[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.49 and 1.50

version 1.49, 2023/11/25 16:31:33 version 1.50, 2024/01/25 16:40:51
Line 117 
Line 117 
 static int get_gototab(fa*, int, int);  static int get_gototab(fa*, int, int);
 static int set_gototab(fa*, int, int, int);  static int set_gototab(fa*, int, int, int);
 static void clear_gototab(fa*, int);  static void clear_gototab(fa*, int);
 extern int u8_rune(int *, const uschar *);  extern int u8_rune(int *, const char *);
   
 static int *  static int *
 intalloc(size_t n, const char *f)  intalloc(size_t n, const char *f)
Line 422 
Line 422 
                 FATAL("out of space for character class [%.10s...] 1", p);                  FATAL("out of space for character class [%.10s...] 1", p);
         bp = buf;          bp = buf;
         for (i = 0; *p != 0; ) {          for (i = 0; *p != 0; ) {
                 n = u8_rune(&c, p);                  n = u8_rune(&c, (const char *) p);
                 p += n;                  p += n;
                 if (c == '\\') {                  if (c == '\\') {
                         c = quoted(&p);                          c = quoted(&p);
Line 430 
Line 430 
                         if (*p != 0) {                          if (*p != 0) {
                                 c = bp[-1];                                  c = bp[-1];
                                 /* c2 = *p++; */                                  /* c2 = *p++; */
                                 n = u8_rune(&c2, p);                                  n = u8_rune(&c2, (const char *) p);
                                 p += n;                                  p += n;
                                 if (c2 == '\\')                                  if (c2 == '\\')
                                         c2 = quoted(&p); /* BUG: sets p, has to be u8 size */                                          c2 = quoted(&p); /* BUG: sets p, has to be u8 size */
Line 624 
Line 624 
   
         key.ch = ch;          key.ch = ch;
         key.state = 0;  /* irrelevant */          key.state = 0;  /* irrelevant */
         item = bsearch(& key, f->gototab[state].entries,          item = (gtte *) bsearch(& key, f->gototab[state].entries,
                         f->gototab[state].inuse, sizeof(gtte),                          f->gototab[state].inuse, sizeof(gtte),
                         entry_cmp);                          entry_cmp);
   
Line 668 
Line 668 
   
                 key.ch = ch;                  key.ch = ch;
                 key.state = 0;  /* irrelevant */                  key.state = 0;  /* irrelevant */
                 item = bsearch(& key, f->gototab[state].entries,                  item = (gtte *) bsearch(& key, f->gototab[state].entries,
                                 f->gototab[state].inuse, sizeof(gtte),                                  f->gototab[state].inuse, sizeof(gtte),
                                 entry_cmp);                                  entry_cmp);
   
Line 716 
Line 716 
                 return(1);                  return(1);
         do {          do {
                 /* assert(*p < NCHARS); */                  /* assert(*p < NCHARS); */
                 n = u8_rune(&rune, p);                  n = u8_rune(&rune, (const char *) p);
                 if ((ns = get_gototab(f, s, rune)) != 0)                  if ((ns = get_gototab(f, s, rune)) != 0)
                         s = ns;                          s = ns;
                 else                  else
Line 749 
Line 749 
                         if (f->out[s])          /* final state */                          if (f->out[s])          /* final state */
                                 patlen = q-p;                                  patlen = q-p;
                         /* assert(*q < NCHARS); */                          /* assert(*q < NCHARS); */
                         n = u8_rune(&rune, q);                          n = u8_rune(&rune, (const char *) q);
                         if ((ns = get_gototab(f, s, rune)) != 0)                          if ((ns = get_gototab(f, s, rune)) != 0)
                                 s = ns;                                  s = ns;
                         else                          else
Line 780 
Line 780 
                 s = 2;                  s = 2;
                 if (*p == 0)                  if (*p == 0)
                         break;                          break;
                 n = u8_rune(&rune, p);                  n = u8_rune(&rune, (const char *) p);
                 p += n;                  p += n;
         } while (1); /* was *p++ */          } while (1); /* was *p++ */
         return (0);          return (0);
Line 805 
Line 805 
                         if (f->out[s])          /* final state */                          if (f->out[s])          /* final state */
                                 patlen = q-p;                                  patlen = q-p;
                         /* assert(*q < NCHARS); */                          /* assert(*q < NCHARS); */
                         n = u8_rune(&rune, q);                          n = u8_rune(&rune, (const char *) q);
                         if ((ns = get_gototab(f, s, rune)) != 0)                          if ((ns = get_gototab(f, s, rune)) != 0)
                                 s = ns;                                  s = ns;
                         else                          else
Line 893 
Line 893 
                         }                          }
                 }                  }
   
                 j += u8_rune(&c, (uschar *)j);                  j += u8_rune(&c, j);
   
                 if ((ns = get_gototab(pfa, s, c)) != 0)                  if ((ns = get_gototab(pfa, s, c)) != 0)
                         s = ns;                          s = ns;
Line 913 
Line 913 
                         break;     /* best match found */                          break;     /* best match found */
   
                 /* no match at origin i, next i and start over */                  /* no match at origin i, next i and start over */
                 i += u8_rune(&c, (uschar *)i);                  i += u8_rune(&c, i);
                 if (c == 0)                  if (c == 0)
                         break;    /* no match */                          break;    /* no match */
                 j = i;                  j = i;
Line 1234 
Line 1234 
         return 0;          return 0;
 }  }
   
 extern int u8_rune(int *, const uschar *); /* run.c; should be in header file */  
   
 int relex(void)         /* lexical analyzer for reparse */  int relex(void)         /* lexical analyzer for reparse */
 {  {
         int c, n;          int c, n;
Line 1253 
Line 1251 
 rescan:  rescan:
         starttok = prestr;          starttok = prestr;
   
         if ((n = u8_rune(&rlxval, prestr)) > 1) {          if ((n = u8_rune(&rlxval, (const char *) prestr)) > 1) {
                 prestr += n;                  prestr += n;
                 starttok = prestr;                  starttok = prestr;
                 return CHAR;                  return CHAR;
Line 1300 
Line 1298 
                 if (!adjbuf((char **) &buf, &bufsz, n, n, (char **) &bp, "relex1"))                  if (!adjbuf((char **) &buf, &bufsz, n, n, (char **) &bp, "relex1"))
                         FATAL("out of space for reg expr %.10s...", lastre);                          FATAL("out of space for reg expr %.10s...", lastre);
                 for (; ; ) {                  for (; ; ) {
                         if ((n = u8_rune(&rlxval, prestr)) > 1) {                          if ((n = u8_rune(&rlxval, (const char *) prestr)) > 1) {
                                 for (i = 0; i < n; i++)                                  for (i = 0; i < n; i++)
                                         *bp++ = *prestr++;                                          *bp++ = *prestr++;
                                 continue;                                  continue;

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.50