| 123 |
|
setformat(const char *fmt) |
| 124 |
|
{ |
| 125 |
|
switch (fmt[0]) { |
| 126 |
– |
case 'a': |
| 126 |
|
case 'f': |
| 127 |
|
case 'd': |
| 128 |
+ |
SET_FILE_BINARY(stdin); |
| 129 |
+ |
/* fall through */ |
| 130 |
+ |
case 'a': |
| 131 |
|
inpfmt = fmt[0]; |
| 132 |
|
break; |
| 133 |
|
default: |
| 164 |
|
int i, j; |
| 165 |
|
/* global program name */ |
| 166 |
|
gargv = argv; |
| 167 |
< |
/* set up calcomp mode */ |
| 167 |
> |
/* initialize calcomp routines */ |
| 168 |
|
esupport |= E_VARIABLE|E_FUNCTION|E_INCHAN|E_RCONST|E_REDEFW; |
| 169 |
|
esupport &= ~(E_OUTCHAN); |
| 170 |
+ |
varset("PI", ':', PI); |
| 171 |
|
/* get our options */ |
| 172 |
|
for (i = 1; i < argc-1; i++) { |
| 173 |
|
/* expand arguments */ |
| 501 |
|
LUENT *lep; |
| 502 |
|
|
| 503 |
|
if (ospec == NULL) { /* use stdout? */ |
| 504 |
< |
if (!using_stdout && header) |
| 505 |
< |
printheader(stdout); |
| 504 |
> |
if (!using_stdout) { |
| 505 |
> |
if (outfmt != 'a') |
| 506 |
> |
SET_FILE_BINARY(stdout); |
| 507 |
> |
if (header) |
| 508 |
> |
printheader(stdout); |
| 509 |
> |
} |
| 510 |
|
using_stdout = 1; |
| 511 |
|
return stdout; |
| 512 |
|
} |
| 548 |
|
if (lep->key == NULL) /* new entry */ |
| 549 |
|
lep->key = strcpy((char *)malloc(strlen(ofname)+1), ofname); |
| 550 |
|
if (lep->data == NULL) { /* open output file */ |
| 551 |
< |
FILE *fp = fopen(ofname, "w"); |
| 551 |
> |
FILE *fp; |
| 552 |
|
int i; |
| 553 |
+ |
if (ofname[0] == '!') /* output to command */ |
| 554 |
+ |
fp = popen(ofname+1, "w"); |
| 555 |
+ |
else |
| 556 |
+ |
fp = fopen(ofname, "w"); |
| 557 |
|
if (fp == NULL) { |
| 558 |
|
sprintf(errmsg, "cannot open '%s' for writing", ofname); |
| 559 |
|
error(SYSTEM, errmsg); |
| 560 |
|
} |
| 561 |
+ |
if (outfmt != 'a') |
| 562 |
+ |
SET_FILE_BINARY(fp); |
| 563 |
|
if (header) |
| 564 |
|
printheader(fp); |
| 565 |
|
/* play catch-up */ |
| 706 |
|
MODCONT *mp; |
| 707 |
|
/* output modifiers in order */ |
| 708 |
|
for (i = 0; i < nmods; i++) { |
| 709 |
+ |
FILE *fp; |
| 710 |
|
mp = (MODCONT *)lu_find(&modconttab,modname[i])->data; |
| 711 |
< |
for (j = 0; j < mp->nbins; j++) |
| 712 |
< |
putcontrib(mp->cbin[j], |
| 711 |
> |
fp = getofile(mp->outspec, mp->modname, 0); |
| 712 |
> |
putcontrib(mp->cbin[0], fp); |
| 713 |
> |
if (mp->nbins > 3 && /* minor optimization */ |
| 714 |
> |
fp == getofile(mp->outspec, mp->modname, 1)) |
| 715 |
> |
for (j = 1; j < mp->nbins; j++) |
| 716 |
> |
putcontrib(mp->cbin[j], fp); |
| 717 |
> |
else |
| 718 |
> |
for (j = 1; j < mp->nbins; j++) |
| 719 |
> |
putcontrib(mp->cbin[j], |
| 720 |
|
getofile(mp->outspec, mp->modname, j)); |
| 721 |
|
/* clear for next ray tree */ |
| 722 |
|
memset(mp->cbin, 0, sizeof(DCOLOR)*mp->nbins); |