[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.12 and 1.12.10.2

version 1.12, 1999/09/16 11:45:20 version 1.12.10.2, 2002/08/01 03:28:15
Line 56 
Line 56 
 #define print   sprint  #define print   sprint
 #define at      sat  #define at      sat
 #define match   smat  #define match   smat
   #define nope    snope
 #endif  #endif
 #ifdef LNAMES  #ifdef LNAMES
 #define matcher lmatcher  #define matcher lmatcher
Line 67 
Line 68 
 #define print   lprint  #define print   lprint
 #define at      lat  #define at      lat
 #define match   lmat  #define match   lmat
   #define nope    lnope
 #endif  #endif
   
 /* another structure passed up and down to avoid zillions of parameters */  /* another structure passed up and down to avoid zillions of parameters */
Line 126  static char *pchar __P((int ch));
Line 128  static char *pchar __P((int ch));
 #define SP(t, s, c)     print(m, t, s, c, stdout)  #define SP(t, s, c)     print(m, t, s, c, stdout)
 #define AT(t, p1, p2, s1, s2)   at(m, t, p1, p2, s1, s2)  #define AT(t, p1, p2, s1, s2)   at(m, t, p1, p2, s1, s2)
 #define NOTE(str)       { if (m->eflags&REG_TRACE) printf("=%s\n", (str)); }  #define NOTE(str)       { if (m->eflags&REG_TRACE) printf("=%s\n", (str)); }
   static int nope = 0;
 #else  #else
 #define SP(t, s, c)     /* nothing */  #define SP(t, s, c)     /* nothing */
 #define AT(t, p1, p2, s1, s2)   /* nothing */  #define AT(t, p1, p2, s1, s2)   /* nothing */
Line 154  int eflags;
Line 157  int eflags;
         const sopno gl = g->laststate;          const sopno gl = g->laststate;
         char *start;          char *start;
         char *stop;          char *stop;
           int error = 0;
   
         _DIAGASSERT(g != NULL);          _DIAGASSERT(g != NULL);
         _DIAGASSERT(string != NULL);          _DIAGASSERT(string != NULL);
Line 202  int eflags;
Line 206  int eflags;
         for (;;) {          for (;;) {
                 endp = fast(m, start, stop, gf, gl);                  endp = fast(m, start, stop, gf, gl);
                 if (endp == NULL) {             /* a miss */                  if (endp == NULL) {             /* a miss */
                         STATETEARDOWN(m);                          error = REG_NOMATCH;
                         return(REG_NOMATCH);                          goto done;
                 }                  }
                 if (nmatch == 0 && !g->backrefs)                  if (nmatch == 0 && !g->backrefs)
                         break;          /* no further info needed */                          break;          /* no further info needed */
Line 226  int eflags;
Line 230  int eflags;
                         m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) *                          m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) *
                                                         sizeof(regmatch_t));                                                          sizeof(regmatch_t));
                 if (m->pmatch == NULL) {                  if (m->pmatch == NULL) {
                         STATETEARDOWN(m);                          error = REG_ESPACE;
                         return(REG_ESPACE);                          goto done;
                 }                  }
                 for (i = 1; i <= m->g->nsub; i++)                  for (i = 1; i <= m->g->nsub; i++)
                         m->pmatch[i].rm_so = m->pmatch[i].rm_eo = (regoff_t)-1;                          m->pmatch[i].rm_so = m->pmatch[i].rm_eo = (regoff_t)-1;
Line 239  int eflags;
Line 243  int eflags;
                                 m->lastpos = (char **)malloc((g->nplus+1) *                                  m->lastpos = (char **)malloc((g->nplus+1) *
                                                         sizeof(char *));                                                          sizeof(char *));
                         if (g->nplus > 0 && m->lastpos == NULL) {                          if (g->nplus > 0 && m->lastpos == NULL) {
                                 free(m->pmatch);                                  error = REG_ESPACE;
                                 STATETEARDOWN(m);                                  goto done;
                                 return(REG_ESPACE);  
                         }                          }
                         NOTE("backref dissect");                          NOTE("backref dissect");
                         dp = backref(m, m->coldp, endp, gf, gl, (sopno)0);                          dp = backref(m, m->coldp, endp, gf, gl, (sopno)0);
Line 296  int eflags;
Line 299  int eflags;
                         }                          }
         }          }
   
         if (m->pmatch != NULL)  done:
           if (m->pmatch != NULL) {
                 free(m->pmatch);                  free(m->pmatch);
         if (m->lastpos != NULL)                  m->pmatch = NULL;
           }
           if (m->lastpos != NULL) {
                 free(m->lastpos);                  free(m->lastpos);
                   m->lastpos = NULL;
           }
         STATETEARDOWN(m);          STATETEARDOWN(m);
         return(0);          return error;
 }  }
   
 /*  /*
Line 1143  int ch;
Line 1151  int ch;
 #undef  print  #undef  print
 #undef  at  #undef  at
 #undef  match  #undef  match
   #undef  nope

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.12.10.2

CVSweb <webmaster@jp.NetBSD.org>