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

version» Context lines:

pike.git/src/modules/Regexp/pike_regexp.c:239:    * 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,int excompat) + regexp *pike_regcomp(char *exp)   {    register regexp *r = NULL;    register 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++)); ) {    switch (c) {    case '(':    case ')': -  *dest++ = excompat ? c : c | SPECIAL; -  break; +     case '.':    case '*':    case '+':    case '|':    case '$':    case '^':    case '[':    case ']':    *dest++ = c | SPECIAL;    break;    case '\\':    switch ( c = *scan++ ) {    case '(':    case ')': -  *dest++ = excompat ? c | SPECIAL : c; +  *dest++ = c;    break;    case '<':    case '>':    *dest++ = c | SPECIAL;    break;    case '{':    case '}':    FAIL("sorry, unimplemented operator");    case 'b': *dest++ = '\b'; break;    case 't': *dest++ = '\t'; break;