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.4 by greg, Sun May 25 05:27:16 2003 UTC vs.
Revision 1.27 by greg, Thu Aug 18 00:52:47 2016 UTC

# 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  bocols = 0;                /* produce binary output 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 88 | 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;
# Line 101 | Line 117 | char  *argv[];
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 110 | 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 117 | 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 128 | Line 156 | char  *argv[];
156                  case 'i':
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);
187 >                                        nbicols = atoi(argv[i]+3);
188                                  else
189 <                                        nbicols = -1;
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;
# Line 153 | Line 200 | char  *argv[];
200                  case 'o':
201                          switch (argv[i][2]) {
202                          case '\0':
203 <                                bocols = 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 <                                bocols = 0;
210 >                                otype = 'a';
211                                  break;
212                          case 'd':
213 <                                bocols = 1;
164 <                                break;
213 >                        case 'D':
214                          case 'f':
215 <                                bocols = -1;
215 >                        case 'F':
216 >                                otype = argv[i][2];
217                                  break;
218 +                        default:
219 +                                goto userr;
220                          }
221                          break;
222                  case 'w':
# Line 177 | Line 229 | char  *argv[];
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          }
189
250          if (blnkeq)             /* for efficiency */
251                  nbsynch();
252  
# Line 197 | 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 211 | Line 273 | nbsynch()               /* non-blank starting synch ch
273   }
274  
275  
276 < int
277 < getinputrec(fp)         /* get next input record */
278 < FILE  *fp;
276 > static int
277 > getinputrec(            /* get next input record */
278 > FILE  *fp
279 > )
280   {
281          if (inpfmt != NULL)
282                  return(getrec());
283 <        if (nbicols > 0)
284 <                return(fread(inpbuf, sizeof(double),
285 <                                        nbicols, fp) == nbicols);
286 <        if (nbicols < 0)
287 <                return(fread(inpbuf, sizeof(float),
288 <                                        -nbicols, fp) == -nbicols);
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 < execute(file)           /* process a file */
302 < char  *file;
301 > static void
302 > execute(           /* process a file */
303 > char  *file
304 > )
305   {
306          int  conditional = vardefined("cond");
307          long  nrecs = 0;
# Line 242 | Line 315 | char  *file;
315                  eputs(": cannot open\n");
316                  quit(1);
317          }
318 +        if (itype != 'a')
319 +                SET_FILE_BINARY(fp);
320 + #ifdef getc_unlocked            /* avoid lock/unlock overhead */
321 +        flockfile(fp);
322 + #endif
323          if (inpfmt != NULL)
324                  initinp(fp);
325          
326          while (getinputrec(fp)) {
327                  varset("recno", '=', (double)++nrecs);
328 +                varset("outno", '=', (double)(nout+1));
329                  colflg = 0;
330                  eclock++;
331                  if (!conditional || varvalue("cond") > 0.0) {
253                        varset("outno", '=', (double)++nout);
332                          putout();
333 +                        ++nout;
334                  }
335 +                if (incnt && nrecs >= incnt)
336 +                        break;
337 +                if (outcnt && nout >= outcnt)
338 +                        break;
339          }
340          fclose(fp);
341   }
342  
343  
344 < putout()                /* produce an output record */
344 > static void
345 > putout(void)                /* produce an output record */
346   {
263        extern void  chanset(), bchanset();
347  
348          colpos = 0;
349          if (outfmt != NULL)
350                  putrec();
351 <        else if (bocols)
269 <                chanout(bchanset);
270 <        else
351 >        else if (otype == 'a')
352                  chanout(chanset);
353 <        if (colpos && !bocols)
353 >        else
354 >                chanout(bchanset);
355 >        if (colpos && otype == 'a')
356                  putchar('\n');
357          if (unbuff)
358                  fflush(stdout);
359   }
360  
361  
362 + static double
363 + l_in(char *funame)      /* function call for $channel */
364 + {
365 +        int  n;
366 +        char  *cp;
367 +                        /* get argument as integer */
368 +        n = (int)(argument(1) + .5);
369 +        if (n != 0)     /* return channel value */
370 +                return(chanvalue(n));
371 +                        /* determine number of channels */
372 +        if (noinput || inpfmt != NULL)
373 +                return(0);
374 +        if (nbicols)
375 +                return(nbicols);
376 +        cp = inpbuf;    /* need to count */
377 +        for (n = 0; *cp; )
378 +                if (blnkeq && isspace(sepchar)) {
379 +                        while (isspace(*cp))
380 +                                cp++;
381 +                        n += *cp != '\0';
382 +                        while (*cp && !isspace(*cp))
383 +                                cp++;
384 +                } else {
385 +                        n += *cp != '\n';
386 +                        while (*cp && *cp++ != sepchar)
387 +                                ;
388 +                }
389 +        return(n);
390 + }
391 +
392   double
393 < chanvalue(n)            /* return value for column n */
394 < int  n;
393 > chanvalue(            /* return value for column n */
394 > int  n
395 > )
396   {
397          int  i;
398 <        register char  *cp;
398 >        char  *cp;
399  
400          if (noinput || inpfmt != NULL) {
401                  eputs("no column input\n");
# Line 291 | Line 405 | int  n;
405                  eputs("illegal channel number\n");
406                  quit(1);
407          }
408 <        if (nbicols > 0) {
408 >        if (nbicols) {
409                  if (n > nbicols)
410                          return(0.0);
411 <                cp = inpbuf + (n-1)*sizeof(double);
412 <                return(*(double *)cp);
413 <        }
414 <        if (nbicols < 0) {
301 <                if (n > -nbicols)
302 <                        return(0.0);
411 >                if (tolower(itype) == 'd') {
412 >                        cp = inpbuf + (n-1)*sizeof(double);
413 >                        return(*(double *)cp);
414 >                }
415                  cp = inpbuf + (n-1)*sizeof(float);
416                  return(*(float *)cp);
417          }
# Line 329 | Line 441 | int  n;
441  
442  
443   void
444 < chanset(n, v)                   /* output column n */
445 < int  n;
446 < double  v;
444 > chanset(                   /* output column n */
445 > int  n,
446 > double  v
447 > )
448   {
449          if (colpos == 0)                /* no leading separator */
450                  colpos = 1;
# Line 344 | Line 457 | double  v;
457  
458  
459   void
460 < bchanset(n, v)                   /* output binary channel n */
461 < int  n;
462 < double  v;
460 > bchanset(                   /* output binary channel n */
461 > int  n,
462 > double  v
463 > )
464   {
465          static char     zerobuf[sizeof(double)];
466 +        float   fval = v;
467  
468          while (++colpos < n)
469 <                fwrite(zerobuf,
470 <                        bocols>0 ? sizeof(double) : sizeof(float),
469 >                putbinary(zerobuf,
470 >                        tolower(otype)=='d' ? sizeof(double) : sizeof(float),
471                          1, stdout);
472 <        if (bocols > 0)
473 <                fwrite(&v, sizeof(double), 1, stdout);
474 <        else {
475 <                float   fval = v;
476 <                fwrite(&fval, sizeof(float), 1, stdout);
472 >        switch (otype) {
473 >        case 'D':
474 >                swap64((char *)&v, 1);
475 >                /* fall through */
476 >        case 'd':
477 >                putbinary(&v, sizeof(double), 1, stdout);
478 >                break;
479 >        case 'F':
480 >                swap32((char *)&fval, 1);
481 >                /* fall through */
482 >        case 'f':
483 >                putbinary(&fval, sizeof(float), 1, stdout);
484 >                break;
485          }
486   }
487  
488  
489 < readfmt(spec, output)                   /* read record format */
490 < char  *spec;
491 < int  output;
489 > static void
490 > readfmt(                   /* read record format */
491 > char  *spec,
492 > int  output
493 > )
494   {
495          int  fd;
496          char  *inptr;
497          struct field  fmt;
498          int  res;
499 <        register struct field  *f;
499 >        struct field  *f;
500                                                  /* check for inline format */
501          for (inptr = spec; *inptr; inptr++)
502                  if (*inptr == '$')
# Line 384 | Line 509 | int  output;
509                          eputs(": cannot open\n");
510                          quit(1);
511                  }
512 <                res = read(fd, inpbuf+1, INBSIZ-1);
512 >                res = read(fd, inpbuf+2, INBSIZ-2);
513                  if (res <= 0 || res >= INBSIZ-1) {
514                          eputs(spec);
515                          if (res < 0)
# Line 396 | Line 521 | int  output;
521                          quit(1);
522                  }
523                  close(fd);
524 <                (inptr=inpbuf+1)[res] = '\0';
524 >                (inptr=inpbuf+2)[res] = '\0';
525          }
526          f = &fmt;                               /* get fields */
527          while ((res = readfield(&inptr)) != F_NUL) {
# Line 429 | Line 554 | int  output;
554   }
555  
556  
557 < int
558 < readfield(pp)                   /* get next field in format */
559 < register char  **pp;
557 > static int
558 > readfield(                   /* get next field in format */
559 > char  **pp
560 > )
561   {
562          int  type = F_NUL;
563          int  width = 0;
564 <        register char  *cp;
564 >        char  *cp;
565          
566          cp = inpbuf;
567          while (cp < &inpbuf[INBSIZ-1] && **pp != '\0') {
# Line 496 | Line 622 | register char  **pp;
622  
623  
624   struct strvar *
625 < getsvar(svname)                         /* get string variable */
626 < char  *svname;
625 > getsvar(                         /* get string variable */
626 > char  *svname
627 > )
628   {
629 <        register struct strvar  *sv;
629 >        struct strvar  *sv;
630          
631          for (sv = svhead; sv != NULL; sv = sv->next)
632                  if (!strcmp(sv->name, svname))
# Line 513 | Line 640 | char  *svname;
640   }
641  
642  
643 < svpreset(eqn)                    /* preset a string variable */
644 < char  *eqn;
643 > static void
644 > svpreset(                    /* preset a string variable */
645 > char  *eqn
646 > )
647   {
648 <        register struct strvar  *sv;
649 <        register char  *val;
648 >        struct strvar  *sv;
649 >        char  *val;
650  
651          for (val = eqn; *val != '='; val++)
652                  if (!*val)
# Line 533 | Line 662 | char  *eqn;
662   }
663  
664  
665 < clearrec()                      /* clear input record variables */
665 > static void
666 > clearrec(void)                  /* clear input record variables */
667   {
668 <        register struct field  *f;
668 >        struct field  *f;
669  
670          for (f = inpfmt; f != NULL; f = f->next)
671                  switch (f->type & F_TYP) {
# Line 552 | Line 682 | clearrec()                     /* clear input record variables */
682   }
683  
684  
685 < getrec()                                /* get next record from file */
685 > static int
686 > getrec(void)                            /* get next record from file */
687   {
688          int  eatline;
689 <        register struct field  *f;
690 <        
689 >        struct field  *f;
690 >
691          while (ipb.chr != EOF) {
692 <                eatline = !igneol && ipb.chr != '\n';
562 <                if (blnkeq)             /* beware of nbsynch() */
692 >                if (blnkeq) {           /* beware of nbsynch() */
693                          while (isblnk(ipb.chr))
694 <                                scaninp();
694 >                                resetinp();
695 >                        if (ipb.chr == EOF)
696 >                                return(0);
697 >                }
698 >                eatline = (!igneol && ipb.chr != '\n');
699                  clearrec();             /* start with fresh record */
700                  for (f = inpfmt; f != NULL; f = f->next)
701                          if (getfield(f) == -1)
702                                  break;
703                  if (f == NULL) {
704 <                        advinp();
704 >                        advinp();       /* got one! */
705                          return(1);
706                  }
707 <                resetinp();
707 >                resetinp();             /* eat false start */
708                  if (eatline) {          /* eat rest of line */
709                          while (ipb.chr != '\n') {
710                                  if (ipb.chr == EOF)
711                                          return(0);
712 <                                scaninp();
712 >                                resetinp();
713                          }
714 <                        scaninp();
581 <                        advinp();
714 >                        resetinp();
715                  }
716          }
717          return(0);
718   }
719  
720  
721 < getfield(f)                             /* get next field */
722 < register struct field  *f;
721 > static int
722 > getfield(                             /* get next field */
723 > struct field  *f
724 > )
725   {
726 <        static char  buf[MAXWORD+1];            /* no recursion! */
726 >        static char  buf[RMAXWORD+1];            /* no recursion! */
727          int  delim, inword;
728          double  d;
729          char  *np;
730 <        register char  *cp;
730 >        char  *cp;
731  
732          switch (f->type & F_TYP) {
733          case T_LIT:
# Line 621 | Line 756 | register struct field  *f;
756                          delim = f->next->f.sl[0];
757                  cp = buf;
758                  do {
759 <                        if (ipb.chr == EOF)
759 >                        if (ipb.chr == EOF || ipb.chr == '\n')
760                                  inword = 0;
761                          else if (blnkeq && delim != EOF)
762                                  inword = isblnk(delim) ?
# Line 633 | Line 768 | register struct field  *f;
768                                  *cp++ = ipb.chr;
769                                  scaninp();
770                          }
771 <                } while (inword && cp < &buf[MAXWORD]);
771 >                } while (inword && cp < &buf[RMAXWORD]);
772                  *cp = '\0';
773                  if (f->f.sv->val == NULL)
774                          f->f.sv->val = savqstr(buf);    /* first setting */
# Line 662 | Line 797 | register struct field  *f;
797                                  *cp++ = ipb.chr;
798                                  scaninp();
799                          }
800 <                } while (inword && cp < &buf[MAXWORD]);
800 >                } while (inword && cp < &buf[RMAXWORD]);
801                  *cp = '\0';
802                  d = np==NULL ? 0. : atof(np);
803                  if (!vardefined(f->f.nv))
# Line 672 | Line 807 | register struct field  *f;
807                          return(-1);                     /* doesn't match! */
808                  return(0);
809          }
810 +        return -1; /* pro forma return */
811   }
812  
813  
814 < putrec()                                /* output a record */
814 > static void
815 > putrec(void)                                /* output a record */
816   {
817 <        char  fmt[32];
818 <        register int  n;
819 <        register struct field  *f;
817 >        char  fmt[32], typ[16];
818 >        int  n;
819 >        struct field  *f;
820          int  adlast, adnext;
821 +        double  dv, av;
822          
823          adlast = 0;
824          for (f = outfmt; f != NULL; f = f->next) {
# Line 711 | Line 849 | putrec()                                /* output a re
849                          break;
850                  case T_NUM:
851                          n = f->type & F_WID;
852 +                        dv = evalue(f->f.ne);
853 +                        av = fabs(dv);
854 +                        if (n <= 9)
855 +                                strcpy(typ, "g");
856 +                        else
857 +                                sprintf(typ, ".%de", n-5);
858 +                        if (av < 1L<<31) {
859 +                                long    iv = (int)(av + .5);
860 +                                if (iv && fabs(av-iv) <= av*1e-14)
861 +                                        strcpy(typ, ".0f");
862 +                        }
863                          if (adlast && adnext)
864 <                                strcpy(fmt, "%g");
864 >                                sprintf(fmt, "%%%s", typ);
865                          else if (adlast)
866 <                                sprintf(fmt, "%%-%dg", n);
866 >                                sprintf(fmt, "%%-%d%s", n, typ);
867                          else
868 <                                sprintf(fmt, "%%%dg", n);
869 <                        printf(fmt, evalue(f->f.ne));
868 >                                sprintf(fmt, "%%%d%s", n, typ);
869 >                        printf(fmt, dv);
870                          adlast = 1;
871                          break;
872                  }
# Line 725 | Line 874 | putrec()                                /* output a re
874   }
875  
876  
877 < initinp(fp)                     /* prepare lookahead buffer */
878 < FILE  *fp;
877 > static void
878 > initinp(FILE  *fp)                     /* prepare lookahead buffer */
879 >
880   {
881          ipb.fin = fp;
882          ipb.beg = ipb.end = inpbuf;
# Line 736 | Line 886 | FILE  *fp;
886   }
887  
888  
889 < scaninp()                       /* scan next character */
889 > static void
890 > scaninp(void)                       /* scan next character */
891   {
892          if (ipb.chr == EOF)
893                  return;
# Line 755 | Line 906 | scaninp()                       /* scan next character
906   }
907  
908  
909 < advinp()                        /* move home to current position */
909 > static void
910 > advinp(void)                        /* move home to current position */
911   {
912          ipb.beg = ipb.pos;
913   }
914  
915  
916 < resetinp()                      /* rewind position and advance 1 */
916 > static void
917 > resetinp(void)                      /* rewind position and advance 1 */
918   {
919          if (ipb.beg == NULL)            /* full */
920                  ipb.beg = ipb.end;
921          ipb.pos = ipb.beg;
922          ipb.chr = *ipb.pos;
923 +        if (passive)                    /* transmit unmatched character? */
924 +                fputc(ipb.chr, stdout);
925          if (++ipb.beg >= &inpbuf[INBSIZ])
926                  ipb.beg = inpbuf;
927          scaninp();
# Line 774 | Line 929 | resetinp()                      /* rewind position and
929  
930  
931   void
932 < eputs(msg)
778 < char  *msg;
932 > eputs(char  *msg)
933   {
934          fputs(msg, stderr);
935   }
936  
937  
938   void
939 < wputs(msg)
786 < char  *msg;
939 > wputs(char  *msg)
940   {
941          if (!nowarn)
942                  eputs(msg);
# Line 791 | Line 944 | char  *msg;
944  
945  
946   void
947 < quit(code)
795 < int  code;
947 > quit(int  code)
948   {
949          exit(code);
950   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines