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.1 by greg, Sat Feb 22 02:07:20 2003 UTC vs.
Revision 1.28 by greg, Sun May 19 20:02:27 2019 UTC

# Line 1 | Line 1
1   #ifndef lint
2 < static const char       RCSid[] = "$Id$";
2 > static const char RCSid[] = "$Id$";
3   #endif
4   /*
5   *  rcalc.c - record calculator program.
# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7   *     9/11/87
8   */
9  
10 #include  <stdio.h>
11
10   #include  <stdlib.h>
13
11   #include  <math.h>
15
12   #include  <ctype.h>
13  
14 + #include  "platform.h"
15 + #include  "rterror.h"
16 + #include  "rtmisc.h"
17 + #include  "rtio.h"
18   #include  "calcomp.h"
19  
20 #ifdef  CPM
21 #define  getc           agetc   /* text files only, right? */
22 #endif
23
20   #define  isnum(c)       (isdigit(c) || (c)=='-' || (c)=='.' \
21                                  || (c)=='+' || (c)=='e' || (c)=='E')
22  
23   #define  isblnk(c)      (igneol ? isspace(c) : (c)==' '||(c)=='\t')
24  
25 < #define  INBSIZ         4096    /* longest record */
25 > #define  INBSIZ         16384   /* longest record */
26   #define  MAXCOL         32      /* number of columns recorded */
27  
28                                  /* field type specifications */
# Line 58 | Line 54 | struct field {                  /* record format struc
54   #define  savqstr(s)     strcpy(emalloc(strlen(s)+1),s)
55   #define  freqstr(s)     efree(s)
56  
57 < extern char  *strcpy(), *emalloc(), *savestr();
58 < struct strvar  *getsvar();
57 > static int getinputrec(FILE *fp);
58 > static void scaninp(void), advinp(void), resetinp(void);
59 > static void putrec(void), putout(void), nbsynch(void);
60 > static int getrec(void);
61 > static void execute(char *file);
62 > static void initinp(FILE *fp);
63 > static void svpreset(char *eqn);
64 > static void readfmt(char *spec, int output);
65 > static int readfield(char **pp);
66 > static int getfield(struct field *f);
67 > static void chanset(int n, double v);
68 > static void bchanset(int n, double v);
69 > static struct strvar* getsvar(char *svname);
70 > static double l_in(char *);
71  
72   struct field  *inpfmt = NULL;   /* input record format */
73   struct field  *outfmt = NULL;   /* output record structure */
74   struct strvar  *svhead = NULL;  /* string variables */
75  
76 + long  incnt = 0;                /* limit number of input records? */
77 + long  outcnt = 0;               /* limit number of output records? */
78 +
79   int  blnkeq = 1;                /* blanks compare equal? */
80   int  igneol = 0;                /* ignore end of line? */
81 + int  passive = 0;               /* passive mode (transmit unmatched input) */
82   char  sepchar = '\t';           /* input/output separator */
83   int  noinput = 0;               /* no input records? */
84 + int  itype = 'a';               /* input type (a/f/F/d/D) */
85 + int  nbicols = 0;               /* number of binary input columns */
86 + int  otype = 'a';               /* output format (a/f/F/d/D) */
87   char  inpbuf[INBSIZ];           /* input buffer */
88   double  colval[MAXCOL];         /* input column values */
89   unsigned long  colflg = 0;      /* column retrieved flags */
# Line 86 | Line 101 | struct {
101   } ipb;                          /* circular lookahead buffer */
102  
103  
104 < main(argc, argv)
105 < int  argc;
106 < char  *argv[];
104 > int
105 > main(
106 > int  argc,
107 > char  *argv[]
108 > )
109   {
110 +        char  *fpath;
111          int  i;
112  
113 <        esupport |= (E_VARIABLE|E_FUNCTION|E_INCHAN|E_OUTCHAN|E_RCONST);
113 >        esupport |= E_VARIABLE|E_FUNCTION|E_INCHAN|E_OUTCHAN|E_RCONST;
114 >        esupport &= ~(E_REDEFW);
115  
116   #ifdef  BIGGERLIB
117          biggerlib();
118   #endif
119          varset("PI", ':', 3.14159265358979323846);
120 +        funset("in", 1, '=', &l_in);
121  
122          for (i = 1; i < argc && argv[i][0] == '-'; i++)
123                  switch (argv[i][1]) {
# Line 107 | Line 127 | char  *argv[];
127                  case 'l':
128                          igneol = !igneol;
129                          break;
130 +                case 'p':
131 +                        passive = !passive;
132 +                        break;
133                  case 't':
134                          sepchar = argv[i][2];
135                          break;
# Line 114 | Line 137 | char  *argv[];
137                          svpreset(argv[++i]);
138                          break;
139                  case 'f':
140 <                        fcompile(argv[++i]);
140 >                        fpath = getpath(argv[++i], getrlibpath(), 0);
141 >                        if (fpath == NULL) {
142 >                                eputs(argv[0]);
143 >                                eputs(": cannot find file '");
144 >                                eputs(argv[i]);
145 >                                eputs("'\n");
146 >                                quit(1);
147 >                        }
148 >                        fcompile(fpath);
149                          break;
150                  case 'e':
151                          scompile(argv[++i], NULL, 0);
# Line 123 | Line 154 | char  *argv[];
154                          noinput = 1;
155                          break;
156                  case 'i':
157 <                        readfmt(argv[++i], 0);
157 >                        switch (argv[i][2]) {
158 >                        case '\0':
159 >                                itype = 'a';
160 >                                nbicols = 0;
161 >                                readfmt(argv[++i], 0);
162 >                                break;
163 >                        case 'n':
164 >                                incnt = atol(argv[++i]);
165 >                                break;
166 >                        case 'a':
167 >                                itype = 'a';
168 >                                nbicols = 0;
169 >                                break;
170 >                        case 'd':
171 >                        case 'D':
172 >                                itype = argv[i][2];
173 >                                if (isdigit(argv[i][3]))
174 >                                        nbicols = atoi(argv[i]+3);
175 >                                else
176 >                                        nbicols = 1;
177 >                                if (nbicols*sizeof(double) > INBSIZ) {
178 >                                        eputs(argv[0]);
179 >                                        eputs(": too many input columns\n");
180 >                                        quit(1);
181 >                                }
182 >                                break;
183 >                        case 'f':
184 >                        case 'F':
185 >                                itype = argv[i][2];
186 >                                if (isdigit(argv[i][3]))
187 >                                        nbicols = atoi(argv[i]+3);
188 >                                else
189 >                                        nbicols = 1;
190 >                                if (nbicols*sizeof(float) > INBSIZ) {
191 >                                        eputs(argv[0]);
192 >                                        eputs(": too many input columns\n");
193 >                                        quit(1);
194 >                                }
195 >                                break;
196 >                        default:
197 >                                goto userr;
198 >                        }
199                          break;
200                  case 'o':
201 <                        readfmt(argv[++i], 1);
201 >                        switch (argv[i][2]) {
202 >                        case '\0':
203 >                                otype = 'a';
204 >                                readfmt(argv[++i], 1);
205 >                                break;
206 >                        case 'n':
207 >                                outcnt = atol(argv[++i]);
208 >                                break;
209 >                        case 'a':
210 >                                otype = 'a';
211 >                                break;
212 >                        case 'd':
213 >                        case 'D':
214 >                        case 'f':
215 >                        case 'F':
216 >                                otype = argv[i][2];
217 >                                break;
218 >                        default:
219 >                                goto userr;
220 >                        }
221                          break;
222                  case 'w':
223                          nowarn = !nowarn;
# Line 134 | Line 225 | char  *argv[];
225                  case 'u':
226                          unbuff = !unbuff;
227                          break;
228 <                default:
228 >                default:;
229 >                userr:
230                          eputs("Usage: ");
231                          eputs(argv[0]);
232 < eputs(" [-b][-l][-n][-w][-u][-tS][-s svar=sval][-e expr][-f source][-i infmt][-o outfmt] [file]\n");
232 > eputs(" [-b][-l][-n][-p][-w][-u][-tS][-s svar=sval][-e expr][-f source][-i infmt][-o outfmt] [file]\n");
233                          quit(1);
234                  }
235 <
235 >        if (otype != 'a')
236 >                SET_FILE_BINARY(stdout);
237 > #ifdef getc_unlocked            /* avoid lock/unlock overhead */
238 >        flockfile(stdout);
239 > #endif
240          if (noinput) {          /* produce a single output record */
241 +                if (i < argc) {
242 +                        eputs(argv[0]);
243 +                        eputs(": file argument(s) incompatible with -n\n");
244 +                        quit(1);
245 +                }
246                  eclock++;
247                  putout();
248                  quit(0);
249          }
149
250          if (blnkeq)             /* for efficiency */
251                  nbsynch();
252  
# Line 157 | Line 257 | eputs(" [-b][-l][-n][-w][-u][-tS][-s svar=sval][-e exp
257                          execute(argv[i]);
258          
259          quit(0);
260 +        return 0; /* pro forma return */
261   }
262  
263  
264 < nbsynch()               /* non-blank starting synch character */
264 > static void
265 > nbsynch(void)               /* non-blank starting synch character */
266   {
267          if (inpfmt == NULL || (inpfmt->type & F_TYP) != T_LIT)
268                  return;
# Line 171 | Line 273 | nbsynch()               /* non-blank starting synch ch
273   }
274  
275  
276 < execute(file)           /* process a file */
277 < char  *file;
276 > static int
277 > getinputrec(            /* get next input record */
278 > FILE  *fp
279 > )
280   {
281 <        int  conditional = vardefined("cond");
281 >        if (inpfmt != NULL)
282 >                return(getrec());
283 >        if (tolower(itype) == 'd') {
284 >                if (getbinary(inpbuf, sizeof(double), nbicols, fp) != nbicols)
285 >                        return(0);
286 >                if (itype == 'D')
287 >                        swap64(inpbuf, nbicols);
288 >                return(1);
289 >        }
290 >        if (tolower(itype) == 'f') {
291 >                if (getbinary(inpbuf, sizeof(float), nbicols, fp) != nbicols)
292 >                        return(0);
293 >                if (itype == 'F')
294 >                        swap32(inpbuf, nbicols);
295 >                return(1);
296 >        }
297 >        return(fgets(inpbuf, INBSIZ, fp) != NULL);
298 > }
299 >
300 >
301 > static void
302 > execute(           /* process a file */
303 > char  *file
304 > )
305 > {
306 >        const int  conditional = vardefined("cond");
307 >        const int  set_recno = (varlookup("recno") != NULL);
308 >        const int  set_outno = (varlookup("outno") != NULL);
309          long  nrecs = 0;
310          long  nout = 0;
311          FILE  *fp;
# Line 186 | Line 317 | char  *file;
317                  eputs(": cannot open\n");
318                  quit(1);
319          }
320 +        if (itype != 'a')
321 +                SET_FILE_BINARY(fp);
322 + #ifdef getc_unlocked            /* avoid lock/unlock overhead */
323 +        flockfile(fp);
324 + #endif
325          if (inpfmt != NULL)
326                  initinp(fp);
327 <                
328 <        while (inpfmt != NULL ? getrec() : fgets(inpbuf, INBSIZ, fp) != NULL) {
329 <                varset("recno", '=', (double)++nrecs);
327 >        
328 >        while (getinputrec(fp)) {
329 >                ++nrecs;
330 >                if (set_recno)
331 >                        varset("recno", '=', (double)nrecs);
332 >                if (set_outno)
333 >                        varset("outno", '=', (double)(nout+1));
334                  colflg = 0;
335                  eclock++;
336                  if (!conditional || varvalue("cond") > 0.0) {
197                        varset("outno", '=', (double)++nout);
337                          putout();
338 +                        ++nout;
339                  }
340 +                if (incnt && nrecs >= incnt)
341 +                        break;
342 +                if (outcnt && nout >= outcnt)
343 +                        break;
344          }
345          fclose(fp);
346   }
347  
348  
349 < putout()                /* produce an output record */
349 > static void
350 > putout(void)                /* produce an output record */
351   {
207        extern int  chanset();
352  
353          colpos = 0;
354          if (outfmt != NULL)
355                  putrec();
356 <        else
356 >        else if (otype == 'a')
357                  chanout(chanset);
358 <        if (colpos)
358 >        else
359 >                chanout(bchanset);
360 >        if (colpos && otype == 'a')
361                  putchar('\n');
362          if (unbuff)
363                  fflush(stdout);
364   }
365  
366  
367 + static double
368 + l_in(char *funame)      /* function call for $channel */
369 + {
370 +        int  n;
371 +        char  *cp;
372 +                        /* get argument as integer */
373 +        n = (int)(argument(1) + .5);
374 +        if (n != 0)     /* return channel value */
375 +                return(chanvalue(n));
376 +                        /* determine number of channels */
377 +        if (noinput || inpfmt != NULL)
378 +                return(0);
379 +        if (nbicols)
380 +                return(nbicols);
381 +        cp = inpbuf;    /* need to count */
382 +        for (n = 0; *cp; )
383 +                if (blnkeq && isspace(sepchar)) {
384 +                        while (isspace(*cp))
385 +                                cp++;
386 +                        n += *cp != '\0';
387 +                        while (*cp && !isspace(*cp))
388 +                                cp++;
389 +                } else {
390 +                        n += *cp != '\n';
391 +                        while (*cp && *cp++ != sepchar)
392 +                                ;
393 +                }
394 +        return(n);
395 + }
396 +
397   double
398 < chanvalue(n)            /* return value for column n */
399 < int  n;
398 > chanvalue(            /* return value for column n */
399 > int  n
400 > )
401   {
402          int  i;
403 <        register char  *cp;
403 >        char  *cp;
404  
405          if (noinput || inpfmt != NULL) {
406                  eputs("no column input\n");
# Line 233 | Line 410 | int  n;
410                  eputs("illegal channel number\n");
411                  quit(1);
412          }
413 +        if (nbicols) {
414 +                if (n > nbicols)
415 +                        return(0.0);
416 +                if (tolower(itype) == 'd') {
417 +                        cp = inpbuf + (n-1)*sizeof(double);
418 +                        return(*(double *)cp);
419 +                }
420 +                cp = inpbuf + (n-1)*sizeof(float);
421 +                return(*(float *)cp);
422 +        }
423          if (n <= MAXCOL && colflg & 1L<<(n-1))
424                  return(colval[n-1]);
425  
# Line 258 | Line 445 | int  n;
445   }
446  
447  
448 < chanset(n, v)                   /* output column n */
449 < int  n;
450 < double  v;
448 > void
449 > chanset(                   /* output column n */
450 > int  n,
451 > double  v
452 > )
453   {
454          if (colpos == 0)                /* no leading separator */
455                  colpos = 1;
# Line 272 | Line 461 | double  v;
461   }
462  
463  
464 < readfmt(spec, output)                   /* read record format */
465 < char  *spec;
466 < int  output;
464 > void
465 > bchanset(                   /* output binary channel n */
466 > int  n,
467 > double  v
468 > )
469   {
470 +        static char     zerobuf[sizeof(double)];
471 +        float   fval = v;
472 +
473 +        while (++colpos < n)
474 +                putbinary(zerobuf,
475 +                        tolower(otype)=='d' ? sizeof(double) : sizeof(float),
476 +                        1, stdout);
477 +        switch (otype) {
478 +        case 'D':
479 +                swap64((char *)&v, 1);
480 +                /* fall through */
481 +        case 'd':
482 +                putbinary(&v, sizeof(double), 1, stdout);
483 +                break;
484 +        case 'F':
485 +                swap32((char *)&fval, 1);
486 +                /* fall through */
487 +        case 'f':
488 +                putbinary(&fval, sizeof(float), 1, stdout);
489 +                break;
490 +        }
491 + }
492 +
493 +
494 + static void
495 + readfmt(                   /* read record format */
496 + char  *spec,
497 + int  output
498 + )
499 + {
500          int  fd;
501          char  *inptr;
502          struct field  fmt;
503          int  res;
504 <        register struct field  *f;
504 >        struct field  *f;
505                                                  /* check for inline format */
506          for (inptr = spec; *inptr; inptr++)
507                  if (*inptr == '$')
# Line 293 | Line 514 | int  output;
514                          eputs(": cannot open\n");
515                          quit(1);
516                  }
517 <                res = read(fd, inpbuf+1, INBSIZ-1);
517 >                res = read(fd, inpbuf+2, INBSIZ-2);
518                  if (res <= 0 || res >= INBSIZ-1) {
519                          eputs(spec);
520                          if (res < 0)
# Line 305 | Line 526 | int  output;
526                          quit(1);
527                  }
528                  close(fd);
529 <                (inptr=inpbuf+1)[res] = '\0';
529 >                (inptr=inpbuf+2)[res] = '\0';
530          }
531          f = &fmt;                               /* get fields */
532          while ((res = readfield(&inptr)) != F_NUL) {
# Line 338 | Line 559 | int  output;
559   }
560  
561  
562 < int
563 < readfield(pp)                   /* get next field in format */
564 < register char  **pp;
562 > static int
563 > readfield(                   /* get next field in format */
564 > char  **pp
565 > )
566   {
567          int  type = F_NUL;
568          int  width = 0;
569 <        register char  *cp;
569 >        char  *cp;
570          
571          cp = inpbuf;
572          while (cp < &inpbuf[INBSIZ-1] && **pp != '\0') {
# Line 405 | Line 627 | register char  **pp;
627  
628  
629   struct strvar *
630 < getsvar(svname)                         /* get string variable */
631 < char  *svname;
630 > getsvar(                         /* get string variable */
631 > char  *svname
632 > )
633   {
634 <        register struct strvar  *sv;
634 >        struct strvar  *sv;
635          
636          for (sv = svhead; sv != NULL; sv = sv->next)
637                  if (!strcmp(sv->name, svname))
# Line 422 | Line 645 | char  *svname;
645   }
646  
647  
648 < svpreset(eqn)                    /* preset a string variable */
649 < char  *eqn;
648 > static void
649 > svpreset(                    /* preset a string variable */
650 > char  *eqn
651 > )
652   {
653 <        register struct strvar  *sv;
654 <        register char  *val;
653 >        struct strvar  *sv;
654 >        char  *val;
655  
656          for (val = eqn; *val != '='; val++)
657                  if (!*val)
# Line 442 | Line 667 | char  *eqn;
667   }
668  
669  
670 < clearrec()                      /* clear input record variables */
670 > static void
671 > clearrec(void)                  /* clear input record variables */
672   {
673 <        register struct field  *f;
673 >        struct field  *f;
674  
675          for (f = inpfmt; f != NULL; f = f->next)
676                  switch (f->type & F_TYP) {
# Line 461 | Line 687 | clearrec()                     /* clear input record variables */
687   }
688  
689  
690 < getrec()                                /* get next record from file */
690 > static int
691 > getrec(void)                            /* get next record from file */
692   {
693          int  eatline;
694 <        register struct field  *f;
695 <        
694 >        struct field  *f;
695 >
696          while (ipb.chr != EOF) {
697 <                eatline = !igneol && ipb.chr != '\n';
471 <                if (blnkeq)             /* beware of nbsynch() */
697 >                if (blnkeq) {           /* beware of nbsynch() */
698                          while (isblnk(ipb.chr))
699 <                                scaninp();
699 >                                resetinp();
700 >                        if (ipb.chr == EOF)
701 >                                return(0);
702 >                }
703 >                eatline = (!igneol && ipb.chr != '\n');
704                  clearrec();             /* start with fresh record */
705                  for (f = inpfmt; f != NULL; f = f->next)
706                          if (getfield(f) == -1)
707                                  break;
708                  if (f == NULL) {
709 <                        advinp();
709 >                        advinp();       /* got one! */
710                          return(1);
711                  }
712 <                resetinp();
712 >                resetinp();             /* eat false start */
713                  if (eatline) {          /* eat rest of line */
714                          while (ipb.chr != '\n') {
715                                  if (ipb.chr == EOF)
716                                          return(0);
717 <                                scaninp();
717 >                                resetinp();
718                          }
719 <                        scaninp();
490 <                        advinp();
719 >                        resetinp();
720                  }
721          }
722          return(0);
723   }
724  
725  
726 < getfield(f)                             /* get next field */
727 < register struct field  *f;
726 > static int
727 > getfield(                             /* get next field */
728 > struct field  *f
729 > )
730   {
731 <        static char  buf[MAXWORD+1];            /* no recursion! */
731 >        static char  buf[RMAXWORD+1];            /* no recursion! */
732          int  delim, inword;
733          double  d;
734          char  *np;
735 <        register char  *cp;
735 >        char  *cp;
736  
737          switch (f->type & F_TYP) {
738          case T_LIT:
# Line 530 | Line 761 | register struct field  *f;
761                          delim = f->next->f.sl[0];
762                  cp = buf;
763                  do {
764 <                        if (ipb.chr == EOF)
764 >                        if (ipb.chr == EOF || ipb.chr == '\n')
765                                  inword = 0;
766                          else if (blnkeq && delim != EOF)
767                                  inword = isblnk(delim) ?
# Line 542 | Line 773 | register struct field  *f;
773                                  *cp++ = ipb.chr;
774                                  scaninp();
775                          }
776 <                } while (inword && cp < &buf[MAXWORD]);
776 >                } while (inword && cp < &buf[RMAXWORD]);
777                  *cp = '\0';
778                  if (f->f.sv->val == NULL)
779                          f->f.sv->val = savqstr(buf);    /* first setting */
# Line 571 | Line 802 | register struct field  *f;
802                                  *cp++ = ipb.chr;
803                                  scaninp();
804                          }
805 <                } while (inword && cp < &buf[MAXWORD]);
805 >                } while (inword && cp < &buf[RMAXWORD]);
806                  *cp = '\0';
807                  d = np==NULL ? 0. : atof(np);
808                  if (!vardefined(f->f.nv))
# Line 581 | Line 812 | register struct field  *f;
812                          return(-1);                     /* doesn't match! */
813                  return(0);
814          }
815 +        return -1; /* pro forma return */
816   }
817  
818  
819 < putrec()                                /* output a record */
819 > static void
820 > putrec(void)                                /* output a record */
821   {
822 <        char  fmt[32];
823 <        register int  n;
824 <        register struct field  *f;
822 >        char  fmt[32], typ[16];
823 >        int  n;
824 >        struct field  *f;
825          int  adlast, adnext;
826 +        double  dv, av;
827          
828          adlast = 0;
829          for (f = outfmt; f != NULL; f = f->next) {
# Line 620 | Line 854 | putrec()                                /* output a re
854                          break;
855                  case T_NUM:
856                          n = f->type & F_WID;
857 +                        dv = evalue(f->f.ne);
858 +                        av = fabs(dv);
859 +                        if (n <= 9)
860 +                                strcpy(typ, "g");
861 +                        else
862 +                                sprintf(typ, ".%de", n-5);
863 +                        if (av < 1L<<31) {
864 +                                long    iv = (int)(av + .5);
865 +                                if (iv && fabs(av-iv) <= av*1e-14)
866 +                                        strcpy(typ, ".0f");
867 +                        }
868                          if (adlast && adnext)
869 <                                strcpy(fmt, "%g");
869 >                                sprintf(fmt, "%%%s", typ);
870                          else if (adlast)
871 <                                sprintf(fmt, "%%-%dg", n);
871 >                                sprintf(fmt, "%%-%d%s", n, typ);
872                          else
873 <                                sprintf(fmt, "%%%dg", n);
874 <                        printf(fmt, evalue(f->f.ne));
873 >                                sprintf(fmt, "%%%d%s", n, typ);
874 >                        printf(fmt, dv);
875                          adlast = 1;
876                          break;
877                  }
# Line 634 | Line 879 | putrec()                                /* output a re
879   }
880  
881  
882 < initinp(fp)                     /* prepare lookahead buffer */
883 < FILE  *fp;
882 > static void
883 > initinp(FILE  *fp)                     /* prepare lookahead buffer */
884 >
885   {
886          ipb.fin = fp;
887          ipb.beg = ipb.end = inpbuf;
# Line 645 | Line 891 | FILE  *fp;
891   }
892  
893  
894 < scaninp()                       /* scan next character */
894 > static void
895 > scaninp(void)                       /* scan next character */
896   {
897          if (ipb.chr == EOF)
898                  return;
# Line 664 | Line 911 | scaninp()                       /* scan next character
911   }
912  
913  
914 < advinp()                        /* move home to current position */
914 > static void
915 > advinp(void)                        /* move home to current position */
916   {
917          ipb.beg = ipb.pos;
918   }
919  
920  
921 < resetinp()                      /* rewind position and advance 1 */
921 > static void
922 > resetinp(void)                      /* rewind position and advance 1 */
923   {
924          if (ipb.beg == NULL)            /* full */
925                  ipb.beg = ipb.end;
926          ipb.pos = ipb.beg;
927          ipb.chr = *ipb.pos;
928 +        if (passive)                    /* transmit unmatched character? */
929 +                fputc(ipb.chr, stdout);
930          if (++ipb.beg >= &inpbuf[INBSIZ])
931                  ipb.beg = inpbuf;
932          scaninp();
# Line 683 | Line 934 | resetinp()                      /* rewind position and
934  
935  
936   void
937 < eputs(msg)
687 < char  *msg;
937 > eputs(char  *msg)
938   {
939          fputs(msg, stderr);
940   }
941  
942  
943   void
944 < wputs(msg)
695 < char  *msg;
944 > wputs(char  *msg)
945   {
946          if (!nowarn)
947                  eputs(msg);
# Line 700 | Line 949 | char  *msg;
949  
950  
951   void
952 < quit(code)
704 < int  code;
952 > quit(int  code)
953   {
954          exit(code);
955   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines