/[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 533 by ph10, Wed Jun 2 19:02:41 2010 UTC revision 552 by ph10, Wed Oct 13 10:15:41 2010 UTC
# Line 261  static const int posix_class_maps[] = { Line 261  static const int posix_class_maps[] = {
261    cbit_xdigit,-1,          0              /* xdigit */    cbit_xdigit,-1,          0              /* xdigit */
262  };  };
263    
264  /* Table of substitutes for \d etc when PCRE_UCP is set. The POSIX class  /* Table of substitutes for \d etc when PCRE_UCP is set. The POSIX class
265  substitutes must be in the order of the names, defined above, and there are  substitutes must be in the order of the names, defined above, and there are
266  both positive and negative cases. NULL means no substitute. */  both positive and negative cases. NULL means no substitute. */
267    
268  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 272  static const uschar *substitutes[] = { Line 272  static const uschar *substitutes[] = {
272    (uschar *)"\\P{Xsp}",   /* \S */       /* NOTE: Xsp is Perl space */    (uschar *)"\\P{Xsp}",   /* \S */       /* NOTE: Xsp is Perl space */
273    (uschar *)"\\p{Xsp}",   /* \s */    (uschar *)"\\p{Xsp}",   /* \s */
274    (uschar *)"\\P{Xwd}",   /* \W */    (uschar *)"\\P{Xwd}",   /* \W */
275    (uschar *)"\\p{Xwd}"    /* \w */    (uschar *)"\\p{Xwd}"    /* \w */
276  };  };
277    
278  static const uschar *posix_substitutes[] = {  static const uschar *posix_substitutes[] = {
279    (uschar *)"\\p{L}",     /* alpha */    (uschar *)"\\p{L}",     /* alpha */
280    (uschar *)"\\p{Ll}",    /* lower */    (uschar *)"\\p{Ll}",    /* lower */
281    (uschar *)"\\p{Lu}",    /* upper */    (uschar *)"\\p{Lu}",    /* upper */
282    (uschar *)"\\p{Xan}",   /* alnum */    (uschar *)"\\p{Xan}",   /* alnum */
283    NULL,                   /* ascii */    NULL,                   /* ascii */
284    (uschar *)"\\h",        /* blank */    (uschar *)"\\h",        /* blank */
285    NULL,                   /* cntrl */    NULL,                   /* cntrl */
# Line 289  static const uschar *posix_substitutes[] Line 289  static const uschar *posix_substitutes[]
289    NULL,                   /* punct */    NULL,                   /* punct */
290    (uschar *)"\\p{Xps}",   /* space */    /* NOTE: Xps is POSIX space */    (uschar *)"\\p{Xps}",   /* space */    /* NOTE: Xps is POSIX space */
291    (uschar *)"\\p{Xwd}",   /* word */    (uschar *)"\\p{Xwd}",   /* word */
292    NULL,                   /* xdigit */    NULL,                   /* xdigit */
293    /* Negated cases */    /* Negated cases */
294    (uschar *)"\\P{L}",     /* ^alpha */    (uschar *)"\\P{L}",     /* ^alpha */
295    (uschar *)"\\P{Ll}",    /* ^lower */    (uschar *)"\\P{Ll}",    /* ^lower */
296    (uschar *)"\\P{Lu}",    /* ^upper */    (uschar *)"\\P{Lu}",    /* ^upper */
297    (uschar *)"\\P{Xan}",   /* ^alnum */    (uschar *)"\\P{Xan}",   /* ^alnum */
298    NULL,                   /* ^ascii */    NULL,                   /* ^ascii */
299    (uschar *)"\\H",        /* ^blank */    (uschar *)"\\H",        /* ^blank */
300    NULL,                   /* ^cntrl */    NULL,                   /* ^cntrl */
# Line 304  static const uschar *posix_substitutes[] Line 304  static const uschar *posix_substitutes[]
304    NULL,                   /* ^punct */    NULL,                   /* ^punct */
305    (uschar *)"\\P{Xps}",   /* ^space */   /* NOTE: Xps is POSIX space */    (uschar *)"\\P{Xps}",   /* ^space */   /* NOTE: Xps is POSIX space */
306    (uschar *)"\\P{Xwd}",   /* ^word */    (uschar *)"\\P{Xwd}",   /* ^word */
307    NULL                    /* ^xdigit */    NULL                    /* ^xdigit */
308  };  };
309  #define POSIX_SUBSIZE (sizeof(posix_substitutes)/sizeof(uschar *))  #define POSIX_SUBSIZE (sizeof(posix_substitutes)/sizeof(uschar *))
310  #endif  #endif
311    
312  #define STRING(a)  # a  #define STRING(a)  # a
313  #define XSTRING(s) STRING(s)  #define XSTRING(s) STRING(s)
# Line 407  static const char error_texts[] = Line 407  static const char error_texts[] =
407    /* 65 */    /* 65 */
408    "different names for subpatterns of the same number are not allowed\0"    "different names for subpatterns of the same number are not allowed\0"
409    "(*MARK) must have an argument\0"    "(*MARK) must have an argument\0"
410    "this version of PCRE is not compiled with PCRE_UCP support\0"    "this version of PCRE is not compiled with PCRE_UCP support\0"
411    ;    ;
412    
413  /* 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 1129  dealing with. The very first call may no Line 1129  dealing with. The very first call may no
1129    
1130  if (ptr[0] == CHAR_LEFT_PARENTHESIS)  if (ptr[0] == CHAR_LEFT_PARENTHESIS)
1131    {    {
1132    if (ptr[1] == CHAR_QUESTION_MARK &&    /* Handle specials such as (*SKIP) or (*UTF8) etc. */
1133        ptr[2] == CHAR_VERTICAL_LINE)  
1134      if (ptr[1] == CHAR_ASTERISK) ptr += 2;
1135    
1136      /* Handle a normal, unnamed capturing parenthesis. */
1137    
1138      else if (ptr[1] != CHAR_QUESTION_MARK)
1139        {
1140        *count += 1;
1141        if (name == NULL && *count == lorn) return *count;
1142        ptr++;
1143        }
1144    
1145      /* All cases now have (? at the start. Remember when we are in a group
1146      where the parenthesis numbers are duplicated. */
1147    
1148      else if (ptr[2] == CHAR_VERTICAL_LINE)
1149      {      {
1150      ptr += 3;      ptr += 3;
1151      dup_parens = TRUE;      dup_parens = TRUE;
1152      }      }
1153    
1154    /* Handle a normal, unnamed capturing parenthesis */    /* Handle comments; all characters are allowed until a ket is reached. */
1155    
1156    else if (ptr[1] != CHAR_QUESTION_MARK && ptr[1] != CHAR_ASTERISK)    else if (ptr[2] == CHAR_NUMBER_SIGN)
1157      {      {
1158      *count += 1;      for (ptr += 3; *ptr != 0; ptr++) if (*ptr == CHAR_RIGHT_PARENTHESIS) break;
1159      if (name == NULL && *count == lorn) return *count;      goto FAIL_EXIT;
     ptr++;  
1160      }      }
1161    
1162    /* Handle a condition. If it is an assertion, just carry on so that it    /* Handle a condition. If it is an assertion, just carry on so that it
1163    is processed as normal. If not, skip to the closing parenthesis of the    is processed as normal. If not, skip to the closing parenthesis of the
1164    condition (there can't be any nested parens. */    condition (there can't be any nested parens). */
1165    
1166    else if (ptr[2] == CHAR_LEFT_PARENTHESIS)    else if (ptr[2] == CHAR_LEFT_PARENTHESIS)
1167      {      {
# Line 1159  if (ptr[0] == CHAR_LEFT_PARENTHESIS) Line 1173  if (ptr[0] == CHAR_LEFT_PARENTHESIS)
1173        }        }
1174      }      }
1175    
1176    /* We have either (? or (* and not a condition */    /* Start with (? but not a condition. */
1177    
1178    else    else
1179      {      {
# Line 1281  for (; *ptr != 0; ptr++) Line 1295  for (; *ptr != 0; ptr++)
1295    else if (*ptr == CHAR_RIGHT_PARENTHESIS)    else if (*ptr == CHAR_RIGHT_PARENTHESIS)
1296      {      {
1297      if (dup_parens && *count < hwm_count) *count = hwm_count;      if (dup_parens && *count < hwm_count) *count = hwm_count;
1298      *ptrptr = ptr;      goto FAIL_EXIT;
     return -1;  
1299      }      }
1300    
1301    else if (*ptr == CHAR_VERTICAL_LINE && dup_parens)    else if (*ptr == CHAR_VERTICAL_LINE && dup_parens)
# Line 1711  for (;;) Line 1724  for (;;)
1724        case OP_MARK:        case OP_MARK:
1725        case OP_PRUNE_ARG:        case OP_PRUNE_ARG:
1726        case OP_SKIP_ARG:        case OP_SKIP_ARG:
       case OP_THEN_ARG:  
1727        code += code[1];        code += code[1];
1728        break;        break;
1729    
1730          case OP_THEN_ARG:
1731          code += code[1+LINK_SIZE];
1732          break;
1733        }        }
1734    
1735      /* Add in the fixed length from the table */      /* Add in the fixed length from the table */
# Line 1814  for (;;) Line 1830  for (;;)
1830        case OP_MARK:        case OP_MARK:
1831        case OP_PRUNE_ARG:        case OP_PRUNE_ARG:
1832        case OP_SKIP_ARG:        case OP_SKIP_ARG:
       case OP_THEN_ARG:  
1833        code += code[1];        code += code[1];
1834        break;        break;
1835    
1836          case OP_THEN_ARG:
1837          code += code[1+LINK_SIZE];
1838          break;
1839        }        }
1840    
1841      /* Add in the fixed length from the table */      /* Add in the fixed length from the table */
# Line 2092  for (code = first_significant_code(code Line 2111  for (code = first_significant_code(code
2111      case OP_MARK:      case OP_MARK:
2112      case OP_PRUNE_ARG:      case OP_PRUNE_ARG:
2113      case OP_SKIP_ARG:      case OP_SKIP_ARG:
     case OP_THEN_ARG:  
2114      code += code[1];      code += code[1];
2115      break;      break;
2116    
2117        case OP_THEN_ARG:
2118        code += code[1+LINK_SIZE];
2119        break;
2120    
2121      /* None of the remaining opcodes are required to match a character. */      /* None of the remaining opcodes are required to match a character. */
2122    
2123      default:      default:
# Line 2407  Arguments: Line 2429  Arguments:
2429    ptype        the property type    ptype        the property type
2430    pdata        the data for the type    pdata        the data for the type
2431    negated      TRUE if it's a negated property (\P or \p{^)    negated      TRUE if it's a negated property (\P or \p{^)
2432    
2433  Returns:       TRUE if auto-possessifying is OK  Returns:       TRUE if auto-possessifying is OK
2434  */  */
2435    
2436  static BOOL  static BOOL
2437  check_char_prop(int c, int ptype, int pdata, BOOL negated)  check_char_prop(int c, int ptype, int pdata, BOOL negated)
# Line 2453  switch(ptype) Line 2475  switch(ptype)
2475            _pcre_ucp_gentype[prop->chartype] == ucp_N ||            _pcre_ucp_gentype[prop->chartype] == ucp_N ||
2476            c == CHAR_UNDERSCORE) == negated;            c == CHAR_UNDERSCORE) == negated;
2477    }    }
2478  return FALSE;  return FALSE;
2479  }  }
2480  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
2481    
# Line 2478  Returns:        TRUE if possessifying is Line 2500  Returns:        TRUE if possessifying is
2500  */  */
2501    
2502  static BOOL  static BOOL
2503  check_auto_possessive(const uschar *previous, BOOL utf8, const uschar *ptr,  check_auto_possessive(const uschar *previous, BOOL utf8, const uschar *ptr,
2504    int options, compile_data *cd)    int options, compile_data *cd)
2505  {  {
2506  int c, next;  int c, next;
# Line 2549  the next item is a character. */ Line 2571  the next item is a character. */
2571  if (next >= 0) switch(op_code)  if (next >= 0) switch(op_code)
2572    {    {
2573    case OP_CHAR:    case OP_CHAR:
2574  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2575    GETCHARTEST(c, previous);    GETCHARTEST(c, previous);
2576  #else  #else
2577    c = *previous;    c = *previous;
2578  #endif  #endif
2579    return c != next;    return c != next;
2580    
2581    /* For CHARNC (caseless character) we must check the other case. If we have    /* For CHARNC (caseless character) we must check the other case. If we have
2582    Unicode property support, we can use it to test the other case of    Unicode property support, we can use it to test the other case of
2583    high-valued characters. */    high-valued characters. */
2584    
2585    case OP_CHARNC:    case OP_CHARNC:
2586  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2587    GETCHARTEST(c, previous);    GETCHARTEST(c, previous);
2588  #else  #else
2589    c = *previous;    c = *previous;
2590  #endif  #endif
2591    if (c == next) return FALSE;    if (c == next) return FALSE;
2592  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2593    if (utf8)    if (utf8)
# Line 2603  if (next >= 0) switch(op_code) Line 2625  if (next >= 0) switch(op_code)
2625    else    else
2626  #endif  /* SUPPORT_UTF8 */  #endif  /* SUPPORT_UTF8 */
2627    return (c == cd->fcc[next]);  /* Non-UTF-8 mode */    return (c == cd->fcc[next]);  /* Non-UTF-8 mode */
2628    
2629    /* Note that OP_DIGIT etc. are generated only when PCRE_UCP is *not* set.    /* Note that OP_DIGIT etc. are generated only when PCRE_UCP is *not* set.
2630    When it is set, \d etc. are converted into OP_(NOT_)PROP codes. */    When it is set, \d etc. are converted into OP_(NOT_)PROP codes. */
2631    
2632    case OP_DIGIT:    case OP_DIGIT:
2633    return next > 127 || (cd->ctypes[next] & ctype_digit) == 0;    return next > 127 || (cd->ctypes[next] & ctype_digit) == 0;
# Line 2673  if (next >= 0) switch(op_code) Line 2695  if (next >= 0) switch(op_code)
2695  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2696    case OP_PROP:    case OP_PROP:
2697    return check_char_prop(next, previous[0], previous[1], FALSE);    return check_char_prop(next, previous[0], previous[1], FALSE);
2698    
2699    case OP_NOTPROP:    case OP_NOTPROP:
2700    return check_char_prop(next, previous[0], previous[1], TRUE);    return check_char_prop(next, previous[0], previous[1], TRUE);
2701  #endif  #endif
# Line 2683  if (next >= 0) switch(op_code) Line 2705  if (next >= 0) switch(op_code)
2705    }    }
2706    
2707    
2708  /* Handle the case when the next item is \d, \s, etc. Note that when PCRE_UCP  /* Handle the case when the next item is \d, \s, etc. Note that when PCRE_UCP
2709  is set, \d turns into ESC_du rather than ESC_d, etc., so ESC_d etc. are  is set, \d turns into ESC_du rather than ESC_d, etc., so ESC_d etc. are
2710  generated only when PCRE_UCP is *not* set, that is, when only ASCII  generated only when PCRE_UCP is *not* set, that is, when only ASCII
2711  characteristics are recognized. Similarly, the opcodes OP_DIGIT etc. are  characteristics are recognized. Similarly, the opcodes OP_DIGIT etc. are
2712  replaced by OP_PROP codes when PCRE_UCP is set. */  replaced by OP_PROP codes when PCRE_UCP is set. */
2713    
2714  switch(op_code)  switch(op_code)
2715    {    {
2716    case OP_CHAR:    case OP_CHAR:
2717    case OP_CHARNC:    case OP_CHARNC:
2718  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2719    GETCHARTEST(c, previous);    GETCHARTEST(c, previous);
2720  #else  #else
2721    c = *previous;    c = *previous;
2722  #endif  #endif
2723    switch(-next)    switch(-next)
2724      {      {
2725      case ESC_d:      case ESC_d:
# Line 2761  switch(op_code) Line 2783  switch(op_code)
2783        default:        default:
2784        return -next == ESC_v;        return -next == ESC_v;
2785        }        }
2786    
2787      /* When PCRE_UCP is set, these values get generated for \d etc. Find      /* When PCRE_UCP is set, these values get generated for \d etc. Find
2788      their substitutions and process them. The result will always be either      their substitutions and process them. The result will always be either
2789      -ESC_p or -ESC_P. Then fall through to process those values. */      -ESC_p or -ESC_P. Then fall through to process those values. */
2790    
2791  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2792      case ESC_du:      case ESC_du:
2793      case ESC_DU:      case ESC_DU:
# Line 2780  switch(op_code) Line 2802  switch(op_code)
2802        if (temperrorcode != 0) return FALSE;        if (temperrorcode != 0) return FALSE;
2803        ptr++;    /* For compatibility */        ptr++;    /* For compatibility */
2804        }        }
2805      /* Fall through */      /* Fall through */
2806    
2807      case ESC_p:      case ESC_p:
2808      case ESC_P:      case ESC_P:
2809        {        {
2810        int ptype, pdata, errorcodeptr;        int ptype, pdata, errorcodeptr;
2811        BOOL negated;        BOOL negated;
2812    
2813        ptr--;      /* Make ptr point at the p or P */        ptr--;      /* Make ptr point at the p or P */
2814        ptype = get_ucp(&ptr, &negated, &pdata, &errorcodeptr);        ptype = get_ucp(&ptr, &negated, &pdata, &errorcodeptr);
2815        if (ptype < 0) return FALSE;        if (ptype < 0) return FALSE;
2816        ptr++;      /* Point past the final curly ket */        ptr++;      /* Point past the final curly ket */
2817    
2818        /* If the property item is optional, we have to give up. (When generated        /* If the property item is optional, we have to give up. (When generated
2819        from \d etc by PCRE_UCP, this test will have been applied much earlier,        from \d etc by PCRE_UCP, this test will have been applied much earlier,
2820        to the original \d etc. At this point, ptr will point to a zero byte. */        to the original \d etc. At this point, ptr will point to a zero byte. */
2821    
2822        if (*ptr == CHAR_ASTERISK || *ptr == CHAR_QUESTION_MARK ||        if (*ptr == CHAR_ASTERISK || *ptr == CHAR_QUESTION_MARK ||
2823          strncmp((char *)ptr, STR_LEFT_CURLY_BRACKET STR_0 STR_COMMA, 3) == 0)          strncmp((char *)ptr, STR_LEFT_CURLY_BRACKET STR_0 STR_COMMA, 3) == 0)
2824            return FALSE;            return FALSE;
2825    
2826        /* Do the property check. */        /* Do the property check. */
2827    
2828        return check_char_prop(c, ptype, pdata, (next == -ESC_P) != negated);        return check_char_prop(c, ptype, pdata, (next == -ESC_P) != negated);
2829        }        }
2830  #endif  #endif
2831    
2832      default:      default:
2833      return FALSE;      return FALSE;
2834      }      }
2835    
2836    /* In principle, support for Unicode properties should be integrated here as    /* In principle, support for Unicode properties should be integrated here as
2837    well. It means re-organizing the above code so as to get hold of the property    well. It means re-organizing the above code so as to get hold of the property
2838    values before switching on the op-code. However, I wonder how many patterns    values before switching on the op-code. However, I wonder how many patterns
2839    combine ASCII \d etc with Unicode properties? (Note that if PCRE_UCP is set,    combine ASCII \d etc with Unicode properties? (Note that if PCRE_UCP is set,
2840    these op-codes are never generated.) */    these op-codes are never generated.) */
2841    
2842    case OP_DIGIT:    case OP_DIGIT:
2843    return next == -ESC_D || next == -ESC_s || next == -ESC_W ||    return next == -ESC_D || next == -ESC_s || next == -ESC_W ||
# Line 2831  switch(op_code) Line 2853  switch(op_code)
2853    return next == -ESC_s || next == -ESC_h || next == -ESC_v;    return next == -ESC_s || next == -ESC_h || next == -ESC_v;
2854    
2855    case OP_HSPACE:    case OP_HSPACE:
2856    return next == -ESC_S || next == -ESC_H || next == -ESC_d ||    return next == -ESC_S || next == -ESC_H || next == -ESC_d ||
2857           next == -ESC_w || next == -ESC_v || next == -ESC_R;           next == -ESC_w || next == -ESC_v || next == -ESC_R;
2858    
2859    case OP_NOT_HSPACE:    case OP_NOT_HSPACE:
2860    return next == -ESC_h;    return next == -ESC_h;
2861    
2862    /* Can't have \S in here because VT matches \S (Perl anomaly) */    /* Can't have \S in here because VT matches \S (Perl anomaly) */
2863    case OP_ANYNL:    case OP_ANYNL:
2864    case OP_VSPACE:    case OP_VSPACE:
2865    return next == -ESC_V || next == -ESC_d || next == -ESC_w;    return next == -ESC_V || next == -ESC_d || next == -ESC_w;
2866    
# Line 2846  switch(op_code) Line 2868  switch(op_code)
2868    return next == -ESC_v || next == -ESC_R;    return next == -ESC_v || next == -ESC_R;
2869    
2870    case OP_WORDCHAR:    case OP_WORDCHAR:
2871    return next == -ESC_W || next == -ESC_s || next == -ESC_h ||    return next == -ESC_W || next == -ESC_s || next == -ESC_h ||
2872           next == -ESC_v || next == -ESC_R;           next == -ESC_v || next == -ESC_R;
2873    
2874    case OP_NOT_WORDCHAR:    case OP_NOT_WORDCHAR:
# Line 2982  for (;; ptr++) Line 3004  for (;; ptr++)
3004    
3005    c = *ptr;    c = *ptr;
3006    
3007    /* If we are at the end of a nested substitution, revert to the outer level    /* If we are at the end of a nested substitution, revert to the outer level
3008    string. Nesting only happens one level deep. */    string. Nesting only happens one level deep. */
3009    
3010    if (c == 0 && nestptr != NULL)    if (c == 0 && nestptr != NULL)
# Line 3289  for (;; ptr++) Line 3311  for (;; ptr++)
3311          {                           /* Braces are required because the */          {                           /* Braces are required because the */
3312          GETCHARLEN(c, ptr, ptr);    /* macro generates multiple statements */          GETCHARLEN(c, ptr, ptr);    /* macro generates multiple statements */
3313          }          }
3314    
3315        /* In the pre-compile phase, accumulate the length of any UTF-8 extra        /* In the pre-compile phase, accumulate the length of any UTF-8 extra
3316        data and reset the pointer. This is so that very large classes that        data and reset the pointer. This is so that very large classes that
3317        contain a zillion UTF-8 characters no longer overwrite the work space        contain a zillion UTF-8 characters no longer overwrite the work space
# Line 3358  for (;; ptr++) Line 3380  for (;; ptr++)
3380    
3381          if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)          if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)
3382            posix_class = 0;            posix_class = 0;
3383    
3384          /* When PCRE_UCP is set, some of the POSIX classes are converted to          /* When PCRE_UCP is set, some of the POSIX classes are converted to
3385          different escape sequences that use Unicode properties. */          different escape sequences that use Unicode properties. */
3386    
3387  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3388          if ((options & PCRE_UCP) != 0)          if ((options & PCRE_UCP) != 0)
3389            {            {
3390            int pc = posix_class + ((local_negate)? POSIX_SUBSIZE/2 : 0);            int pc = posix_class + ((local_negate)? POSIX_SUBSIZE/2 : 0);
3391            if (posix_substitutes[pc] != NULL)            if (posix_substitutes[pc] != NULL)
3392              {              {
3393              nestptr = tempptr + 1;              nestptr = tempptr + 1;
3394              ptr = posix_substitutes[pc] - 1;              ptr = posix_substitutes[pc] - 1;
3395              continue;              continue;
3396              }              }
3397            }            }
3398  #endif  #endif
3399          /* In the non-UCP case, we build the bit map for the POSIX class in a          /* In the non-UCP case, we build the bit map for the POSIX class in a
3400          chunk of local store because we may be adding and subtracting from it,          chunk of local store because we may be adding and subtracting from it,
3401          and we don't want to subtract bits that may be in the main map already.          and we don't want to subtract bits that may be in the main map already.
# Line 3460  for (;; ptr++) Line 3482  for (;; ptr++)
3482              case ESC_SU:              case ESC_SU:
3483              nestptr = ptr;              nestptr = ptr;
3484              ptr = substitutes[-c - ESC_DU] - 1;  /* Just before substitute */              ptr = substitutes[-c - ESC_DU] - 1;  /* Just before substitute */
3485              class_charcount -= 2;                /* Undo! */              class_charcount -= 2;                /* Undo! */
3486              continue;              continue;
3487  #endif  #endif
3488              case ESC_d:              case ESC_d:
# Line 3481  for (;; ptr++) Line 3503  for (;; ptr++)
3503              for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_word];              for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_word];
3504              continue;              continue;
3505    
3506                /* Perl 5.004 onwards omits VT from \s, but we must preserve it
3507                if it was previously set by something earlier in the character
3508                class. */
3509    
3510              case ESC_s:              case ESC_s:
3511              for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_space];              classbits[0] |= cbits[cbit_space];
3512              classbits[1] &= ~0x08;   /* Perl 5.004 onwards omits VT from \s */              classbits[1] |= cbits[cbit_space+1] & ~0x08;
3513                for (c = 2; c < 32; c++) classbits[c] |= cbits[c+cbit_space];
3514              continue;              continue;
3515    
3516              case ESC_S:              case ESC_S:
# Line 3911  for (;; ptr++) Line 3938  for (;; ptr++)
3938      can cause firstbyte to be set. Otherwise, there can be no first char if      can cause firstbyte to be set. Otherwise, there can be no first char if
3939      this item is first, whatever repeat count may follow. In the case of      this item is first, whatever repeat count may follow. In the case of
3940      reqbyte, save the previous value for reinstating. */      reqbyte, save the previous value for reinstating. */
3941    
3942  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3943      if (class_charcount == 1 && !class_utf8 &&      if (class_charcount == 1 && !class_utf8 &&
3944        (!utf8 || !negate_class || class_lastchar < 128))        (!utf8 || !negate_class || class_lastchar < 128))
# Line 3991  for (;; ptr++) Line 4018  for (;; ptr++)
4018        }        }
4019  #endif  #endif
4020    
4021      /* If there are no characters > 255, or they are all to be included or      /* If there are no characters > 255, or they are all to be included or
4022      excluded, set the opcode to OP_CLASS or OP_NCLASS, depending on whether the      excluded, set the opcode to OP_CLASS or OP_NCLASS, depending on whether the
4023      whole class was negated and whether there were negative specials such as \S      whole class was negated and whether there were negative specials such as \S
4024      (non-UCP) in the class. Then copy the 32-byte map into the code vector,      (non-UCP) in the class. Then copy the 32-byte map into the code vector,
# Line 4795  for (;; ptr++) Line 4822  for (;; ptr++)
4822                *errorcodeptr = ERR66;                *errorcodeptr = ERR66;
4823                goto FAILED;                goto FAILED;
4824                }                }
4825              *code++ = verbs[i].op;              *code = verbs[i].op;
4826                if (*code++ == OP_THEN)
4827                  {
4828                  PUT(code, 0, code - bcptr->current_branch - 1);
4829                  code += LINK_SIZE;
4830                  }
4831              }              }
4832    
4833            else            else
# Line 4805  for (;; ptr++) Line 4837  for (;; ptr++)
4837                *errorcodeptr = ERR59;                *errorcodeptr = ERR59;
4838                goto FAILED;                goto FAILED;
4839                }                }
4840              *code++ = verbs[i].op_arg;              *code = verbs[i].op_arg;
4841                if (*code++ == OP_THEN_ARG)
4842                  {
4843                  PUT(code, 0, code - bcptr->current_branch - 1);
4844                  code += LINK_SIZE;
4845                  }
4846              *code++ = arglen;              *code++ = arglen;
4847              memcpy(code, arg, arglen);              memcpy(code, arg, arglen);
4848              code += arglen;              code += arglen;
# Line 5795  for (;; ptr++) Line 5832  for (;; ptr++)
5832    
5833      /* ===================================================================*/      /* ===================================================================*/
5834      /* Handle metasequences introduced by \. For ones like \d, the ESC_ values      /* Handle metasequences introduced by \. For ones like \d, the ESC_ values
5835      are arranged to be the negation of the corresponding OP_values in the      are arranged to be the negation of the corresponding OP_values in the
5836      default case when PCRE_UCP is not set. For the back references, the values      default case when PCRE_UCP is not set. For the back references, the values
5837      are ESC_REF plus the reference number. Only back references and those types      are ESC_REF plus the reference number. Only back references and those types
5838      that consume a character may be repeated. We can test for values between      that consume a character may be repeated. We can test for values between
# Line 5973  for (;; ptr++) Line 6010  for (;; ptr++)
6010            ptr = substitutes[-c - ESC_DU] - 1;  /* Just before substitute */            ptr = substitutes[-c - ESC_DU] - 1;  /* Just before substitute */
6011            }            }
6012          else          else
6013  #endif  #endif
6014            {            {
6015            previous = (-c > ESC_b && -c < ESC_Z)? code : NULL;            previous = (-c > ESC_b && -c < ESC_Z)? code : NULL;
6016            *code++ = -c;            *code++ = -c;
6017            }            }
6018          }          }
6019        continue;        continue;
6020        }        }
# Line 6809  while (ptr[skipatstart] == CHAR_LEFT_PAR Line 6846  while (ptr[skipatstart] == CHAR_LEFT_PAR
6846      options = (options & ~(PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) | newbsr;      options = (options & ~(PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) | newbsr;
6847    else break;    else break;
6848    }    }
6849    
6850  utf8 = (options & PCRE_UTF8) != 0;  utf8 = (options & PCRE_UTF8) != 0;
6851    
6852  /* Can't support UTF8 unless PCRE has been compiled to include the code. */  /* Can't support UTF8 unless PCRE has been compiled to include the code. */
# Line 6835  if (utf8) Line 6872  if (utf8)
6872  if ((options & PCRE_UCP) != 0)  if ((options & PCRE_UCP) != 0)
6873    {    {
6874    errorcode = ERR67;    errorcode = ERR67;
6875    goto PCRE_EARLY_ERROR_RETURN;    goto PCRE_EARLY_ERROR_RETURN;
6876    }    }
6877  #endif  #endif
6878    
6879  /* Check validity of \R options. */  /* Check validity of \R options. */

Legend:
Removed from v.533  
changed lines
  Added in v.552

  ViewVC Help
Powered by ViewVC 1.1.5