[BACK]Return to lib.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / awk

Diff for /src/usr.bin/awk/lib.c between version 1.33 and 1.34

version 1.33, 2020/06/10 21:05:02 version 1.34, 2020/06/10 21:05:50
Line 29 
Line 29 
 #include <ctype.h>  #include <ctype.h>
 #include <errno.h>  #include <errno.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <unistd.h>  
 #include <stdarg.h>  #include <stdarg.h>
 #include <limits.h>  #include <limits.h>
 #include "awk.h"  #include "awk.h"
Line 37 
Line 36 
   
 char    EMPTY[] = { '\0' };  char    EMPTY[] = { '\0' };
 FILE    *infile = NULL;  FILE    *infile = NULL;
   bool    innew;          /* true = infile has not been read by readrec */
 char    *file   = EMPTY;  char    *file   = EMPTY;
 char    *record;  char    *record;
 int     recsize = RECSIZE;  int     recsize = RECSIZE;
Line 57 
Line 57 
 int     argno   = 1;    /* current input argument number */  int     argno   = 1;    /* current input argument number */
 extern  Awkfloat *ARGC;  extern  Awkfloat *ARGC;
   
 static Cell dollar0 = { OCELL, CFLD, NULL, EMPTY, 0.0, REC|STR|DONTFREE };  static Cell dollar0 = { OCELL, CFLD, NULL, EMPTY, 0.0, REC|STR|DONTFREE, NULL, NULL };
 static Cell dollar1 = { OCELL, CFLD, NULL, EMPTY, 0.0, FLD|STR|DONTFREE };  static Cell dollar1 = { OCELL, CFLD, NULL, EMPTY, 0.0, FLD|STR|DONTFREE, NULL, NULL };
   
 void recinit(unsigned int n)  void recinit(unsigned int n)
 {  {
Line 108 
Line 108 
                 argno++;                  argno++;
         }          }
         infile = stdin;         /* no filenames, so use stdin */          infile = stdin;         /* no filenames, so use stdin */
           innew = true;
 }  }
   
 /*  /*
Line 177 
Line 178 
                                 FATAL("can't open file %s", file);                                  FATAL("can't open file %s", file);
                         setfval(fnrloc, 0.0);                          setfval(fnrloc, 0.0);
                 }                  }
                 c = readrec(&buf, &bufsize, infile);                  c = readrec(&buf, &bufsize, infile, innew);
                   if (innew)
                           innew = false;
                 if (c != 0 || buf[0] != '\0') { /* normal record */                  if (c != 0 || buf[0] != '\0') { /* normal record */
                         if (isrecord) {                          if (isrecord) {
                                 if (freeable(fldtab[0]))                                  if (freeable(fldtab[0]))
Line 215 
Line 218 
         argno++;          argno++;
 }  }
   
 int readrec(char **pbuf, int *pbufsize, FILE *inf)      /* read one record into buf */  int readrec(char **pbuf, int *pbufsize, FILE *inf, bool newflag)        /* read one record into buf */
 {  {
         int sep, c, isrec;          int sep, c, isrec;
         char *rr, *buf = *pbuf;          char *rr, *buf = *pbuf;
Line 226 
Line 229 
                 bool found;                  bool found;
   
                 fa *pfa = makedfa(rs, 1);                  fa *pfa = makedfa(rs, 1);
                 found = fnematch(pfa, inf, &buf, &bufsize, recsize);                  if (newflag)
                           found = fnematch(pfa, inf, &buf, &bufsize, recsize);
                   else {
                           int tempstat = pfa->initstat;
                           pfa->initstat = 2;
                           found = fnematch(pfa, inf, &buf, &bufsize, recsize);
                           pfa->initstat = tempstat;
                   }
                 if (found)                  if (found)
                         setptr(patbeg, '\0');                          setptr(patbeg, '\0');
         } else {          } else {
Line 463 
Line 473 
         if (n > nf)          if (n > nf)
                 nf = n;                  nf = n;
         s = (nf+1) * (sizeof (struct Cell *));  /* freebsd: how much do we need? */          s = (nf+1) * (sizeof (struct Cell *));  /* freebsd: how much do we need? */
         if (s / sizeof(struct Cell *) - 1 == nf) /* didn't overflow */          if (s / sizeof(struct Cell *) - 1 == (size_t)nf) /* didn't overflow */
                 fldtab = realloc(fldtab, s);                  fldtab = realloc(fldtab, s);
         else                                    /* overflow sizeof int */          else                                    /* overflow sizeof int */
                 xfree(fldtab);  /* make it null */                  xfree(fldtab);  /* make it null */
Line 584 
Line 594 
         fprintf(stderr, "\n");          fprintf(stderr, "\n");
         errorflag = 2;          errorflag = 2;
         eprint();          eprint();
 }  
   
 void fpecatch(int sig)  
 {  
         extern Node *curnode;  
   
         dprintf(STDERR_FILENO, "floating point exception\n");  
   
         if (compile_time != 2 && NR && *NR > 0) {  
                 dprintf(STDERR_FILENO, " input record number %d", (int) (*FNR));  
                 if (strcmp(*FILENAME, "-") != 0) {  
                         dprintf(STDERR_FILENO, ", file %s", *FILENAME);  
                 }  
                 dprintf(STDERR_FILENO, "\n");  
         }  
         if (compile_time != 2 && curnode) {  
                 dprintf(STDERR_FILENO, " source line number %d", curnode->lineno);  
         } else if (compile_time != 2 && lineno) {  
                 dprintf(STDERR_FILENO, " source line number %d", lineno);  
         }  
         if (compile_time == 1 && cursource() != NULL) {  
                 dprintf(STDERR_FILENO, " source file %s", cursource());  
         }  
         dprintf(STDERR_FILENO, "\n");  
         if (dbg > 1)            /* core dump if serious debugging on */  
                 abort();  
         _exit(1);  
 }  }
   
 extern int bracecnt, brackcnt, parencnt;  extern int bracecnt, brackcnt, parencnt;

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34