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

version» Context lines:

pike.git/src/modules/Regexp/pike_regexp.c:1:   /* -  * $Id: pike_regexp.c,v 1.18 2000/09/11 18:31:07 grubba Exp $ +  * $Id: pike_regexp.c,v 1.19 2000/09/14 12:08:03 grubba Exp $    *    * regexp.c - regular expression matching    *    * DESCRIPTION    *    * Underneath the reformatting and comment blocks which were added to    * make it consistent with the rest of the code, you will find a    * modified version of Henry Specer's regular expression library.    * Henry's functions were modified to provide the minimal regular    * expression matching, as required by P1003. Henry's code was
pike.git/src/modules/Regexp/pike_regexp.c:247:    * one piece because free() must be able to free it all.)    *    * Beware that the optimization-preparation code in here knows about some    * of the structure of the compiled regexp.    */   regexp *pike_regcomp(char *exp,int excompat)   {    register regexp *r;    register char *scan;    register char *longest; -  register size_t len; +  register ptrdiff_t len;    int flags;    short *exp2,*dest,c;       if (exp == (char *)NULL)    FAIL("NULL argument");       exp2=(short*)xalloc( (strlen(exp)+1) * (sizeof(short[8])/sizeof(char[8])) );    for ( scan=exp,dest=exp2;( c= UCHARAT(scan++)); ) {    switch (c) {    case '(':
pike.git/src/modules/Regexp/pike_regexp.c:350:    * ties in favor of later strings, since the regstart check works    * with the beginning of the r.e. and avoiding duplication    * strengthens checking. Not a strong reason, but sufficient in the    * absence of others.    */    if (flags & SPSTART) {    longest = NULL;    len = 0;    for (; scan != NULL; scan = regnext(scan))    if (OP(scan) == EXACTLY && -  strlen(OPERAND(scan)) >= len) { +  strlen(OPERAND(scan)) >= (size_t)len) {    longest = OPERAND(scan);    len = strlen(OPERAND(scan));    }    r->regmust = longest;    r->regmlen = len;    }    }    free((char*)exp2);    return (r);   }
pike.git/src/modules/Regexp/pike_regexp.c:756:    * Global work variables for regexec().    */   static char *reginput; /* String-input pointer. */   static char *regbol; /* Beginning of input, for ^ check. */   static char **regstartp; /* Pointer to startp array. */   static char **regendp; /* Ditto for endp. */      /*    * Forwards.    */ - STATIC int regtry(regexp *, char *); - STATIC int regmatch(char *); - STATIC size_t regrepeat(char *); + STATIC int regtry(regexp *, char *); + STATIC int regmatch(char *); + STATIC ptrdiff_t regrepeat(char *);      #ifdef PIKE_DEBUG   int regnarrate = 0;   void regdump(regexp *);   STATIC char *regprop(char *op);   #endif      /*    - regexec - match a regexp against a string    */
pike.git/src/modules/Regexp/pike_regexp.c:925:    break;    case WORDEND:    if (*reginput == '\0')    break;    if ( reginput == regbol ||    !ISWORDPART( *((unsigned char *)reginput-1) ) ||    ISWORDPART( *((unsigned char *)reginput) ) )    return (0);    break;    case EXACTLY:{ -  register size_t len; +  register ptrdiff_t len;    register char *opnd;       opnd = OPERAND(scan);    /* Inline the first character, for speed. */    if (*opnd != *reginput)    return (0);    len = strlen(opnd);    if (len > 1 && strncmp(opnd, reginput, len) != 0)    return (0);    reginput += len;
pike.git/src/modules/Regexp/pike_regexp.c:975:    reginput = save;    scan = regnext(scan);    } while (scan != (char *)NULL && OP(scan) == BRANCH);    return (0);    /* NOTREACHED */    }    }    break;    case STAR:{    register char nextch; -  register size_t no; +  register ptrdiff_t no;    register char *save; -  register size_t minimum; +  register ptrdiff_t minimum;       /*    * Lookahead to avoid useless match attempts when we know    * what character comes next.    */    nextch = '\0';    if (OP(nxt) == EXACTLY)    nextch = *OPERAND(nxt);    minimum = (OP(scan) == STAR) ? 0 : 1;    save = reginput;
pike.git/src/modules/Regexp/pike_regexp.c:1065:    */    regerror("corrupted pointers");    return (0);   }      /*    - regrepeat - repeatedly match something simple, report how many    */   #ifdef __STDC__    - static size_t regrepeat(char *p) + static ptrdiff_t regrepeat(char *p)      #else    - static size_t regrepeat(p) + static ptrdiff_t regrepeat(p)   char *p;      #endif   { -  register size_t count = 0; +  register ptrdiff_t count = 0;    register char *scan;    register char *opnd;       scan = reginput;    opnd = OPERAND(p);    switch (OP(p)) {    case ANY:    count = strlen(scan);    scan += count;    break;