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

Diff for /src/usr.bin/awk/b.c between version 1.28 and 1.29

version 1.28, 2020/06/10 21:03:36 version 1.29, 2020/06/10 21:03:56
Line 149 
Line 149 
         overflo(__func__);          overflo(__func__);
 }  }
   
 fa *makedfa(const char *s, int anchor)  /* returns dfa for reg expr s */  fa *makedfa(const char *s, bool anchor) /* returns dfa for reg expr s */
 {  {
         int i, use, nuse;          int i, use, nuse;
         fa *pfa;          fa *pfa;
Line 159 
Line 159 
                 allocsetvec(__func__);                  allocsetvec(__func__);
         }          }
   
         if (compile_time)       /* a constant for sure */          if (compile_time != RUNNING)    /* a constant for sure */
                 return mkdfa(s, anchor);                  return mkdfa(s, anchor);
         for (i = 0; i < nfatab; i++)    /* is it there already? */          for (i = 0; i < nfatab; i++)    /* is it there already? */
                 if (fatab[i]->anchor == anchor                  if (fatab[i]->anchor == anchor
Line 187 
Line 187 
         return pfa;          return pfa;
 }  }
   
 fa *mkdfa(const char *s, int anchor)    /* does the real work of making a dfa */  fa *mkdfa(const char *s, bool anchor)   /* does the real work of making a dfa */
                                 /* anchor = 1 for anchored matches, else 0 */                                  /* anchor = 1 for anchored matches, else 0 */
 {  {
         Node *p, *p1;          Node *p, *p1;
Line 222 
Line 222 
         return f;          return f;
 }  }
   
 int makeinit(fa *f, int anchor)  int makeinit(fa *f, bool anchor)
 {  {
         int i, k;          int i, k;
   
Line 653 
Line 653 
  *     a match is found, patbeg and patlen are set appropriately.   *     a match is found, patbeg and patlen are set appropriately.
  *   *
  * RETURN VALUES   * RETURN VALUES
  *     0    No match found.   *     false    No match found.
  *     1    Match found.   *     true     Match found.
  */   */
   
 int fnematch(fa *pfa, FILE *f, char **pbuf, int *pbufsize, int quantum)  bool fnematch(fa *pfa, FILE *f, char **pbuf, int *pbufsize, int quantum)
 {  {
         char *buf = *pbuf;          char *buf = *pbuf;
         int bufsize = *pbufsize;          int bufsize = *pbufsize;
Line 723 
Line 723 
                                 FATAL("unable to ungetc '%c'", buf[k]);                                  FATAL("unable to ungetc '%c'", buf[k]);
                 while (k > i + patlen);                  while (k > i + patlen);
                 buf[k] = 0;                  buf[k] = 0;
                 return 1;                  return true;
         }          }
         else          else
                 return 0;                  return false;
 }  }
   
 Node *reparse(const char *p)    /* parses regular expression pointed to by p */  Node *reparse(const char *p)    /* parses regular expression pointed to by p */
Line 915 
Line 915 
         int i, j;          int i, j;
         uschar *buf = NULL;          uschar *buf = NULL;
         int ret = 1;          int ret = 1;
         int init_q = (firstnum==0);             /* first added char will be ? */          int init_q = (firstnum == 0);           /* first added char will be ? */
         int n_q_reps = secondnum-firstnum;      /* m>n, so reduce until {1,m-n} left  */          int n_q_reps = secondnum-firstnum;      /* m>n, so reduce until {1,m-n} left  */
         int prefix_length = reptok - basestr;   /* prefix includes first rep    */          int prefix_length = reptok - basestr;   /* prefix includes first rep    */
         int suffix_length = strlen((const char *) reptok) - reptoklen;  /* string after rep specifier   */          int suffix_length = strlen((const char *) reptok) - reptoklen;  /* string after rep specifier   */
Line 949 
Line 949 
         if (special_case == REPEAT_PLUS_APPENDED) {          if (special_case == REPEAT_PLUS_APPENDED) {
                 buf[j++] = '+';                  buf[j++] = '+';
         } else if (special_case == REPEAT_WITH_Q) {          } else if (special_case == REPEAT_WITH_Q) {
                 if (init_q) buf[j++] = '?';                  if (init_q)
                 for (i=0; i < n_q_reps; i++) {  /* copy x? reps */                          buf[j++] = '?';
                   for (i = 0; i < n_q_reps; i++) {        /* copy x? reps */
                         memcpy(&buf[j], atom, atomlen);                          memcpy(&buf[j], atom, atomlen);
                         j += atomlen;                          j += atomlen;
                         buf[j++] = '?';                          buf[j++] = '?';
Line 1024 
Line 1025 
         uschar *bp;          uschar *bp;
         struct charclass *cc;          struct charclass *cc;
         int i;          int i;
         int num, m, commafound, digitfound;          int num, m;
           bool commafound, digitfound;
         const uschar *startreptok;          const uschar *startreptok;
         static int parens = 0;          static int parens = 0;
   
Line 1158 
Line 1160 
                 if (isdigit(*(prestr))) {                  if (isdigit(*(prestr))) {
                         num = 0;        /* Process as a repetition */                          num = 0;        /* Process as a repetition */
                         n = -1; m = -1;                          n = -1; m = -1;
                         commafound = 0;                          commafound = false;
                         digitfound = 0;                          digitfound = false;
                         startreptok = prestr-1;                          startreptok = prestr-1;
                         /* Remember start of previous atom here ? */                          /* Remember start of previous atom here ? */
                 } else {                /* just a { char, not a repetition */                  } else {                /* just a { char, not a repetition */
Line 1206 
Line 1208 
                                         lastre);                                          lastre);
                         } else if (isdigit(c)) {                          } else if (isdigit(c)) {
                                 num = 10 * num + c - '0';                                  num = 10 * num + c - '0';
                                 digitfound = 1;                                  digitfound = true;
                         } else if (c == ',') {                          } else if (c == ',') {
                                 if (commafound)                                  if (commafound)
                                         FATAL("illegal repetition expression: class %.20s",                                          FATAL("illegal repetition expression: class %.20s",
                                                 lastre);                                                  lastre);
                                 /* looking for {n,} or {n,m} */                                  /* looking for {n,} or {n,m} */
                                 commafound = 1;                                  commafound = true;
                                 n = num;                                  n = num;
                                 digitfound = 0; /* reset */                                  digitfound = false; /* reset */
                                 num = 0;                                  num = 0;
                         } else {                          } else {
                                 FATAL("illegal repetition expression: class %.20s",                                  FATAL("illegal repetition expression: class %.20s",

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29