--- ray/src/rt/rc2.c 2016/09/16 04:49:15 2.20 +++ ray/src/rt/rc2.c 2023/04/07 00:03:26 2.25 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rc2.c,v 2.20 2016/09/16 04:49:15 greg Exp $"; +static const char RCSid[] = "$Id: rc2.c,v 2.25 2023/04/07 00:03:26 greg Exp $"; #endif /* * Accumulate ray contributions for a set of materials @@ -116,6 +116,8 @@ printheader(FILE *fout, const char *info) fputs("NCOMP=3\n", fout); /* always RGB */ if (info != NULL) /* add extra info if given */ fputs(info, fout); + if ((outfmt == 'f') | (outfmt == 'd')) + fputendian(fout); fputformat(formstr(outfmt), fout); fputc('\n', fout); /* empty line ends header */ } @@ -141,11 +143,15 @@ getostream(const char *ospec, const char *mname, int b LUENT *lep; STREAMOUT *sop; char *cp; - + + info[0] = '\0'; if (ospec == NULL) { /* use stdout? */ if (!noopen & !using_stdout) { if (outfmt != 'a') SET_FILE_BINARY(stdout); +#ifdef getc_unlocked + flockfile(stdout); /* avoid lock/unlock overhead */ +#endif if (header) { cp = info; if (yres > 0) { @@ -162,9 +168,6 @@ getostream(const char *ospec, const char *mname, int b if (waitflush > 0) fflush(stdout); stdos.xr = xres; stdos.yr = yres; -#ifdef getc_unlocked - flockfile(stdout); /* avoid lock/unlock overhead */ -#endif using_stdout = 1; } stdos.ofp = stdout; @@ -519,7 +522,7 @@ myseeko(const LUENT *e, void *p) off_t nbytes = *(off_t *)p; if (sop->reclen > 1) - nbytes = nbytes * sop->reclen; + nbytes *= (off_t)sop->reclen; if (fseeko(sop->ofp, nbytes, SEEK_CUR) < 0) { sprintf(errmsg, "seek error on file '%s'", e->key); error(SYSTEM, errmsg); @@ -588,6 +591,7 @@ recover_output() sprintf(errmsg, "missing recover file '%s'", oname); error(WARNING, errmsg); + lastout = 0; break; } nvals = lseek(fileno(sop->ofp), 0, SEEK_END); @@ -620,7 +624,8 @@ recover_output() } if (!lastout) { /* empty output */ error(WARNING, "no previous data to recover"); - lu_done(&ofiletab); /* reclose all outputs */ + /* reclose all outputs */ + lu_doall(&ofiletab, &myclose, NULL); return; } }