pike.git / src / modules / Regexp / pike_regexp.c

version» Context lines:

pike.git/src/modules/Regexp/pike_regexp.c:116:   #define BACK 7 /* no Match "", "nxt" ptr points backward. */   #define EXACTLY 8 /* str Match this string. */   #define NOTHING 9 /* no Match empty string. */   #define STAR 10 /* node Match this (simple) thing 0 or more    * times. */   #define WORDSTART 11 /* node matching a start of a word */   #define WORDEND 12 /* node matching an end of a word */   #define OPEN 20 /* no Mark this point in input as start of    * #n. */    /* OPEN+1 is number 1, etc. */ - #define CLOSE 30 /* no Analogous to OPEN. */ + #define CLOSE (OPEN+NSUBEXP) /* no Analogous to OPEN. */      /*    * Opcode notes:    *    * BRANCH The set of branches constituting a single choice are hooked    * together with their "nxt" pointers, since precedence prevents    * anything being concatenated to any individual branch. The    * "nxt" pointer of the last BRANCH in a choice points to the    * thing following the whole choice. This is also where the    * final "nxt" pointer of each individual branch points; each
pike.git/src/modules/Regexp/pike_regexp.c:950:    case ANYBUT:    if (*reginput == '\0' ||    STRCHR(OPERAND(scan), *reginput) != (char *)NULL)    return (0);    reginput++;    break;    case NOTHING:    break;    case BACK:    break; -  case OPEN + 1: -  case OPEN + 2: -  case OPEN + 3: -  case OPEN + 4: -  case OPEN + 5: -  case OPEN + 6: -  case OPEN + 7: -  case OPEN + 8: -  case OPEN + 9:{ -  register int no; -  register char *save; +     -  no = OP(scan) - OPEN; -  save = reginput; -  -  if (regmatch(nxt)) { -  /* -  * Don't set startp if some later invocation of the same -  * parentheses already has. -  */ -  if (regstartp[no] == (char *)NULL) -  regstartp[no] = save; -  return (1); -  } else -  return (0); -  } -  -  case CLOSE + 1: -  case CLOSE + 2: -  case CLOSE + 3: -  case CLOSE + 4: -  case CLOSE + 5: -  case CLOSE + 6: -  case CLOSE + 7: -  case CLOSE + 8: -  case CLOSE + 9:{ -  register int no; -  register char *save; -  -  no = OP(scan) - CLOSE; -  save = reginput; -  -  if (regmatch(nxt)) { -  /* -  * Don't set endp if some later invocation of the same -  * parentheses already has. -  */ -  if (regendp[no] == (char *)NULL) -  regendp[no] = save; -  return (1); -  } else -  return (0); -  } -  +     case BRANCH:{    register char *save;       if (OP(nxt) != BRANCH) /* No choice. */    nxt = OPERAND(scan); /* Avoid recursion. */    else {    do {    save = reginput;    if (regmatch(OPERAND(scan)))    return (1);
pike.git/src/modules/Regexp/pike_regexp.c:1054:    no--;    reginput = save + no;    }    return (0);    }       case END:    return (1); /* Success! */       default: +  if(OP(scan) >= OPEN && OP(scan)<OPEN+NSUBEXP) +  { +  register int no; +  register char *save; +  +  no = OP(scan) - OPEN; +  save = reginput; +  +  if (regmatch(nxt)) { +  /* +  * Don't set startp if some later invocation of the same +  * parentheses already has. +  */ +  if (regstartp[no] == (char *)NULL) +  regstartp[no] = save; +  return (1); +  } else +  return (0); +  } +  +  if(OP(scan) >= CLOSE && OP(scan)<CLOSE+NSUBEXP) +  { +  register int no; +  register char *save; +  +  no = OP(scan) - CLOSE; +  save = reginput; +  +  if (regmatch(nxt)) { +  /* +  * Don't set endp if some later invocation of the same +  * parentheses already has. +  */ +  if (regendp[no] == (char *)NULL) +  regendp[no] = save; +  return (1); +  } else +  return (0); +  }    regerror("memory corruption");    return (0);       }       scan = nxt;    }       /*    * We get here only if there's trouble -- normally "case END" is the
pike.git/src/modules/Regexp/pike_regexp.c:1256:    break;    case NOTHING:    p = "NOTHING";    break;    case BACK:    p = "BACK";    break;    case END:    p = "END";    break; -  case OPEN + 1: -  case OPEN + 2: -  case OPEN + 3: -  case OPEN + 4: -  case OPEN + 5: -  case OPEN + 6: -  case OPEN + 7: -  case OPEN + 8: -  case OPEN + 9: +  +  case STAR: +  p = "STAR"; +  break; +  +  default: +  if(OP(op) >= OPEN && OP(op) < OPEN+NSUBEXP) +  {    sprintf(buf + strlen(buf), "OPEN%d", OP(op) - OPEN);    p = (char *)NULL;    break; -  case CLOSE + 1: -  case CLOSE + 2: -  case CLOSE + 3: -  case CLOSE + 4: -  case CLOSE + 5: -  case CLOSE + 6: -  case CLOSE + 7: -  case CLOSE + 8: -  case CLOSE + 9: +  } +  if(OP(op) >= CLOSE && OP(op) < CLOSE+NSUBEXP) +  {    sprintf(buf + strlen(buf), "CLOSE%d", OP(op) - CLOSE);    p = (char *)NULL;    break; -  case STAR: -  p = "STAR"; -  break; -  default: +  }    regerror("corrupted opcode");    p=(char *)NULL;    break;    }    if (p != (char *)NULL)    strcat(buf, p);    return (buf);   }   #endif