| 8 |
|
|
| 9 |
|
#include "rcontrib.h" |
| 10 |
|
#include "resolu.h" |
| 11 |
– |
#include "platform.h" |
| 11 |
|
|
| 12 |
+ |
/* Close output stream and free record */ |
| 13 |
+ |
static void |
| 14 |
+ |
closestream(void *p) |
| 15 |
+ |
{ |
| 16 |
+ |
STREAMOUT *sop = (STREAMOUT *)p; |
| 17 |
+ |
|
| 18 |
+ |
if (sop->ofp != NULL) { |
| 19 |
+ |
int status = 0; |
| 20 |
+ |
if (sop->outpipe) |
| 21 |
+ |
status = pclose(sop->ofp); |
| 22 |
+ |
else if (sop->ofp != stdout) |
| 23 |
+ |
status = fclose(sop->ofp); |
| 24 |
+ |
if (status) |
| 25 |
+ |
error(SYSTEM, "error closing output stream"); |
| 26 |
+ |
} |
| 27 |
+ |
free(p); |
| 28 |
+ |
} |
| 29 |
+ |
|
| 30 |
+ |
LUTAB ofiletab = LU_SINIT(free,closestream); /* output file table */ |
| 31 |
+ |
|
| 32 |
|
#define OF_MODIFIER 01 |
| 33 |
|
#define OF_BIN 02 |
| 34 |
|
|
| 139 |
|
STREAMOUT *sop; |
| 140 |
|
|
| 141 |
|
if (ospec == NULL) { /* use stdout? */ |
| 142 |
< |
if (!noopen && !using_stdout) { |
| 142 |
> |
if (!noopen & !using_stdout) { |
| 143 |
|
if (outfmt != 'a') |
| 144 |
|
SET_FILE_BINARY(stdout); |
| 145 |
|
if (header) |
| 328 |
|
|
| 329 |
|
put_contrib(mp->cbin[0], sop->ofp); |
| 330 |
|
if (mp->nbins > 3 && /* minor optimization */ |
| 331 |
< |
sop == getostream(mp->outspec, mp->modname, 1, 0)) |
| 331 |
> |
sop == getostream(mp->outspec, mp->modname, 1, 0)) { |
| 332 |
|
for (j = 1; j < mp->nbins; j++) |
| 333 |
|
put_contrib(mp->cbin[j], sop->ofp); |
| 334 |
< |
else |
| 334 |
> |
} else { |
| 335 |
|
for (j = 1; j < mp->nbins; j++) { |
| 336 |
|
sop = getostream(mp->outspec, mp->modname, j, 0); |
| 337 |
|
put_contrib(mp->cbin[j], sop->ofp); |
| 338 |
|
} |
| 339 |
+ |
} |
| 340 |
|
} |
| 341 |
|
|
| 342 |
|
|
| 363 |
|
end_record() |
| 364 |
|
{ |
| 365 |
|
--waitflush; |
| 366 |
< |
lu_doall(&ofiletab, puteol, NULL); |
| 366 |
> |
lu_doall(&ofiletab, &puteol, NULL); |
| 367 |
|
if (using_stdout & (outfmt == 'a')) |
| 368 |
|
putc('\n', stdout); |
| 369 |
|
if (!waitflush) { |
| 513 |
|
*(STREAMOUT *)oent->data = sout; |
| 514 |
|
} |
| 515 |
|
} |
| 516 |
< |
lu_doall(&ofiletab, myclose, NULL); /* close all files */ |
| 516 |
> |
lu_doall(&ofiletab, &myclose, NULL); /* close all files */ |
| 517 |
|
} |
| 518 |
|
|
| 519 |
|
|
| 669 |
|
} |
| 670 |
|
/* seek on all files */ |
| 671 |
|
nvals = lastout * outvsiz; |
| 672 |
< |
lu_doall(&ofiletab, myseeko, &nvals); |
| 672 |
> |
lu_doall(&ofiletab, &myseeko, &nvals); |
| 673 |
|
/* skip repeated input */ |
| 674 |
+ |
lastout *= accumulate; |
| 675 |
|
for (nvals = 0; nvals < lastout; nvals++) { |
| 676 |
|
FVECT vdummy; |
| 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; |
| 681 |
|
if (raysleft) |
| 682 |
|
raysleft -= lastray; |
| 683 |
|
} |