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

version» Context lines:

pike.git/src/modules/Regexp/pike_regexp.c:486:    *    * Note that the branching code sequence used for * is somewhat optimized:    * they use the same NOTHING node as both the endmarker for their branch    * list and the body of the last branch. It might seem that this node could    * be dispensed with entirely, but the endmarker role is not redundant.    */   static char *regpiece(int *flagp)   {    register char *ret;    register short op; -  /* register char *nxt; */ +  /* register char *next; */    int flags;       ret = regatom(&flags);    if (ret == NULL)    return (NULL);       op = *regparse;    if (!ISMULT(op)) {    *flagp = flags;    return (ret);
pike.git/src/modules/Regexp/pike_regexp.c:526:    }    }    else if(op == PLUS)    {    if (flags & SIMPLE)    {    reginsert(KPLUS, ret);    }    else    { -  /* ret -> 1: x nxt: 2 -  * tmp -> 2: BRANCH op: 3 nxt: 4 -  * 3: BACK nxt: 1 -  * 4: BRANCH op: 5 nxt: 5 +  /* ret -> 1: x next: 2 +  * tmp -> 2: BRANCH op: 3 next: 4 +  * 3: BACK next: 1 +  * 4: BRANCH op: 5 next: 5    * 5: NOTHING    */    char *tmp;    tmp=regnode(BACK);    reginsert(BRANCH, tmp);    regtail(ret, tmp);    regoptail(tmp, ret);    regtail(ret, regnode(BRANCH));    regtail(ret, regnode(NOTHING));    }
pike.git/src/modules/Regexp/pike_regexp.c:582:    ret = regnode(ANY);    *flagp |= HASWIDTH | SIMPLE;    break;    case LSHBRAC:    ret = regnode(WORDSTART);    break;    case RSHBRAC:    ret = regnode(WORDEND);    break;    case LSQBRAC:{ -  register int class; -  register int classend; +  register int range; +  register int rangeend;       if (*regparse == CARET) { /* Complement of range. */    ret = regnode(ANYBUT);    regparse++;    } else    ret = regnode(ANYOF);    if (*regparse == RSQBRAC || *regparse == '-')    regc((char)(*regparse++));    while (*regparse != '\0' && *regparse != RSQBRAC) {    if (*regparse == '-') {    regparse++;    if (*regparse == RSQBRAC || *regparse == '\0')    regc('-');    else { -  class = (CHARBITS & *(regparse - 2)) + 1; -  classend = (CHARBITS & *(regparse)); -  if (class > classend + 1) +  range = (CHARBITS & *(regparse - 2)) + 1; +  rangeend = (CHARBITS & *(regparse)); +  if (range > rangeend + 1)    FAIL("invalid [] range"); -  for (; class <= classend; class++) -  regc((char)class); +  for (; range <= rangeend; range++) +  regc((char)range);    regparse++;    }    } else    regc((char)(*regparse++));    }    regc('\0');    if (*regparse != RSQBRAC)    FAIL("unmatched []");    regparse++;    *flagp |= HASWIDTH | SIMPLE;
pike.git/src/modules/Regexp/pike_regexp.c:700:    regsize++;   }      /*    - reginsert - insert an operator in front of already-emitted operand    *    * Means relocating the operand.    */   static void reginsert(char op, char *opnd)   { -  register char *src; -  register char *dst; +     register char *place;       if (regcode == &regdummy) {    regsize += 3;    return;    }       memmove(opnd+3, opnd, (size_t)(regcode - opnd));    regcode += 3;   
pike.git/src/modules/Regexp/pike_regexp.c:833:    /* Failure. */    return (0);   }      /*    - regtry - try match at specific point    */   static int regtry(regexp *prog, char *string)   {    register int i; -  register char **sp; -  register char **ep; +  register char **stp; +  register char **enp;       reginput = string;    regstartp = prog->startp;    regendp = prog->endp;    -  sp = prog->startp; -  ep = prog->endp; +  stp = prog->startp; +  enp = prog->endp;    for (i = NSUBEXP; i > 0; i--) { -  *sp++ = NULL; -  *ep++ = NULL; +  *stp++ = NULL; +  *enp++ = NULL;    }    if (regmatch(prog->program)) {    prog->startp[0] = string;    prog->endp[0] = reginput;    return (1);    } else    return (0);   }      /*
pike.git/src/modules/Regexp/pike_regexp.c:867:    * Conceptually the strategy is simple: check to see whether the current    * node matches, call self recursively to see whether the rest matches,    * and then act accordingly. In practice we make some effort to avoid    * recursion, in particular by going through "ordinary" nodes (that don't    * need to know whether the rest of the match failed) by a loop instead of    * by recursion.    */   static int regmatch(char *prog)   {    register char *scan; /* Current node. */ -  char *nxt; /* nxt node. */ +  char *next; /* nxt node. */       check_c_stack (4 * sizeof (void *));       scan = prog;   #ifdef PIKE_DEBUG    if (scan != NULL && regnarrate)    fprintf(stderr, "%s(\n", regprop(scan));   #endif    while (scan != NULL) {   #ifdef PIKE_DEBUG    if (regnarrate)    fprintf(stderr, "%s...\n", regprop(scan));   #endif -  nxt = regnext(scan); +  next = regnext(scan);       switch (OP(scan)) {    case BOL:    if (reginput != regbol)    return (0);    break;    case EOL:    if (*reginput != '\0')    return (0);    break;
pike.git/src/modules/Regexp/pike_regexp.c:947:    reginput++;    break;    case NOTHING:    break;    case BACK:    break;       case BRANCH:{    register char *save;    -  if (OP(nxt) != BRANCH) /* No choice. */ -  nxt = OPERAND(scan); /* Avoid recursion. */ +  if (OP(next) != BRANCH) /* No choice. */ +  next = OPERAND(scan); /* Avoid recursion. */    else {    do {    save = reginput;    if (regmatch(OPERAND(scan)))    return (1);    reginput = save;    scan = regnext(scan);    } while (scan != NULL && OP(scan) == BRANCH);    return (0);    /* NOTREACHED */    }    }    break;    case KPLUS:    case STAR:{    register char nextch = -  (OP(nxt) == EXACTLY) ? *OPERAND(nxt) : '\0'; +  (OP(next) == EXACTLY) ? *OPERAND(next) : '\0';    register size_t no;    register char *save = reginput;    register size_t minimum = (OP(scan) == STAR) ? 0 : 1;       for(no = regrepeat(OPERAND(scan)) + 1; no > minimum; no--) {    reginput = save + no -1;    /* If it could work, try it. */    if (nextch == '\0' || *reginput == nextch) -  if (regmatch(nxt)) +  if (regmatch(next))    return (1);    }    return (0);    }       case END:    return (1); /* Success! */       default:    if(OP(scan) >= OPEN && OP(scan)<OPEN+NSUBEXP)    {    register int no; -  register char *save; +  register char *input;       no = OP(scan) - OPEN; -  save = reginput; +  input = reginput;    -  if (regmatch(nxt)) { +  if (regmatch(next)) {    /*    * Don't set startp if some later invocation of the same    * parentheses already has.    */    if (regstartp[no] == NULL) -  regstartp[no] = save; +  regstartp[no] = input;    return (1);    } else    return (0);    }       if(OP(scan) >= CLOSE && OP(scan)<CLOSE+NSUBEXP)    {    register int no; -  register char *save; +  register char *input;       no = OP(scan) - CLOSE; -  save = reginput; +  input = reginput;    -  if (regmatch(nxt)) { +  if (regmatch(next)) {    /*    * Don't set endp if some later invocation of the same    * parentheses already has.    */    if (regendp[no] == NULL) -  regendp[no] = save; +  regendp[no] = input;    return (1);    } else    return (0);    }    regerror("memory corruption");    return (0);       }    -  scan = nxt; +  scan = next;    }       /*    * We get here only if there's trouble -- normally "case END" is the    * terminating point.    */    regerror("corrupted pointers");    return (0);   }   
pike.git/src/modules/Regexp/pike_regexp.c:1105: Inside #if defined(PIKE_DEBUG)
     static char *regprop(char *);      /*    - regdump - dump a regexp onto stdout in vaguely comprehensible form    */   void regdump(regexp *r)   {    register char *s;    register char op = EXACTLY; /* Arbitrary non-END op. */ -  register char *nxt; +  register char *next;       s = r->program;    while (op != END) { /* While that wasn't END last time... */    op = OP(s);    printf("%2ld%s", /* Where, what. */    DO_NOT_WARN((long)(s - r->program)),    regprop(s)); -  nxt = regnext(s); -  if (nxt == NULL) /* nxt ptr. */ +  next = regnext(s); +  if (next == NULL) /* next ptr. */    printf("(0)");    else    printf("(%ld)", -  DO_NOT_WARN((long)( (s - r->program) + (nxt - s)))); +  DO_NOT_WARN((long)( (s - r->program) + (next - s))));    s += 3;    if (op == ANYOF || op == ANYBUT || op == EXACTLY) {    /* Literal string, where present. */    while (*s != '\0') {    putchar(*s);    s++;    }    s++;    }    putchar('\n');