/[pcre]/code/trunk/pcre_compile.c
ViewVC logotype

Diff of /code/trunk/pcre_compile.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 210 by ph10, Wed Aug 8 14:24:50 2007 UTC revision 213 by ph10, Wed Aug 15 11:34:14 2007 UTC
# Line 146  typedef struct verbitem { Line 146  typedef struct verbitem {
146    const char *name;    const char *name;
147    int   len;    int   len;
148    int   op;    int   op;
149  } verbitem;  } verbitem;
150    
151  static verbitem verbs[] = {  static verbitem verbs[] = {
152    { "ACCEPT", 6, OP_ACCEPT },    { "ACCEPT", 6, OP_ACCEPT },
153    { "COMMIT", 6, OP_COMMIT },    { "COMMIT", 6, OP_COMMIT },
154    { "F",      1, OP_FAIL },    { "F",      1, OP_FAIL },
155    { "FAIL",   4, OP_FAIL },    { "FAIL",   4, OP_FAIL },
156    { "PRUNE",  5, OP_PRUNE },    { "PRUNE",  5, OP_PRUNE },
157    { "SKIP",   4, OP_SKIP  },    { "SKIP",   4, OP_SKIP  },
158    { "THEN",   4, OP_THEN  }    { "THEN",   4, OP_THEN  }
# Line 281  static const char *error_texts[] = { Line 281  static const char *error_texts[] = {
281    "\\g is not followed by a braced name or an optionally braced non-zero number",    "\\g is not followed by a braced name or an optionally braced non-zero number",
282    "(?+ or (?- or (?(+ or (?(- must be followed by a non-zero number",    "(?+ or (?- or (?(+ or (?(- must be followed by a non-zero number",
283    "(*VERB) with an argument is not supported",    "(*VERB) with an argument is not supported",
284    /* 60 */    /* 60 */
285    "(*VERB) not recognized"    "(*VERB) not recognized",
286      "number is too big"
287  };  };
288    
289    
# Line 439  Arguments: Line 440  Arguments:
440    
441  Returns:         zero or positive => a data character  Returns:         zero or positive => a data character
442                   negative => a special escape sequence                   negative => a special escape sequence
443                   on error, errorptr is set                   on error, errorcodeptr is set
444  */  */
445    
446  static int  static int
# Line 523  else Line 524  else
524      c = 0;      c = 0;
525      while ((digitab[ptr[1]] & ctype_digit) != 0)      while ((digitab[ptr[1]] & ctype_digit) != 0)
526        c = c * 10 + *(++ptr) - '0';        c = c * 10 + *(++ptr) - '0';
527    
528        if (c < 0)
529          {
530          *errorcodeptr = ERR61;
531          break;
532          }
533    
534      if (c == 0 || (braced && *(++ptr) != '}'))      if (c == 0 || (braced && *(++ptr) != '}'))
535        {        {
536        *errorcodeptr = ERR57;        *errorcodeptr = ERR57;
537        return 0;        break;
538        }        }
539    
540      if (negated)      if (negated)
# Line 535  else Line 542  else
542        if (c > bracount)        if (c > bracount)
543          {          {
544          *errorcodeptr = ERR15;          *errorcodeptr = ERR15;
545          return 0;          break;
546          }          }
547        c = bracount - (c - 1);        c = bracount - (c - 1);
548        }        }
# Line 564  else Line 571  else
571        c -= '0';        c -= '0';
572        while ((digitab[ptr[1]] & ctype_digit) != 0)        while ((digitab[ptr[1]] & ctype_digit) != 0)
573          c = c * 10 + *(++ptr) - '0';          c = c * 10 + *(++ptr) - '0';
574          if (c < 0)
575            {
576            *errorcodeptr = ERR61;
577            break;
578            }
579        if (c < 10 || c <= bracount)        if (c < 10 || c <= bracount)
580          {          {
581          c = -(ESC_REF + c);          c = -(ESC_REF + c);
# Line 659  else Line 671  else
671      if (c == 0)      if (c == 0)
672        {        {
673        *errorcodeptr = ERR2;        *errorcodeptr = ERR2;
674        return 0;        break;
675        }        }
676    
677  #ifndef EBCDIC  /* ASCII coding */  #ifndef EBCDIC  /* ASCII coding */
# Line 3892  for (;; ptr++) Line 3904  for (;; ptr++)
3904      bravalue = OP_CBRA;      bravalue = OP_CBRA;
3905      save_hwm = cd->hwm;      save_hwm = cd->hwm;
3906      reset_bracount = FALSE;      reset_bracount = FALSE;
3907    
3908      /* First deal with various "verbs" that can be introduced by '*'. */      /* First deal with various "verbs" that can be introduced by '*'. */
3909    
3910      if (*(++ptr) == '*' && (cd->ctypes[ptr[1]] & ctype_letter) != 0)      if (*(++ptr) == '*' && (cd->ctypes[ptr[1]] & ctype_letter) != 0)
3911        {        {
3912        int i, namelen;        int i, namelen;
3913        const uschar *name = ++ptr;        const uschar *name = ++ptr;
3914        previous = NULL;        previous = NULL;
3915        while ((cd->ctypes[*++ptr] & ctype_letter) != 0);        while ((cd->ctypes[*++ptr] & ctype_letter) != 0);
3916        if (*ptr == ':')        if (*ptr == ':')
3917          {          {
3918          *errorcodeptr = ERR59;   /* Not supported */          *errorcodeptr = ERR59;   /* Not supported */
3919          goto FAILED;          goto FAILED;
3920          }          }
3921        if (*ptr != ')')        if (*ptr != ')')
3922          {          {
3923          *errorcodeptr = ERR60;          *errorcodeptr = ERR60;
3924          goto FAILED;          goto FAILED;
3925          }          }
3926        namelen = ptr - name;        namelen = ptr - name;
3927        for (i = 0; i < verbcount; i++)        for (i = 0; i < verbcount; i++)
3928          {          {
3929          if (namelen == verbs[i].len &&          if (namelen == verbs[i].len &&
3930              strncmp((char *)name, verbs[i].name, namelen) == 0)              strncmp((char *)name, verbs[i].name, namelen) == 0)
3931            {            {
3932            *code = verbs[i].op;            *code = verbs[i].op;
3933            if (*code++ == OP_ACCEPT) cd->had_accept = TRUE;            if (*code++ == OP_ACCEPT) cd->had_accept = TRUE;
3934            break;            break;
3935            }            }
3936          }          }
3937        if (i < verbcount) continue;        if (i < verbcount) continue;
3938        *errorcodeptr = ERR60;        *errorcodeptr = ERR60;
3939        goto FAILED;        goto FAILED;
3940        }        }
3941    
3942      /* Deal with the extended parentheses; all are introduced by '?', and the      /* Deal with the extended parentheses; all are introduced by '?', and the
3943      appearance of any of them means that this is not a capturing group. */      appearance of any of them means that this is not a capturing group. */
3944    
# Line 4176  for (;; ptr++) Line 4188  for (;; ptr++)
4188          if (*ptr == ')')          /* Optimize (?!) */          if (*ptr == ')')          /* Optimize (?!) */
4189            {            {
4190            *code++ = OP_FAIL;            *code++ = OP_FAIL;
4191            previous = NULL;            previous = NULL;
4192            continue;            continue;
4193            }            }
4194          bravalue = OP_ASSERT_NOT;          bravalue = OP_ASSERT_NOT;
4195          break;          break;
4196    

Legend:
Removed from v.210  
changed lines
  Added in v.213

  ViewVC Help
Powered by ViewVC 1.1.5