| 123 |
|
int outfmt = 'a'; /* output format */ |
| 124 |
|
|
| 125 |
|
int header = 1; /* output header? */ |
| 126 |
+ |
int force_open = 0; /* truncate existing output? */ |
| 127 |
|
int xres = 0; /* horiz. output resolution */ |
| 128 |
|
int yres = 0; /* vert. output resolution */ |
| 129 |
|
|
| 267 |
|
continue; |
| 268 |
|
} |
| 269 |
|
break; |
| 270 |
< |
case 'f': /* file or i/o format */ |
| 270 |
> |
case 'f': /* file or force or format */ |
| 271 |
|
if (!argv[i][2]) { |
| 272 |
|
char *fpath; |
| 273 |
|
if (i >= argc-2) break; |
| 282 |
|
fcompile(fpath); |
| 283 |
|
continue; |
| 284 |
|
} |
| 285 |
+ |
if (argv[i][2] == 'o') { |
| 286 |
+ |
force_open++; |
| 287 |
+ |
continue; |
| 288 |
+ |
} |
| 289 |
|
setformat(argv[i]+2); |
| 290 |
|
continue; |
| 291 |
|
case 'e': /* expression */ |
| 715 |
|
long i; |
| 716 |
|
if (oname[0] == '!') /* output to command */ |
| 717 |
|
sop->ofp = popen(oname+1, "w"); |
| 718 |
< |
else |
| 718 |
> |
else if (!force_open && access(oname, F_OK) == 0) |
| 719 |
> |
errno = EEXIST; /* file exists */ |
| 720 |
> |
else /* else open it */ |
| 721 |
|
sop->ofp = fopen(oname, "w"); |
| 722 |
|
if (sop->ofp == NULL) { |
| 723 |
|
sprintf(errmsg, "cannot open '%s' for writing", oname); |