| 10 |
|
#include "resolu.h" |
| 11 |
|
#include "platform.h" |
| 12 |
|
|
| 13 |
+ |
/* Close output stream and free record */ |
| 14 |
+ |
static void |
| 15 |
+ |
closestream(void *p) |
| 16 |
+ |
{ |
| 17 |
+ |
STREAMOUT *sop = (STREAMOUT *)p; |
| 18 |
+ |
|
| 19 |
+ |
if (sop->ofp != NULL) { |
| 20 |
+ |
int status = 0; |
| 21 |
+ |
if (sop->outpipe) |
| 22 |
+ |
status = pclose(sop->ofp); |
| 23 |
+ |
else if (sop->ofp != stdout) |
| 24 |
+ |
status = fclose(sop->ofp); |
| 25 |
+ |
if (status) |
| 26 |
+ |
error(SYSTEM, "error closing output stream"); |
| 27 |
+ |
} |
| 28 |
+ |
free(p); |
| 29 |
+ |
} |
| 30 |
+ |
|
| 31 |
+ |
LUTAB ofiletab = LU_SINIT(free,closestream); /* output file table */ |
| 32 |
+ |
|
| 33 |
|
#define OF_MODIFIER 01 |
| 34 |
|
#define OF_BIN 02 |
| 35 |
|
|
| 140 |
|
STREAMOUT *sop; |
| 141 |
|
|
| 142 |
|
if (ospec == NULL) { /* use stdout? */ |
| 143 |
< |
if (!noopen && !using_stdout) { |
| 143 |
> |
if (!noopen & !using_stdout) { |
| 144 |
|
if (outfmt != 'a') |
| 145 |
|
SET_FILE_BINARY(stdout); |
| 146 |
|
if (header) |
| 329 |
|
|
| 330 |
|
put_contrib(mp->cbin[0], sop->ofp); |
| 331 |
|
if (mp->nbins > 3 && /* minor optimization */ |
| 332 |
< |
sop == getostream(mp->outspec, mp->modname, 1, 0)) |
| 332 |
> |
sop == getostream(mp->outspec, mp->modname, 1, 0)) { |
| 333 |
|
for (j = 1; j < mp->nbins; j++) |
| 334 |
|
put_contrib(mp->cbin[j], sop->ofp); |
| 335 |
< |
else |
| 335 |
> |
} else { |
| 336 |
|
for (j = 1; j < mp->nbins; j++) { |
| 337 |
|
sop = getostream(mp->outspec, mp->modname, j, 0); |
| 338 |
|
put_contrib(mp->cbin[j], sop->ofp); |
| 339 |
|
} |
| 340 |
+ |
} |
| 341 |
|
} |
| 342 |
|
|
| 343 |
|
|
| 677 |
|
if (getvec(vdummy) < 0 || getvec(vdummy) < 0) |
| 678 |
|
error(USER, "unexpected EOF on input"); |
| 679 |
|
} |
| 680 |
< |
lastray = lastdone = lastout * accumulate; |
| 680 |
> |
lastray = lastdone = (RNUMBER)lastout * accumulate; |
| 681 |
|
if (raysleft) |
| 682 |
|
raysleft -= lastray; |
| 683 |
|
} |