/[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 335 by ph10, Sat Apr 12 14:36:14 2008 UTC revision 340 by ph10, Fri Apr 18 20:00:21 2008 UTC
# Line 302  static const char error_texts[] = Line 302  static const char error_texts[] =
302    "(*VERB) not recognized\0"    "(*VERB) not recognized\0"
303    "number is too big\0"    "number is too big\0"
304    "subpattern name expected\0"    "subpattern name expected\0"
305    "digit expected after (?+";    "digit expected after (?+\0"
306      "] is an invalid data character in JavaScript compatibility mode";
307    
308    
309  /* Table to identify digits and hex digits. This is used when compiling  /* Table to identify digits and hex digits. This is used when compiling
# Line 1007  for (; *ptr != 0; ptr++) Line 1008  for (; *ptr != 0; ptr++)
1008      continue;      continue;
1009      }      }
1010    
1011    /* Skip over character classes */    /* Skip over character classes; this logic must be similar to the way they
1012      are handled for real. If the first character is '^', skip it. Also, if the
1013      first few characters (either before or after ^) are \Q\E or \E we skip them
1014      too. This makes for compatibility with Perl. */
1015    
1016    if (*ptr == '[')    if (*ptr == '[')
1017      {      {
1018        BOOL negate_class = FALSE;
1019        for (;;)
1020          {
1021          int c = *(++ptr);
1022          if (c == '\\')
1023            {
1024            if (ptr[1] == 'E') ptr++;
1025              else if (strncmp((const char *)ptr+1, "Q\\E", 3) == 0) ptr += 3;
1026                else break;
1027            }
1028          else if (!negate_class && c == '^')
1029            negate_class = TRUE;
1030          else break;
1031          }
1032    
1033        /* If the next character is ']', it is a data character that must be
1034        skipped. */
1035    
1036        if (ptr[1] == ']') ptr++;
1037    
1038      while (*(++ptr) != ']')      while (*(++ptr) != ']')
1039        {        {
1040        if (*ptr == 0) return -1;        if (*ptr == 0) return -1;
# Line 2654  for (;; ptr++) Line 2678  for (;; ptr++)
2678      opcode is compiled. It may optionally have a bit map for characters < 256,      opcode is compiled. It may optionally have a bit map for characters < 256,
2679      but those above are are explicitly listed afterwards. A flag byte tells      but those above are are explicitly listed afterwards. A flag byte tells
2680      whether the bitmap is present, and whether this is a negated class or not.      whether the bitmap is present, and whether this is a negated class or not.
2681      */  
2682        In JavaScript compatibility mode, an isolated ']' causes an error. In
2683        default (Perl) mode, it is treated as a data character. */
2684    
2685        case ']':
2686        if ((cd->external_options & PCRE_JAVASCRIPT_COMPAT) != 0)
2687          {
2688          *errorcodeptr = ERR64;
2689          goto FAILED;
2690          }
2691        goto NORMAL_CHAR;
2692    
2693      case '[':      case '[':
2694      previous = code;      previous = code;

Legend:
Removed from v.335  
changed lines
  Added in v.340

  ViewVC Help
Powered by ViewVC 1.1.5