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

version» Context lines:

pike.git/src/modules/Regexp/pike_regexp.c:221:    * Forward declarations for regcomp()'s friends.    */   static char *reg(int, int *);   static char *regbranch(int *);   static char *regpiece(int *);   static char *regatom(int *);   static char *regnode(char);   static char *regnext(char *);   static void regc(char b);   static void reginsert(char, char *); - static void regtail(char *, char *); - static void regoptail(char *, char *); + static void regtail(char *, const char *); + static void regoptail(char *, const char *);      /*    - regcomp - compile a regular expression into internal code    *    * We can't allocate space until we know how big the compiled form will be,    * but we can't compile it (and thus know how big it is) until we've got a    * place to put the code. So we cheat: we compile it twice, once with code    * generation turned off and size counting turned on, and once "for real".    * This also means that we don't allocate space until we are sure that the    * thing really will compile successfully, and we never have to move the    * code and thus invalidate pointers into it. (Note that it has to be in    * 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) + regexp *pike_regcomp(const char *exp)   {    regexp *r = NULL;    char *scan;    int flags;    short *exp2,*dest,c;       if (exp == NULL)    FAIL("NULL argument");       exp2=xcalloc( (strlen(exp)+1), sizeof(short) ); -  for ( scan=exp,dest=exp2;( c= UCHARAT(scan++)); ) { +  for ( dest=exp2; (c=UCHARAT(exp++)); ) {    switch (c) {    case '(':    case ')':    case '.':    case '*':    case '+':    case '|':    case '$':    case '^':    case '[':    case ']':    *dest++ = c | SPECIAL;    break;    case '\\': -  switch ( c = *scan++ ) { +  switch ( c = *exp++ ) {    case '(':    case ')':    *dest++ = c;    break;    case '<':    case '>':    *dest++ = c | SPECIAL;    break;    case '{':    case '}':
pike.git/src/modules/Regexp/pike_regexp.c:714:       place = opnd; /* Op node, where operand used to be. */    *place++ = op;    *place++ = '\0';    *place++ = '\0';   }      /*    - regtail - set the next-pointer at the end of a node chain    */ - static void regtail(char *p, char *val) + static void regtail(char *p, const char *val)   {    char *scan;    char *temp;    ptrdiff_t offset;       if (p == &regdummy)    return;       /* Find last node. */    scan = p;
pike.git/src/modules/Regexp/pike_regexp.c:743:    offset = scan - val;    else    offset = val - scan;    *(scan + 1) = DO_NOT_WARN((offset >> 8) & 0377);    *(scan + 2) = DO_NOT_WARN(offset & 0377);   }      /*    - regoptail - regtail on operand of first argument; nop if operandless    */ - static void regoptail(char *p, char *val) + static void regoptail(char *p, const char *val)   {    /* "Operandless" and "op != BRANCH" are synonymous in practice. */    if (p == NULL || p == &regdummy || OP(p) != BRANCH)    return;    regtail(OPERAND(p), val);   }      /*    * regexec and friends    */