ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rtcontrib.c
(Generate patch)

Comparing ray/src/util/rtcontrib.c (file contents):
Revision 1.1 by greg, Wed May 25 04:45:22 2005 UTC vs.
Revision 1.2 by greg, Thu May 26 06:55:22 2005 UTC

# Line 16 | Line 16 | static const char RCSid[] = "$Id$";
16   #include  "lookup.h"
17   #include  "calcomp.h"
18  
19 #ifdef getc_unlocked            /* avoid horrendous overhead of flockfile */
20 #undef getc
21 #undef putc
22 #define getc    getc_unlocked
23 #define putc    putc_unlocked
24 #define ferror  ferror_unlocked
25 #endif
26
19   #define MAXMODLIST      1024            /* maximum modifiers we'll track */
20  
21   int     treebufsiz = BUFSIZ;            /* current tree buffer size */
22  
23 + typedef double  DCOLOR[3];              /* double-precision color */
24 +
25   /*
26   * The modcont structure is used to accumulate ray contributions
27   * for a particular modifier, which may be subdivided into bins
# Line 43 | Line 37 | typedef struct {
37          const char      *modname;       /* modifier name */
38          EPNODE          *binv;          /* bin value expression */
39          int             nbins;          /* number of accumulation bins */
40 <        COLOR           cbin[1];        /* contribution bins (extends struct) */
40 >        DCOLOR          cbin[1];        /* contribution bins (extends struct) */
41   } MODCONT;                      /* modifier contribution */
42  
43   static void mcfree(void *p) { epfree((*(MODCONT *)p).binv); free(p); }
# Line 66 | Line 60 | FILE *getofile(const char *ospec, const char *mname, i
60   struct rtproc {
61          struct rtproc   *next;          /* next in list of processes */
62          SUBPROC         pd;             /* rtrace pipe descriptors */
63 <        unsigned long   raynum;         /* ray number for this buffer */
64 <        int             bsiz;           /* rtrace buffer length */
65 <        char            *buf;           /* rtrace i/o buffer */
66 <        char            *bpos;          /* current buffer position */
63 >        unsigned long   raynum;         /* ray number for this tree */
64 >        int             bsiz;           /* ray tree buffer length */
65 >        char            *buf;           /* ray tree buffer */
66 >        int             nbr;            /* number of bytes from rtrace */
67   };                              /* rtrace process */
68  
69                                          /* rtrace command and defaults */
70 < char            *rtargv[256] = { "rtrace", "-dj", ".5", "-dr", "3",
70 > char            *rtargv[256] = { "rtrace", "-dt", "0", "-dj", ".5", "-dr", "3",
71                                  "-ab", "1", "-ad", "512", };
72 < int  rtargc = 9;
72 > int  rtargc = 11;
73                                          /* overriding rtrace options */
74 < char            *myrtopts[] = { "-o-TmWdp", "-h-",
75 <                                "-x", "1", "-y", "0", NULL };
74 > char            *myrtopts[] = { "-o~~TmWdp", "-h-",
75 >                                "-x", "1", "-y", "0",
76 >                                "-as", "0", "-aa", "0", NULL };
77  
78   struct rtproc   rt0;                    /* head of rtrace process list */
79  
# Line 106 | Line 101 | long           waitflush;              /* how long until next flush */
101   unsigned long   lastray = 0;            /* last ray number sent */
102   unsigned long   lastdone = 0;           /* last ray processed */
103  
104 + int             using_stdout = 0;       /* are we using stdout? */
105 +
106   const char      *modname[MAXMODLIST];   /* ordered modifier name list */
107   int             nmods = 0;              /* number of modifiers */
108  
# Line 118 | Line 115 | struct rtproc *wait_rproc(void);
115   struct rtproc *get_rproc(void);
116   void process_rays(struct rtproc *rtp);
117  
118 < void add_contrib(const char *modn, float rayval[7]);
118 > void putcontrib(const DCOLOR cnt, FILE *fout);
119 > void add_contrib(const char *modn);
120   void done_contrib(void);
121  
122   /* set input/output format */
# Line 161 | Line 159 | main(int argc, char *argv[])
159          int     nprocs = 1;
160          char    *curout = NULL;
161          char    *binval = NULL;
162 <        int     i;
163 <                                /* set global argument list */
166 <        gargc = argc;
162 >        int     i, j;
163 >                                /* global program name */
164          gargv = argv;
165 <                                /* set up calcomp functions */
165 >                                /* set up calcomp mode */
166          esupport |= E_VARIABLE|E_FUNCTION|E_INCHAN|E_RCONST|E_REDEFW;
167          esupport &= ~(E_OUTCHAN);
168                                  /* get our options */
169 <        for (i = 1; i < argc && argv[i][0] == '-'; i++) {
170 <                switch (argv[i][1]) {
171 <                case 'n':                       /* number of processes */
172 <                        if (argv[i][2] || i >= argc-1) break;
173 <                        nprocs = atoi(argv[++i]);
174 <                        if (nprocs <= 0)
175 <                                error(USER, "illegal number of processes");
176 <                        continue;
177 <                case 'h':                       /* output header? */
178 <                        switch (argv[i][2]) {
179 <                        case '\0':
180 <                                header = !header;
169 >        for (i = 1; i < argc-1; i++) {
170 >                                                /* expand arguments */
171 >                while ((j = expandarg(&argc, &argv, i)) > 0)
172 >                        ;
173 >                if (j < 0) {
174 >                        fprintf(stderr, "%s: cannot expand '%s'",
175 >                                        argv[0], argv[i]);
176 >                        exit(1);
177 >                }
178 >                if (argv[i][0] == '-')
179 >                        switch (argv[i][1]) {
180 >                        case 'n':               /* number of processes */
181 >                                if (argv[i][2] || i >= argc-1) break;
182 >                                nprocs = atoi(argv[++i]);
183 >                                if (nprocs <= 0)
184 >                                        error(USER, "illegal number of processes");
185                                  continue;
186 <                        case '+': case '1': case 'T': case 't':
187 <                                header = 1;
186 >                        case 'h':               /* output header? */
187 >                                switch (argv[i][2]) {
188 >                                case '\0':
189 >                                        header = !header;
190 >                                        continue;
191 >                                case '+': case '1': case 'T': case 't':
192 >                                        header = 1;
193 >                                        continue;
194 >                                case '-': case '0': case 'F': case 'f':
195 >                                        header = 0;
196 >                                        continue;
197 >                                }
198 >                                break;
199 >                        case 'f':               /* file or i/o format */
200 >                                if (!argv[i][2]) {
201 >                                        if (i >= argc-1) break;
202 >                                        fcompile(argv[++i]);
203 >                                        continue;
204 >                                }
205 >                                setformat(argv[i]+2);
206                                  continue;
207 <                        case '-': case '0': case 'F': case 'f':
208 <                                header = 0;
207 >                        case 'e':               /* expression */
208 >                                if (argv[i][2] || i >= argc-1) break;
209 >                                scompile(argv[++i], NULL, 0);
210                                  continue;
211 <                        }
212 <                        break;
213 <                case 'f':                       /* file or i/o format */
194 <                        if (!argv[i][2]) {
195 <                                if (i >= argc-1) break;
196 <                                fcompile(argv[++i]);
211 >                        case 'o':               /* output file spec. */
212 >                                if (argv[i][2] || i >= argc-1) break;
213 >                                curout = argv[++i];
214                                  continue;
215 +                        case 'x':               /* horiz. output resolution */
216 +                                if (argv[i][2] || i >= argc-1) break;
217 +                                xres = atoi(argv[++i]);
218 +                                continue;
219 +                        case 'y':               /* vert. output resolution */
220 +                                if (argv[i][2] || i >= argc-1) break;
221 +                                yres = atoi(argv[++i]);
222 +                                continue;
223 +                        case 'b':               /* bin expression */
224 +                                if (argv[i][2] || i >= argc-1) break;
225 +                                binval = argv[++i];
226 +                                continue;
227 +                        case 'm':               /* modifier name */
228 +                                if (argv[i][2] || i >= argc-1) break;
229 +                                rtargv[rtargc++] = "-ti";
230 +                                rtargv[rtargc++] = argv[++i];
231 +                                addmodifier(argv[i], curout, binval);
232 +                                continue;
233                          }
234 <                        setformat(argv[i]+2);
200 <                        continue;
201 <                case 'e':                       /* expression */
202 <                        if (argv[i][2] || i >= argc-1) break;
203 <                        scompile(argv[++i], NULL, 0);
204 <                        continue;
205 <                case 'o':                       /* output file spec. */
206 <                        if (argv[i][2] || i >= argc-1) break;
207 <                        curout = argv[++i];
208 <                        continue;
209 <                case 'x':                       /* horiz. output resolution */
210 <                        if (argv[i][2] || i >= argc-1) break;
211 <                        xres = atoi(argv[++i]);
212 <                        continue;
213 <                case 'y':                       /* vert. output resolution */
214 <                        if (argv[i][2] || i >= argc-1) break;
215 <                        yres = atoi(argv[++i]);
216 <                        continue;
217 <                case 'l':                       /* limit distance? */
218 <                        if (argv[i][2] != 'd') break;
219 <                        rtargv[rtargc++] = argv[i];
220 <                        continue;
221 <                case 'b':                       /* bin expression */
222 <                        if (argv[i][2] || i >= argc-1) break;
223 <                        binval = argv[++i];
224 <                        continue;
225 <                case 'm':                       /* modifier name */
226 <                        if (argv[i][2] || i >= argc-1) break;
227 <                        rtargv[rtargc++] = "-ti";
228 <                        rtargv[rtargc++] = argv[++i];
229 <                        addmodifier(argv[i], curout, binval);
230 <                        continue;
231 <                }
232 <                break;          /* break into rtrace options */
234 >                rtargv[rtargc++] = argv[i];     /* assume rtrace option */
235          }
236 <        for ( ; i < argc; i++)  /* transfer rtrace-specific options */
237 <                rtargv[rtargc++] = argv[i];
236 <        if (!strcmp(rtargv[--rtargc], "-defaults"))
237 <                nprocs = 0;
238 <        if (nprocs > 1) {       /* add persist file if parallel invocation */
239 <                rtargv[rtargc++] = "-PP";
240 <                rtargv[rtargc++] = mktemp(persistfn);
241 <        }
236 >                                /* set global argument list */
237 >        gargc = argc; gargv = argv;
238                                  /* add "mandatory" rtrace settings */
239 <        for (i = 0; myrtopts[i] != NULL; i++)
240 <                rtargv[rtargc++] = myrtopts[i];
241 <        if (!nprocs) {          /* just asking for defaults? */
239 >        for (j = 0; myrtopts[j] != NULL; j++)
240 >                rtargv[rtargc++] = myrtopts[j];
241 >                                /* just asking for defaults? */
242 >        if (!strcmp(argv[i], "-defaults")) {
243                  char    sxres[16], syres[16];
244                  char    *rtpath;
245 <                printf("-n  1\t\t\t\t# number of processes\n", nprocs);
245 >                printf("-n  %-2d\t\t\t\t# number of processes\n", nprocs);
246                  fflush(stdout);                 /* report OUR options */
247                  rtargv[rtargc++] = header ? "-h+" : "-h-";
248                  sprintf(fmt, "-f%c%c", inpfmt, outfmt);
# Line 256 | Line 253 | main(int argc, char *argv[])
253                  rtargv[rtargc++] = "-y";
254                  sprintf(syres, "%d", yres);
255                  rtargv[rtargc++] = syres;
256 <                rtargv[rtargc++] = "-oW";
256 >                rtargv[rtargc++] = "-oTW";
257                  rtargv[rtargc++] = "-defaults";
258                  rtargv[rtargc] = NULL;
259                  rtpath = getpath(rtargv[0], getenv("PATH"), X_OK);
# Line 268 | Line 265 | main(int argc, char *argv[])
265                  execv(rtpath, rtargv);
266                  perror(rtpath); /* execv() should not return */
267                  exit(1);
268 <        }
269 <        if (!nmods)
270 <                error(USER, "No modifiers specified");
271 <        if (argc < 2 || argv[argc-1][0] == '-')
275 <                error(USER, "missing octree argument");
268 >        } else if (nprocs > 1) {        /* add persist file if parallel */
269 >                rtargv[rtargc++] = "-PP";
270 >                rtargv[rtargc++] = mktemp(persistfn);
271 >        }
272                                  /* add format string */
273          sprintf(fmt, "-f%cf", inpfmt);
274          rtargv[rtargc++] = fmt;
275                                  /* octree argument is last */
276 <        rtargv[rtargc++] = octree = argv[argc-1];
276 >        if (i <= 0 || i != argc-1 || argv[i][0] == '-')
277 >                error(USER, "missing octree argument");
278 >        rtargv[rtargc++] = octree = argv[i];
279          rtargv[rtargc] = NULL;
280 <                                /* start rtrace & sum contributions */
280 >                                /* start rtrace & compute contributions */
281          init(nprocs);
282          tracecontribs(stdin);
283          quit(0);
# Line 340 | Line 338 | init(int np)
338          struct rtproc   *rtp;
339          int     i;
340          int     maxbytes;
341 +                                        /* make sure we have something to do */
342 +        if (!nmods)
343 +                error(USER, "No modifiers specified");
344                                          /* assign ray variables */
345          scompile("Dx=$1;Dy=$2;Dz=$3;", NULL, 0);
346          scompile("Px=$4;Py=$5;Pz=$6;", NULL, 0);
# Line 360 | Line 361 | init(int np)
361                          error(SYSTEM, "cannot start rtrace process");
362                  if (maxbytes > treebufsiz)
363                          treebufsiz = maxbytes;
364 +                rtp->raynum = 0;
365                  rtp->bsiz = 0;
366                  rtp->buf = NULL;
367 <                rtp->raynum = 0;
367 >                rtp->nbr = 0;
368                  if (i == np)            /* last process? */
369                          break;
370                  if (i == 1)
# Line 437 | Line 439 | printheader(FILE *fout)
439          
440          if (fin == NULL)
441                  quit(1);
442 <        getheader(fin, (gethfunc *)fputs, fout);        /* copy octree header */
442 >        checkheader(fin, "ignore", fout);       /* copy octree header */
443          fclose(fin);
444          printargs(gargc-1, gargv, fout);        /* add our command */
445          fprintf(fout, "SOFTWARE= %s\n", VersionID);
# Line 468 | Line 470 | printheader(FILE *fout)
470   FILE *
471   getofile(const char *ospec, const char *mname, int bn)
472   {
471        static int      using_stdout = 0;
473          const char      *mnp = NULL;
474          const char      *bnp = NULL;
475          const char      *cp;
# Line 519 | Line 520 | getofile(const char *ospec, const char *mname, int bn)
520          if (lep->key == NULL)                   /* new entry */
521                  lep->key = strcpy((char *)malloc(strlen(ofname)+1), ofname);
522          if (lep->data == NULL) {                /* open output file */
523 <                lep->data = (char *)fopen(ofname, "w");
524 <                if (lep->data == NULL) {
523 >                FILE            *fp = fopen(ofname, "w");
524 >                int             i;
525 >                if (fp == NULL) {
526                          sprintf(errmsg, "cannot open '%s' for writing", ofname);
527                          error(SYSTEM, errmsg);
528                  }
529                  if (header)
530 <                        printheader((FILE *)lep->data);
530 >                        printheader(fp);
531 >                                                /* play catch-up */
532 >                for (i = 0; i < lastdone; i++) {
533 >                        static const DCOLOR     nocontrib = BLKCOLOR;
534 >                        putcontrib(nocontrib, fp);
535 >                        if (outfmt == 'a')
536 >                                putc('\n', fp);
537 >                }
538 >                if (xres > 0)
539 >                        fflush(fp);
540 >                lep->data = (char *)fp;
541          }
542          return (FILE *)lep->data;               /* return open file pointer */
543   badspec:
# Line 556 | Line 568 | getinp(char *buf, FILE *fp)
568          return 0;       /* pro forma return */
569   }
570  
571 < static const float      *rparams = NULL;        /* ray parameter pointer */
571 > static float    rparams[9];             /* traced ray parameters */
572  
573   /* return channel (ray) value */
574   double
# Line 564 | Line 576 | chanvalue(int n)
576   {
577          if (--n < 0 || n >= 6)
578                  error(USER, "illegal channel number ($N)");
579 <        if (rparams == NULL)
568 <                error(USER, "illegal use of $N in constant expression");
569 <        return rparams[n];
579 >        return rparams[n+3];
580   }
581  
582 < /* add ray contribution to the appropriate modifier bin */
582 > /* add current ray contribution to the appropriate modifier bin */
583   void
584 < add_contrib(const char *modn, float rayval[9])
584 > add_contrib(const char *modn)
585   {
586          LUENT   *le = lu_find(&modconttab, modn);
587          MODCONT *mp = (MODCONT *)le->data;
# Line 581 | Line 591 | add_contrib(const char *modn, float rayval[9])
591                  sprintf(errmsg, "unexpected modifier '%s' from rtrace", modn);
592                  error(USER, errmsg);
593          }
594 <        rparams = rayval + 3;           /* for chanvalue */
585 <        eclock++;
594 >        eclock++;                       /* get bin number */
595          bn = (int)(evalue(mp->binv) + .5);
596          if (bn <= 0)
597                  bn = 0;
598          else if (bn > mp->nbins) {      /* new bin */
599                  mp = (MODCONT *)realloc(mp, sizeof(MODCONT) +
600 <                                                bn*sizeof(COLOR));
600 >                                                bn*sizeof(DCOLOR));
601                  if (mp == NULL)
602                          error(SYSTEM, "out of memory in add_contrib");
603 <                memset(mp->cbin+mp->nbins, 0, sizeof(COLOR)*(bn+1-mp->nbins));
603 >                memset(mp->cbin+mp->nbins, 0, sizeof(DCOLOR)*(bn+1-mp->nbins));
604                  mp->nbins = bn+1;
605                  le->data = (char *)mp;
606          }
607 <        addcolor(mp->cbin[bn], rayval);
599 <        rparams = NULL;
607 >        addcolor(mp->cbin[bn], rparams);
608   }
609  
610   /* output newline to ASCII file and/or flush as requested */
# Line 616 | Line 624 | puteol(const LUENT *e, void *p)
624          return 0;
625   }
626  
627 + /* put out ray contribution to file */
628 + void
629 + putcontrib(const DCOLOR cnt, FILE *fout)
630 + {
631 +        float   fv[3];
632 +        COLR    cv;
633 +
634 +        switch (outfmt) {
635 +        case 'a':
636 +                fprintf(fout, "%.6e\t%.6e\t%.6e\t", cnt[0], cnt[1], cnt[2]);
637 +                break;
638 +        case 'f':
639 +                fv[0] = cnt[0];
640 +                fv[1] = cnt[1];
641 +                fv[2] = cnt[2];
642 +                fwrite(fv, sizeof(float), 3, fout);
643 +                break;
644 +        case 'd':
645 +                fwrite(cnt, sizeof(double), 3, fout);
646 +                break;
647 +        case 'c':
648 +                setcolr(cv, cnt[0], cnt[1], cnt[2]);
649 +                fwrite(cv, sizeof(cv), 1, fout);
650 +                break;
651 +        default:
652 +                error(INTERNAL, "botched output format");
653 +        }
654 + }
655 +
656   /* output ray tallies and clear for next primary */
657   void
658   done_contrib(void)
659   {
660          int     i, j;
661          MODCONT *mp;
625        FILE    *fout;
626        double  dv[3];
627        COLR    cv;
662                                                  /* output modifiers in order */
663          for (i = 0; i < nmods; i++) {
664                  mp = (MODCONT *)lu_find(&modconttab,modname[i])->data;
665 <                for (j = 0; j < mp->nbins; j++) {
666 <                        fout = getofile(mp->outspec, mp->modname, j);
667 <                        switch (outfmt) {
634 <                        case 'a':
635 <                                fprintf(fout, "%.6e\t%.6e\t%.6e\t",
636 <                                                mp->cbin[j][RED],
637 <                                                mp->cbin[j][GRN],
638 <                                                mp->cbin[j][BLU]);
639 <                                break;
640 <                        case 'f':
641 <                                fwrite(mp->cbin[j], sizeof(float), 3, fout);
642 <                                break;
643 <                        case 'd':
644 <                                dv[0] = mp->cbin[j][0];
645 <                                dv[1] = mp->cbin[j][1];
646 <                                dv[2] = mp->cbin[j][2];
647 <                                fwrite(dv, sizeof(double), 3, fout);
648 <                                break;
649 <                        case 'c':
650 <                                setcolr(cv, mp->cbin[j][RED],
651 <                                        mp->cbin[j][GRN], mp->cbin[j][BLU]);
652 <                                fwrite(cv, sizeof(COLR), 1, fout);
653 <                                break;
654 <                        default:
655 <                                error(INTERNAL, "botched output format");
656 <                        }
657 <                }
665 >                for (j = 0; j < mp->nbins; j++)
666 >                        putcontrib(mp->cbin[j],
667 >                                        getofile(mp->outspec, mp->modname, j));
668                                                  /* clear for next ray tree */
669 <                memset(mp->cbin, 0, sizeof(COLOR)*mp->nbins);
669 >                memset(mp->cbin, 0, sizeof(DCOLOR)*mp->nbins);
670          }
671          --waitflush;                            /* terminate records */
672          lu_doall(&ofiletab, puteol, NULL);
673 <        if (!waitflush)
673 >        if (using_stdout & (outfmt == 'a'))
674 >                putc('\n', stdout);
675 >        if (!waitflush) {
676                  waitflush = xres;
677 +                if (using_stdout)
678 +                        fflush(stdout);
679 +        }
680   }
681  
682   /* process (or save) ray tree produced by rtrace process */
# Line 671 | Line 686 | process_rays(struct rtproc *rtp)
686          struct rtproc   *rtu;
687                                          /* check if time to process it */
688          if (rtp->raynum == lastdone+1) {
689 <                int             n = rtp->bpos - rtp->buf;
689 >                int             n = rtp->nbr;
690                  const char      *cp = rtp->buf;
691 +                char            modname[128];
692                  while (n > 0) {         /* process rays */
693 <                        char    matname[128];
678 <                        char    *mnp = matname;
693 >                        register char   *mnp = modname;
694                                          /* skip leading tabs */
695                          while (n > 0 && *cp == '\t') {
696                                  cp++; n--;
697                          }
698 <                                        /* get material name */
698 >                        if (!n || !(isalpha(*cp) | (*cp == '_')))
699 >                                error(USER, "bad modifier name from rtrace");
700 >                                        /* get modifier name */
701                          while (n > 0 && *cp != '\t') {
702                                  *mnp++ = *cp++; n--;
703                          }
687                        if (!n)
688                                error(USER, "botched modifer name from rtrace");
704                          *mnp = '\0';
705 <                        cp++; n--;      /* skip terminating tab */
705 >                        cp++; n--;      /* eat following tab */
706                          if (n < (int)(sizeof(float)*9))
707                                  error(USER, "incomplete ray value from rtrace");
708                                          /* add ray contribution */
709 <                        add_contrib(matname, (float *)cp);
709 >                        memcpy(rparams, cp, sizeof(float)*9);
710                          cp += sizeof(float)*9; n -= sizeof(float)*9;
711 +                        add_contrib(modname);
712                  }
713                  done_contrib();         /* sum up contributions & output */
714                  lastdone = rtp->raynum;
# Line 723 | Line 739 | process_rays(struct rtproc *rtp)
739          rtp->raynum = 0;                /* clear path for next ray tree */
740          rtp->bsiz = 0;
741          rtp->buf = NULL;
742 +        rtp->nbr = 0;
743   }
744  
745   /* wait for rtrace process to finish with ray tree */
# Line 763 | Line 780 | wait_rproc(void)
780                          if (rt->buf == NULL) {
781                                  rt->bsiz = treebufsiz;
782                                  rt->buf = (char *)malloc(treebufsiz);
783 <                        } else if (rt->bpos + BUFSIZ > rt->buf + rt->bsiz) {
783 >                        } else if (rt->nbr + BUFSIZ > rt->bsiz) {
784                                  if (rt->bsiz + BUFSIZ <= treebufsiz)
785                                          rt->bsiz = treebufsiz;
786                                  else
# Line 772 | Line 789 | wait_rproc(void)
789                          }
790                          if (rt->buf == NULL)
791                                  error(SYSTEM, "out of memory in wait_rproc");
792 <                        nr = read(rt->pd.r, rt->bpos,
793 <                                        rt->buf + rt->bsiz - rt->bpos);
777 <                        if (!nr)
792 >                        nr = read(rt->pd.r, rt->buf+rt->nbr, rt->bsiz-rt->nbr);
793 >                        if (nr <= 0)
794                                  error(USER, "rtrace process died");
795 <                        rt->bpos += nr;         /* advance buffer & check */
796 <                        if (rt->bpos[-1] == '\t' && rt->bpos[-2] == '-') {
797 <                                rt->bpos -= 2;  /* elide terminator */
795 >                        rt->nbr += nr;          /* advance & check */
796 >                        if (rt->nbr >= 4 && !memcmp(rt->buf+rt->nbr-4,
797 >                                                        "~\t~\t", 4)) {
798 >                                rt->nbr -= 4;   /* elide terminator */
799                                  process_rays(rt);
800                                  rtfree = rt;    /* ready for next ray */
801                          }
# Line 821 | Line 838 | tracecontribs(FILE *fin)
838          }
839          while (wait_rproc() != NULL)            /* process outstanding rays */
840                  ;
841 +        if (raysleft > 0)
842 +                error(USER, "unexpected EOF on input");
843   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines