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

Comparing ray/src/cal/rcalc.c (file contents):
Revision 1.34 by greg, Sat Mar 12 18:14:45 2022 UTC vs.
Revision 1.35 by greg, Sat Mar 12 19:20:11 2022 UTC

# Line 55 | Line 55 | struct field {          /* record format structure */
55   #define freqstr(s) efree(s)
56  
57   static int getinputrec(FILE *fp);
58 < static void scaninp(void), advinp(void), passinp(void), skipinp(void);
58 > static void scaninp(void), skipinp(void), advinp(int skip);
59   static void putrec(void), putout(void), nbsynch(void);
60   static int getrec(void);
61   static void execute(char *file);
# Line 348 | Line 348 | char *file
348                  colflg = 0;
349                  eclock++;
350                  if (!conditional || varvalue(condVN) > 0.0) {
351 +                        if (inpfmt != NULL)
352 +                                advinp(0);
353                          putout();
354                          ++nout;
353                        advinp();
355                  } else if (inpfmt != NULL) {
356 <                        if (passive < 0)
356 <                                passinp();
357 <                        else
358 <                                advinp();
356 >                        advinp(1);
357                  }
358                  if (incnt && nrecs >= incnt)
359                          break;
# Line 930 | Line 928 | scaninp(void)                  /* scan next character */
928  
929  
930   static void
931 < advinp(void)                    /* move home to current position */
931 > skipinp(void)                   /* rewind position and advance 1 */
932   {
933 <        ipb.beg = ipb.pos;
933 >        if (ipb.beg == NULL)            /* can't fully rewind? */
934 >                ipb.beg = ipb.end;
935 >        ipb.pos = ipb.beg;
936 >        ipb.chr = *ipb.pos;
937 >        if (passive)                    /* transmit unmatched character? */
938 >                putchar(ipb.chr);
939 >        if (++ipb.beg >= &inpbuf[INBSIZ])
940 >                ipb.beg = inpbuf;
941 >        scaninp();
942   }
943  
944  
945   static void
946 < passinp(void)                   /* pass beginning to current position */
946 > advinp(int skip)                /* advance home to current position */
947   {
948 <        if (!passive) {
949 <                advinp();               /* mistake to call us */
948 >        if (!skip | (passive >= 0)) {
949 >                ipb.beg = ipb.pos;      /* no need to copy input */
950                  return;
951          }
952 <        if (ipb.beg == NULL)            /* buffer overflowed a bit */
952 >        if (ipb.beg == NULL)            /* buffer overflowed a bit? */
953                  ipb.beg = ipb.end;
954 <        while (ipb.beg != ipb.pos) {    /* transfer buffer unaltered */
954 >        while (ipb.beg != ipb.pos) {    /* copy buffer to current */
955                  putchar(*ipb.beg);
956                  if (++ipb.beg >= &inpbuf[INBSIZ])
957                          ipb.beg = inpbuf;
958          }
953 }
954
955
956 static void
957 skipinp(void)                   /* rewind position and advance 1 */
958 {
959        if (ipb.beg == NULL)            /* overflow - can't fully rewind */
960                ipb.beg = ipb.end;
961        ipb.pos = ipb.beg;
962        ipb.chr = *ipb.pos;
963        if (passive)                    /* transmit unmatched character? */
964                putchar(ipb.chr);
965        if (++ipb.beg >= &inpbuf[INBSIZ])
966                ipb.beg = inpbuf;
967        scaninp();
959   }
960  
961  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines