[BACK]Return to engine.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / regex

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/lib/libc/regex/engine.c between version 1.8 and 1.9

version 1.8, 1998/02/03 18:38:12 version 1.9, 1998/11/14 16:43:49
Line 159  int eflags;
Line 159  int eflags;
         if (g->cflags&REG_NOSUB)          if (g->cflags&REG_NOSUB)
                 nmatch = 0;                  nmatch = 0;
         if (eflags&REG_STARTEND) {          if (eflags&REG_STARTEND) {
                 start = string + pmatch[0].rm_so;                  start = string + (size_t)pmatch[0].rm_so;
                 stop = string + pmatch[0].rm_eo;                  stop = string + (size_t)pmatch[0].rm_eo;
         } else {          } else {
                 start = string;                  start = string;
                 stop = start + strlen(start);                  stop = start + strlen(start);
Line 291  int eflags;
Line 291  int eflags;
         }          }
   
         if (m->pmatch != NULL)          if (m->pmatch != NULL)
                 free((char *)m->pmatch);                  free(m->pmatch);
         if (m->lastpos != NULL)          if (m->lastpos != NULL)
                 free((char *)m->lastpos);                  free(m->lastpos);
         STATETEARDOWN(m);          STATETEARDOWN(m);
         return(0);          return(0);
 }  }
Line 323  sopno stopst;
Line 323  sopno stopst;
         char *ssp;      /* start of string matched by subsubRE */          char *ssp;      /* start of string matched by subsubRE */
         char *sep;      /* end of string matched by subsubRE */          char *sep;      /* end of string matched by subsubRE */
         char *oldssp;   /* previous ssp */          char *oldssp;   /* previous ssp */
   #ifndef NDEBUG
         char *dp;          char *dp;
   #endif
   
         AT("diss", start, stop, startst, stopst);          AT("diss", start, stop, startst, stopst);
         sp = start;          sp = start;
Line 382  sopno stopst;
Line 384  sopno stopst;
                         esub = es - 1;                          esub = es - 1;
                         /* did innards match? */                          /* did innards match? */
                         if (slow(m, sp, rest, ssub, esub) != NULL) {                          if (slow(m, sp, rest, ssub, esub) != NULL) {
                                 dp = dissect(m, sp, rest, ssub, esub);  #ifdef NDEBUG
                                   (void)
   #else
                                   dp =
   #endif
                                       dissect(m, sp, rest, ssub, esub);
                                 assert(dp == rest);                                  assert(dp == rest);
                         } else          /* no */                          } else          /* no */
                                 assert(sp == rest);                                  assert(sp == rest);
Line 420  sopno stopst;
Line 427  sopno stopst;
                         }                          }
                         assert(sep == rest);    /* must exhaust substring */                          assert(sep == rest);    /* must exhaust substring */
                         assert(slow(m, ssp, sep, ssub, esub) == rest);                          assert(slow(m, ssp, sep, ssub, esub) == rest);
                         dp = dissect(m, ssp, sep, ssub, esub);  #ifdef NDEBUG
                           (void)
   #else
                           dp =
   #endif
                               dissect(m, ssp, sep, ssub, esub);
                         assert(dp == sep);                          assert(dp == sep);
                         sp = rest;                          sp = rest;
                         break;                          break;
Line 455  sopno stopst;
Line 467  sopno stopst;
                                 else                                  else
                                         assert(OP(m->g->strip[esub]) == O_CH);                                          assert(OP(m->g->strip[esub]) == O_CH);
                         }                          }
                         dp = dissect(m, sp, rest, ssub, esub);  #ifdef NDEBUG
                           (void)
   #else
                           dp =
   #endif
                               dissect(m, sp, rest, ssub, esub);
                         assert(dp == rest);                          assert(dp == rest);
                         sp = rest;                          sp = rest;
                         break;                          break;
Line 603  sopno lev;   /* PLUS nesting level */
Line 620  sopno lev;   /* PLUS nesting level */
                 if (m->pmatch[i].rm_eo == -1)                  if (m->pmatch[i].rm_eo == -1)
                         return(NULL);                          return(NULL);
                 assert(m->pmatch[i].rm_so != -1);                  assert(m->pmatch[i].rm_so != -1);
                 len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so;                  len = (size_t)(m->pmatch[i].rm_eo - m->pmatch[i].rm_so);
                 assert(stop - m->beginp >= len);                  assert(stop - m->beginp >= len);
                 if (sp > stop - len)                  if (sp > stop - len)
                         return(NULL);   /* not enough left to match */                          return(NULL);   /* not enough left to match */
                 ssp = m->offp + m->pmatch[i].rm_so;                  ssp = m->offp + (size_t)m->pmatch[i].rm_so;
                 if (memcmp(sp, ssp, len) != 0)                  if (memcmp(sp, ssp, len) != 0)
                         return(NULL);                          return(NULL);
                 while (m->g->strip[ss] != SOP(O_BACK, i))                  while (m->g->strip[ss] != SOP(O_BACK, i))
                         ss++;                          ss++;
                 return(backref(m, sp+len, stop, ss+1, stopst, lev));                  return(backref(m, sp+len, stop, ss+1, stopst, lev));
                 break;  
         case OQUEST_:           /* to null or not */          case OQUEST_:           /* to null or not */
                 dp = backref(m, sp, stop, ss+1, stopst, lev);                  dp = backref(m, sp, stop, ss+1, stopst, lev);
                 if (dp != NULL)                  if (dp != NULL)
                         return(dp);     /* not */                          return(dp);     /* not */
                 return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev));                  return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev));
                 break;  
         case OPLUS_:          case OPLUS_:
                 assert(m->lastpos != NULL);                  assert(m->lastpos != NULL);
                 assert(lev+1 <= m->g->nplus);                  assert(lev+1 <= m->g->nplus);
                 m->lastpos[lev+1] = sp;                  m->lastpos[lev+1] = sp;
                 return(backref(m, sp, stop, ss+1, stopst, lev+1));                  return(backref(m, sp, stop, ss+1, stopst, lev+1));
                 break;  
         case O_PLUS:          case O_PLUS:
                 if (sp == m->lastpos[lev])      /* last pass matched null */                  if (sp == m->lastpos[lev])      /* last pass matched null */
                         return(backref(m, sp, stop, ss+1, stopst, lev-1));                          return(backref(m, sp, stop, ss+1, stopst, lev-1));
Line 633  sopno lev;   /* PLUS nesting level */
Line 650  sopno lev;   /* PLUS nesting level */
                 m->lastpos[lev] = sp;                  m->lastpos[lev] = sp;
                 dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev);                  dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev);
                 if (dp == NULL)                  if (dp == NULL)
                         return(backref(m, sp, stop, ss+1, stopst, lev-1));                          dp = backref(m, sp, stop, ss+1, stopst, lev-1);
                 else                  return(dp);
                         return(dp);  
                 break;  
         case OCH_:              /* find the right one, if any */          case OCH_:              /* find the right one, if any */
                 ssub = ss + 1;                  ssub = ss + 1;
                 esub = ss + OPND(s) - 1;                  esub = ss + OPND(s) - 1;
Line 657  sopno lev;   /* PLUS nesting level */
Line 673  sopno lev;   /* PLUS nesting level */
                         else                          else
                                 assert(OP(m->g->strip[esub]) == O_CH);                                  assert(OP(m->g->strip[esub]) == O_CH);
                 }                  }
                 break;  
         case OLPAREN:           /* must undo assignment if rest fails */          case OLPAREN:           /* must undo assignment if rest fails */
                 i = OPND(s);                  i = OPND(s);
                 assert(0 < i && i <= m->g->nsub);                  assert(0 < i && i <= m->g->nsub);
Line 668  sopno lev;   /* PLUS nesting level */
Line 684  sopno lev;   /* PLUS nesting level */
                         return(dp);                          return(dp);
                 m->pmatch[i].rm_so = offsave;                  m->pmatch[i].rm_so = offsave;
                 return(NULL);                  return(NULL);
                 break;  
         case ORPAREN:           /* must undo assignment if rest fails */          case ORPAREN:           /* must undo assignment if rest fails */
                 i = OPND(s);                  i = OPND(s);
                 assert(0 < i && i <= m->g->nsub);                  assert(0 < i && i <= m->g->nsub);
Line 679  sopno lev;   /* PLUS nesting level */
Line 695  sopno lev;   /* PLUS nesting level */
                         return(dp);                          return(dp);
                 m->pmatch[i].rm_eo = offsave;                  m->pmatch[i].rm_eo = offsave;
                 return(NULL);                  return(NULL);
                 break;  
         default:                /* uh oh */          default:                /* uh oh */
                 assert(nope);                  assert(nope);
                 break;                  break;

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

CVSweb <webmaster@jp.NetBSD.org>