/[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 1114 by chpe, Tue Oct 16 15:57:16 2012 UTC revision 1253 by ph10, Fri Feb 22 11:38:35 2013 UTC
# Line 80  to check them every time. */ Line 80  to check them every time. */
80  /* Definitions to allow mutual recursion */  /* Definitions to allow mutual recursion */
81    
82  static int  static int
83    add_list_to_class(pcre_uint8 *, pcre_uchar **, int, compile_data *,    add_list_to_class(pcre_uint8 *, pcre_uchar **, int, compile_data *,
84      const pcre_uint32 *, unsigned int);      const pcre_uint32 *, unsigned int);
85    
86  static BOOL  static BOOL
87    compile_regex(int, pcre_uchar **, const pcre_uchar **, int *, BOOL, BOOL, int, int,    compile_regex(int, pcre_uchar **, const pcre_uchar **, int *, BOOL, BOOL, int, int,
88      pcre_uint32 *, pcre_int32 *, pcre_uint32 *, pcre_int32 *, branch_chain *,      pcre_uint32 *, pcre_int32 *, pcre_uint32 *, pcre_int32 *, branch_chain *,
89      compile_data *, int *);      compile_data *, int *);
90    
91    
# Line 667  find_error_text(int n) Line 667  find_error_text(int n)
667  const char *s = error_texts;  const char *s = error_texts;
668  for (; n > 0; n--)  for (; n > 0; n--)
669    {    {
670    while (*s++ != 0) {};    while (*s++ != CHAR_NULL) {};
671    if (*s == 0) return "Error text not found (please report)";    if (*s == CHAR_NULL) return "Error text not found (please report)";
672    }    }
673  return s;  return s;
674  }  }
# Line 773  Returns:         zero => a data characte Line 773  Returns:         zero => a data characte
773  */  */
774    
775  static int  static int
776  check_escape(const pcre_uchar **ptrptr, pcre_uint32 *chptr, int *errorcodeptr,  check_escape(const pcre_uchar **ptrptr, pcre_uint32 *chptr, int *errorcodeptr,
777    int bracount, int options, BOOL isclass)    int bracount, int options, BOOL isclass)
778  {  {
779  /* PCRE_UTF16 has the same value as PCRE_UTF8. */  /* PCRE_UTF16 has the same value as PCRE_UTF8. */
# Line 788  ptr--;                            /* Set Line 788  ptr--;                            /* Set
788    
789  /* If backslash is at the end of the pattern, it's an error. */  /* If backslash is at the end of the pattern, it's an error. */
790    
791  if (c == 0) *errorcodeptr = ERR1;  if (c == CHAR_NULL) *errorcodeptr = ERR1;
792    
793  /* Non-alphanumerics are literals. For digits or letters, do an initial lookup  /* Non-alphanumerics are literals. For digits or letters, do an initial lookup
794  in a table. A non-zero result is something that can be returned immediately.  in a table. A non-zero result is something that can be returned immediately.
# Line 797  Otherwise further processing may be requ Line 797  Otherwise further processing may be requ
797  #ifndef EBCDIC  /* ASCII/UTF-8 coding */  #ifndef EBCDIC  /* ASCII/UTF-8 coding */
798  /* Not alphanumeric */  /* Not alphanumeric */
799  else if (c < CHAR_0 || c > CHAR_z) {}  else if (c < CHAR_0 || c > CHAR_z) {}
800  else if ((i = escapes[c - CHAR_0]) != 0) { if (i > 0) c = (pcre_uint32)i; else escape = -i; }  else if ((i = escapes[c - CHAR_0]) != 0)
801      { if (i > 0) c = (pcre_uint32)i; else escape = -i; }
802    
803  #else           /* EBCDIC coding */  #else           /* EBCDIC coding */
804  /* Not alphanumeric */  /* Not alphanumeric */
# Line 847  else Line 848  else
848            }            }
849    
850  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
851          if (c > (utf ? 0x10ffff : 0xff))          if (c > (utf ? 0x10ffffU : 0xffU))
852  #elif defined COMPILE_PCRE16  #elif defined COMPILE_PCRE16
853          if (c > (utf ? 0x10ffff : 0xffff))          if (c > (utf ? 0x10ffffU : 0xffffU))
854  #elif defined COMPILE_PCRE32  #elif defined COMPILE_PCRE32
855          if (utf && c > 0x10ffff)          if (utf && c > 0x10ffffU)
856  #endif  #endif
857            {            {
858            *errorcodeptr = ERR76;            *errorcodeptr = ERR76;
# Line 898  else Line 899  else
899      if (ptr[1] == CHAR_LEFT_CURLY_BRACKET)      if (ptr[1] == CHAR_LEFT_CURLY_BRACKET)
900        {        {
901        const pcre_uchar *p;        const pcre_uchar *p;
902        for (p = ptr+2; *p != 0 && *p != CHAR_RIGHT_CURLY_BRACKET; p++)        for (p = ptr+2; *p != CHAR_NULL && *p != CHAR_RIGHT_CURLY_BRACKET; p++)
903          if (*p != CHAR_MINUS && !IS_DIGIT(*p)) break;          if (*p != CHAR_MINUS && !IS_DIGIT(*p)) break;
904        if (*p != 0 && *p != CHAR_RIGHT_CURLY_BRACKET)        if (*p != CHAR_NULL && *p != CHAR_RIGHT_CURLY_BRACKET)
905          {          {
906          escape = ESC_k;          escape = ESC_k;
907          break;          break;
# Line 1085  else Line 1086  else
1086  #endif  #endif
1087    
1088  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
1089          if (c > (utf ? 0x10ffff : 0xff)) { overflow = TRUE; break; }          if (c > (utf ? 0x10ffffU : 0xffU)) { overflow = TRUE; break; }
1090  #elif defined COMPILE_PCRE16  #elif defined COMPILE_PCRE16
1091          if (c > (utf ? 0x10ffff : 0xffff)) { overflow = TRUE; break; }          if (c > (utf ? 0x10ffffU : 0xffffU)) { overflow = TRUE; break; }
1092  #elif defined COMPILE_PCRE32  #elif defined COMPILE_PCRE32
1093          if (utf && c > 0x10ffff) { overflow = TRUE; break; }          if (utf && c > 0x10ffffU) { overflow = TRUE; break; }
1094  #endif  #endif
1095          }          }
1096    
# Line 1134  else Line 1135  else
1135    
1136      case CHAR_c:      case CHAR_c:
1137      c = *(++ptr);      c = *(++ptr);
1138      if (c == 0)      if (c == CHAR_NULL)
1139        {        {
1140        *errorcodeptr = ERR2;        *errorcodeptr = ERR2;
1141        break;        break;
# Line 1203  escape sequence. Line 1204  escape sequence.
1204  Argument:  Argument:
1205    ptrptr         points to the pattern position pointer    ptrptr         points to the pattern position pointer
1206    negptr         points to a boolean that is set TRUE for negation else FALSE    negptr         points to a boolean that is set TRUE for negation else FALSE
1207    dptr           points to an int that is set to the detailed property value    ptypeptr       points to an unsigned int that is set to the type value
1208      pdataptr       points to an unsigned int that is set to the detailed property value
1209    errorcodeptr   points to the error code variable    errorcodeptr   points to the error code variable
1210    
1211  Returns:         type value from ucp_type_table, or -1 for an invalid type  Returns:         TRUE if the type value was found, or FALSE for an invalid type
1212  */  */
1213    
1214  static int  static BOOL
1215  get_ucp(const pcre_uchar **ptrptr, BOOL *negptr, int *dptr, int *errorcodeptr)  get_ucp(const pcre_uchar **ptrptr, BOOL *negptr, unsigned int *ptypeptr,
1216      unsigned int *pdataptr, int *errorcodeptr)
1217  {  {
1218  pcre_uchar c;  pcre_uchar c;
1219  int i, bot, top;  int i, bot, top;
# Line 1218  const pcre_uchar *ptr = *ptrptr; Line 1221  const pcre_uchar *ptr = *ptrptr;
1221  pcre_uchar name[32];  pcre_uchar name[32];
1222    
1223  c = *(++ptr);  c = *(++ptr);
1224  if (c == 0) goto ERROR_RETURN;  if (c == CHAR_NULL) goto ERROR_RETURN;
1225    
1226  *negptr = FALSE;  *negptr = FALSE;
1227    
# Line 1235  if (c == CHAR_LEFT_CURLY_BRACKET) Line 1238  if (c == CHAR_LEFT_CURLY_BRACKET)
1238    for (i = 0; i < (int)(sizeof(name) / sizeof(pcre_uchar)) - 1; i++)    for (i = 0; i < (int)(sizeof(name) / sizeof(pcre_uchar)) - 1; i++)
1239      {      {
1240      c = *(++ptr);      c = *(++ptr);
1241      if (c == 0) goto ERROR_RETURN;      if (c == CHAR_NULL) goto ERROR_RETURN;
1242      if (c == CHAR_RIGHT_CURLY_BRACKET) break;      if (c == CHAR_RIGHT_CURLY_BRACKET) break;
1243      name[i] = c;      name[i] = c;
1244      }      }
# Line 1265  while (bot < top) Line 1268  while (bot < top)
1268    r = STRCMP_UC_C8(name, PRIV(utt_names) + PRIV(utt)[i].name_offset);    r = STRCMP_UC_C8(name, PRIV(utt_names) + PRIV(utt)[i].name_offset);
1269    if (r == 0)    if (r == 0)
1270      {      {
1271      *dptr = PRIV(utt)[i].value;      *ptypeptr = PRIV(utt)[i].type;
1272      return PRIV(utt)[i].type;      *pdataptr = PRIV(utt)[i].value;
1273        return TRUE;
1274      }      }
1275    if (r > 0) bot = i + 1; else top = i;    if (r > 0) bot = i + 1; else top = i;
1276    }    }
1277    
1278  *errorcodeptr = ERR47;  *errorcodeptr = ERR47;
1279  *ptrptr = ptr;  *ptrptr = ptr;
1280  return -1;  return FALSE;
1281    
1282  ERROR_RETURN:  ERROR_RETURN:
1283  *errorcodeptr = ERR46;  *errorcodeptr = ERR46;
1284  *ptrptr = ptr;  *ptrptr = ptr;
1285  return -1;  return FALSE;
1286  }  }
1287  #endif  #endif
1288    
# Line 1429  if (ptr[0] == CHAR_LEFT_PARENTHESIS) Line 1433  if (ptr[0] == CHAR_LEFT_PARENTHESIS)
1433    
1434    else if (ptr[2] == CHAR_NUMBER_SIGN)    else if (ptr[2] == CHAR_NUMBER_SIGN)
1435      {      {
1436      for (ptr += 3; *ptr != 0; ptr++) if (*ptr == CHAR_RIGHT_PARENTHESIS) break;      for (ptr += 3; *ptr != CHAR_NULL; ptr++)
1437          if (*ptr == CHAR_RIGHT_PARENTHESIS) break;
1438      goto FAIL_EXIT;      goto FAIL_EXIT;
1439      }      }
1440    
# Line 1442  if (ptr[0] == CHAR_LEFT_PARENTHESIS) Line 1447  if (ptr[0] == CHAR_LEFT_PARENTHESIS)
1447      ptr += 2;      ptr += 2;
1448      if (ptr[1] != CHAR_QUESTION_MARK)      if (ptr[1] != CHAR_QUESTION_MARK)
1449        {        {
1450        while (*ptr != 0 && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;        while (*ptr != CHAR_NULL && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;
1451        if (*ptr != 0) ptr++;        if (*ptr != CHAR_NULL) ptr++;
1452        }        }
1453      }      }
1454    
# Line 1486  for (; ptr < cd->end_pattern; ptr++) Line 1491  for (; ptr < cd->end_pattern; ptr++)
1491    
1492    if (*ptr == CHAR_BACKSLASH)    if (*ptr == CHAR_BACKSLASH)
1493      {      {
1494      if (*(++ptr) == 0) goto FAIL_EXIT;      if (*(++ptr) == CHAR_NULL) goto FAIL_EXIT;
1495      if (*ptr == CHAR_Q) for (;;)      if (*ptr == CHAR_Q) for (;;)
1496        {        {
1497        while (*(++ptr) != 0 && *ptr != CHAR_BACKSLASH) {};        while (*(++ptr) != CHAR_NULL && *ptr != CHAR_BACKSLASH) {};
1498        if (*ptr == 0) goto FAIL_EXIT;        if (*ptr == CHAR_NULL) goto FAIL_EXIT;
1499        if (*(++ptr) == CHAR_E) break;        if (*(++ptr) == CHAR_E) break;
1500        }        }
1501      continue;      continue;
# Line 1534  for (; ptr < cd->end_pattern; ptr++) Line 1539  for (; ptr < cd->end_pattern; ptr++)
1539    
1540      while (*(++ptr) != CHAR_RIGHT_SQUARE_BRACKET)      while (*(++ptr) != CHAR_RIGHT_SQUARE_BRACKET)
1541        {        {
1542        if (*ptr == 0) return -1;        if (*ptr == CHAR_NULL) return -1;
1543        if (*ptr == CHAR_BACKSLASH)        if (*ptr == CHAR_BACKSLASH)
1544          {          {
1545          if (*(++ptr) == 0) goto FAIL_EXIT;          if (*(++ptr) == CHAR_NULL) goto FAIL_EXIT;
1546          if (*ptr == CHAR_Q) for (;;)          if (*ptr == CHAR_Q) for (;;)
1547            {            {
1548            while (*(++ptr) != 0 && *ptr != CHAR_BACKSLASH) {};            while (*(++ptr) != CHAR_NULL && *ptr != CHAR_BACKSLASH) {};
1549            if (*ptr == 0) goto FAIL_EXIT;            if (*ptr == CHAR_NULL) goto FAIL_EXIT;
1550            if (*(++ptr) == CHAR_E) break;            if (*(++ptr) == CHAR_E) break;
1551            }            }
1552          continue;          continue;
# Line 1555  for (; ptr < cd->end_pattern; ptr++) Line 1560  for (; ptr < cd->end_pattern; ptr++)
1560    if (xmode && *ptr == CHAR_NUMBER_SIGN)    if (xmode && *ptr == CHAR_NUMBER_SIGN)
1561      {      {
1562      ptr++;      ptr++;
1563      while (*ptr != 0)      while (*ptr != CHAR_NULL)
1564        {        {
1565        if (IS_NEWLINE(ptr)) { ptr += cd->nllen - 1; break; }        if (IS_NEWLINE(ptr)) { ptr += cd->nllen - 1; break; }
1566        ptr++;        ptr++;
# Line 1563  for (; ptr < cd->end_pattern; ptr++) Line 1568  for (; ptr < cd->end_pattern; ptr++)
1568        if (utf) FORWARDCHAR(ptr);        if (utf) FORWARDCHAR(ptr);
1569  #endif  #endif
1570        }        }
1571      if (*ptr == 0) goto FAIL_EXIT;      if (*ptr == CHAR_NULL) goto FAIL_EXIT;
1572      continue;      continue;
1573      }      }
1574    
# Line 1573  for (; ptr < cd->end_pattern; ptr++) Line 1578  for (; ptr < cd->end_pattern; ptr++)
1578      {      {
1579      int rc = find_parens_sub(&ptr, cd, name, lorn, xmode, utf, count);      int rc = find_parens_sub(&ptr, cd, name, lorn, xmode, utf, count);
1580      if (rc > 0) return rc;      if (rc > 0) return rc;
1581      if (*ptr == 0) goto FAIL_EXIT;      if (*ptr == CHAR_NULL) goto FAIL_EXIT;
1582      }      }
1583    
1584    else if (*ptr == CHAR_RIGHT_PARENTHESIS)    else if (*ptr == CHAR_RIGHT_PARENTHESIS)
# Line 1638  matching closing parens. That is why we Line 1643  matching closing parens. That is why we
1643  for (;;)  for (;;)
1644    {    {
1645    rc = find_parens_sub(&ptr, cd, name, lorn, xmode, utf, &count);    rc = find_parens_sub(&ptr, cd, name, lorn, xmode, utf, &count);
1646    if (rc > 0 || *ptr++ == 0) break;    if (rc > 0 || *ptr++ == CHAR_NULL) break;
1647    }    }
1648    
1649  return rc;  return rc;
# Line 1875  for (;;) Line 1880  for (;;)
1880    
1881      case OP_TYPEEXACT:      case OP_TYPEEXACT:
1882      branchlength += GET2(cc,1);      branchlength += GET2(cc,1);
1883      if (cc[1 + IMM2_SIZE] == OP_PROP || cc[1 + IMM2_SIZE] == OP_NOTPROP)      if (cc[1 + IMM2_SIZE] == OP_PROP || cc[1 + IMM2_SIZE] == OP_NOTPROP)
1884        cc += 2;        cc += 2;
1885      cc += 1 + IMM2_SIZE + 1;      cc += 1 + IMM2_SIZE + 1;
1886      break;      break;
# Line 1911  for (;;) Line 1916  for (;;)
1916    
1917      /* Check a class for variable quantification */      /* Check a class for variable quantification */
1918    
 #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32  
     case OP_XCLASS:  
     cc += GET(cc, 1) - PRIV(OP_lengths)[OP_CLASS];  
     /* Fall through */  
 #endif  
   
1919      case OP_CLASS:      case OP_CLASS:
1920      case OP_NCLASS:      case OP_NCLASS:
1921    #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1922        case OP_XCLASS:
1923        /* The original code caused an unsigned overflow in 64 bit systems,
1924        so now we use a conditional statement. */
1925        if (op == OP_XCLASS)
1926          cc += GET(cc, 1);
1927        else
1928          cc += PRIV(OP_lengths)[OP_CLASS];
1929    #else
1930      cc += PRIV(OP_lengths)[OP_CLASS];      cc += PRIV(OP_lengths)[OP_CLASS];
1931    #endif
1932    
1933      switch (*cc)      switch (*cc)
1934        {        {
# Line 2114  for (;;) Line 2123  for (;;)
2123        case OP_TYPEMINUPTO:        case OP_TYPEMINUPTO:
2124        case OP_TYPEEXACT:        case OP_TYPEEXACT:
2125        case OP_TYPEPOSUPTO:        case OP_TYPEPOSUPTO:
2126        if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)        if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
2127          code += 2;          code += 2;
2128        break;        break;
2129    
# Line 2234  for (;;) Line 2243  for (;;)
2243        case OP_TYPEUPTO:        case OP_TYPEUPTO:
2244        case OP_TYPEMINUPTO:        case OP_TYPEMINUPTO:
2245        case OP_TYPEEXACT:        case OP_TYPEEXACT:
2246        if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)        if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
2247          code += 2;          code += 2;
2248        break;        break;
2249    
# Line 2560  for (code = first_significant_code(code Line 2569  for (code = first_significant_code(code
2569      case OP_TYPEUPTO:      case OP_TYPEUPTO:
2570      case OP_TYPEMINUPTO:      case OP_TYPEMINUPTO:
2571      case OP_TYPEPOSUPTO:      case OP_TYPEPOSUPTO:
2572      if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)      if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
2573        code += 2;        code += 2;
2574      break;      break;
2575    
# Line 2710  check_posix_syntax(const pcre_uchar *ptr Line 2719  check_posix_syntax(const pcre_uchar *ptr
2719  {  {
2720  pcre_uchar terminator;          /* Don't combine these lines; the Solaris cc */  pcre_uchar terminator;          /* Don't combine these lines; the Solaris cc */
2721  terminator = *(++ptr);   /* compiler warns about "non-constant" initializer. */  terminator = *(++ptr);   /* compiler warns about "non-constant" initializer. */
2722  for (++ptr; *ptr != 0; ptr++)  for (++ptr; *ptr != CHAR_NULL; ptr++)
2723    {    {
2724    if (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)    if (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
2725      ptr++;      ptr++;
# Line 2895  PUT(previous_callout, 2 + LINK_SIZE, len Line 2904  PUT(previous_callout, 2 + LINK_SIZE, len
2904  /* This function is passed the start and end of a class range, in UTF-8 mode  /* This function is passed the start and end of a class range, in UTF-8 mode
2905  with UCP support. It searches up the characters, looking for ranges of  with UCP support. It searches up the characters, looking for ranges of
2906  characters in the "other" case. Each call returns the next one, updating the  characters in the "other" case. Each call returns the next one, updating the
2907  start address. A character with multiple other cases is returned on its own  start address. A character with multiple other cases is returned on its own
2908  with a special return value.  with a special return value.
2909    
2910  Arguments:  Arguments:
# Line 2907  Arguments: Line 2916  Arguments:
2916  Yield:        -1 when no more  Yield:        -1 when no more
2917                 0 when a range is returned                 0 when a range is returned
2918                >0 the CASESET offset for char with multiple other cases                >0 the CASESET offset for char with multiple other cases
2919                  in this case, ocptr contains the original                  in this case, ocptr contains the original
2920  */  */
2921    
2922  static int  static int
# Line 2915  get_othercase_range(pcre_uint32 *cptr, p Line 2924  get_othercase_range(pcre_uint32 *cptr, p
2924    pcre_uint32 *odptr)    pcre_uint32 *odptr)
2925  {  {
2926  pcre_uint32 c, othercase, next;  pcre_uint32 c, othercase, next;
2927  int co;  unsigned int co;
2928    
2929  /* Find the first character that has an other case. If it has multiple other  /* Find the first character that has an other case. If it has multiple other
2930  cases, return its case offset value. */  cases, return its case offset value. */
2931    
2932  for (c = *cptr; c <= d; c++)  for (c = *cptr; c <= d; c++)
2933    {    {
2934    if ((co = UCD_CASESET(c)) != 0)    if ((co = UCD_CASESET(c)) != 0)
2935      {      {
2936      *ocptr = c++;   /* Character that has the set */      *ocptr = c++;   /* Character that has the set */
2937      *cptr = c;      /* Rest of input range */      *cptr = c;      /* Rest of input range */
2938      return co;      return (int)co;
2939      }      }
2940    if ((othercase = UCD_OTHERCASE(c)) != c) break;    if ((othercase = UCD_OTHERCASE(c)) != c) break;
2941    }    }
2942    
2943  if (c > d) return -1;  /* Reached end of range */  if (c > d) return -1;  /* Reached end of range */
# Line 2966  Returns:       TRUE if auto-possessifyin Line 2975  Returns:       TRUE if auto-possessifyin
2975  */  */
2976    
2977  static BOOL  static BOOL
2978  check_char_prop(pcre_uint32 c, int ptype, int pdata, BOOL negated)  check_char_prop(pcre_uint32 c, unsigned int ptype, unsigned int pdata, BOOL negated)
2979  {  {
2980  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2981  const pcre_uint32 *p;  const pcre_uint32 *p;
# Line 3011  switch(ptype) Line 3020  switch(ptype)
3020    return (PRIV(ucp_gentype)[prop->chartype] == ucp_L ||    return (PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
3021            PRIV(ucp_gentype)[prop->chartype] == ucp_N ||            PRIV(ucp_gentype)[prop->chartype] == ucp_N ||
3022            c == CHAR_UNDERSCORE) == negated;            c == CHAR_UNDERSCORE) == negated;
3023    
3024  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3025    case PT_CLIST:    case PT_CLIST:
3026    p = PRIV(ucd_caseless_sets) + prop->caseset;    p = PRIV(ucd_caseless_sets) + prop->caseset;
3027    for (;;)    for (;;)
3028      {      {
3029      if ((unsigned int)c < *p) return !negated;      if (c < *p) return !negated;
3030      if ((unsigned int)c == *p++) return negated;      if (c == *p++) return negated;
3031      }      }
3032    break;  /* Control never reaches here */    break;  /* Control never reaches here */
3033  #endif  #endif
# Line 3067  if ((options & PCRE_EXTENDED) != 0) Line 3076  if ((options & PCRE_EXTENDED) != 0)
3076      if (*ptr == CHAR_NUMBER_SIGN)      if (*ptr == CHAR_NUMBER_SIGN)
3077        {        {
3078        ptr++;        ptr++;
3079        while (*ptr != 0)        while (*ptr != CHAR_NULL)
3080          {          {
3081          if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }          if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }
3082          ptr++;          ptr++;
# Line 3086  value is a character, a negative value i Line 3095  value is a character, a negative value i
3095  if (*ptr == CHAR_BACKSLASH)  if (*ptr == CHAR_BACKSLASH)
3096    {    {
3097    int temperrorcode = 0;    int temperrorcode = 0;
3098    escape = check_escape(&ptr, &next, &temperrorcode, cd->bracount, options, FALSE);    escape = check_escape(&ptr, &next, &temperrorcode, cd->bracount, options,
3099        FALSE);
3100    if (temperrorcode != 0) return FALSE;    if (temperrorcode != 0) return FALSE;
3101    ptr++;    /* Point after the escape sequence */    ptr++;    /* Point after the escape sequence */
3102    }    }
# Line 3110  if ((options & PCRE_EXTENDED) != 0) Line 3120  if ((options & PCRE_EXTENDED) != 0)
3120      if (*ptr == CHAR_NUMBER_SIGN)      if (*ptr == CHAR_NUMBER_SIGN)
3121        {        {
3122        ptr++;        ptr++;
3123        while (*ptr != 0)        while (*ptr != CHAR_NULL)
3124          {          {
3125          if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }          if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }
3126          ptr++;          ptr++;
# Line 3131  if (*ptr == CHAR_ASTERISK || *ptr == CHA Line 3141  if (*ptr == CHAR_ASTERISK || *ptr == CHA
3141    
3142  /* If the previous item is a character, get its value. */  /* If the previous item is a character, get its value. */
3143    
3144  if (op_code == OP_CHAR || op_code == OP_CHARI ||  if (op_code == OP_CHAR || op_code == OP_CHARI ||
3145      op_code == OP_NOT || op_code == OP_NOTI)      op_code == OP_NOT || op_code == OP_NOTI)
   //if (escape == 0) switch(op_code)  
3146    {    {
3147  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3148    GETCHARTEST(c, previous);    GETCHARTEST(c, previous);
# Line 3149  if (escape == 0) Line 3158  if (escape == 0)
3158    {    {
3159    /* For a caseless UTF match, the next character may have more than one other    /* For a caseless UTF match, the next character may have more than one other
3160    case, which maps to the special PT_CLIST property. Check this first. */    case, which maps to the special PT_CLIST property. Check this first. */
3161    
3162  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3163    if (utf && c != NOTACHAR && (options & PCRE_CASELESS) != 0)    if (utf && c != NOTACHAR && (options & PCRE_CASELESS) != 0)
3164      {      {
3165      int ocs = UCD_CASESET(next);      unsigned int ocs = UCD_CASESET(next);
3166      if (ocs > 0) return check_char_prop(c, PT_CLIST, ocs, op_code >= OP_NOT);      if (ocs > 0) return check_char_prop(c, PT_CLIST, ocs, op_code >= OP_NOT);
3167      }      }
3168  #endif  #endif
# Line 3165  if (escape == 0) Line 3174  if (escape == 0)
3174    
3175      /* For CHARI (caseless character) we must check the other case. If we have      /* For CHARI (caseless character) we must check the other case. If we have
3176      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
3177      high-valued characters. We know that next can have only one other case,      high-valued characters. We know that next can have only one other case,
3178      because multi-other-case characters are dealt with above. */      because multi-other-case characters are dealt with above. */
3179    
3180      case OP_CHARI:      case OP_CHARI:
# Line 3185  if (escape == 0) Line 3194  if (escape == 0)
3194      else      else
3195  #endif  /* SUPPORT_UTF */  #endif  /* SUPPORT_UTF */
3196      return (c != TABLE_GET(next, cd->fcc, next));  /* Not UTF */      return (c != TABLE_GET(next, cd->fcc, next));  /* Not UTF */
3197    
3198      case OP_NOT:      case OP_NOT:
3199      return c == next;      return c == next;
3200    
3201      case OP_NOTI:      case OP_NOTI:
3202      if (c == next) return TRUE;      if (c == next) return TRUE;
3203  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
# Line 3232  if (escape == 0) Line 3241  if (escape == 0)
3241      case OP_NOT_HSPACE:      case OP_NOT_HSPACE:
3242      switch(next)      switch(next)
3243        {        {
3244        HSPACE_CASES:        HSPACE_CASES:
3245        return op_code == OP_NOT_HSPACE;        return op_code == OP_NOT_HSPACE;
3246    
3247        default:        default:
# Line 3244  if (escape == 0) Line 3253  if (escape == 0)
3253      case OP_NOT_VSPACE:      case OP_NOT_VSPACE:
3254      switch(next)      switch(next)
3255        {        {
3256        VSPACE_CASES:        VSPACE_CASES:
3257        return op_code == OP_NOT_VSPACE;        return op_code == OP_NOT_VSPACE;
3258    
3259        default:        default:
# Line 3253  if (escape == 0) Line 3262  if (escape == 0)
3262    
3263  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3264      case OP_PROP:      case OP_PROP:
3265      return check_char_prop(next, (int)previous[0], (int)previous[1], FALSE);      return check_char_prop(next, previous[0], previous[1], FALSE);
3266    
3267      case OP_NOTPROP:      case OP_NOTPROP:
3268      return check_char_prop(next, (int)previous[0], (int)previous[1], TRUE);      return check_char_prop(next, previous[0], previous[1], TRUE);
3269  #endif  #endif
3270    
3271      default:      default:
# Line 3298  switch(op_code) Line 3307  switch(op_code)
3307      case ESC_H:      case ESC_H:
3308      switch(c)      switch(c)
3309        {        {
3310        HSPACE_CASES:        HSPACE_CASES:
3311        return escape != ESC_h;        return escape != ESC_h;
3312    
3313        default:        default:
3314        return escape == ESC_h;        return escape == ESC_h;
3315        }        }
# Line 3309  switch(op_code) Line 3318  switch(op_code)
3318      case ESC_V:      case ESC_V:
3319      switch(c)      switch(c)
3320        {        {
3321        VSPACE_CASES:        VSPACE_CASES:
3322        return escape != ESC_v;        return escape != ESC_v;
3323    
3324        default:        default:
# Line 3339  switch(op_code) Line 3348  switch(op_code)
3348      case ESC_p:      case ESC_p:
3349      case ESC_P:      case ESC_P:
3350        {        {
3351        int ptype, pdata, errorcodeptr;        unsigned int ptype = 0, pdata = 0;
3352          int errorcodeptr;
3353        BOOL negated;        BOOL negated;
3354    
3355        ptr--;      /* Make ptr point at the p or P */        ptr--;      /* Make ptr point at the p or P */
3356        ptype = get_ucp(&ptr, &negated, &pdata, &errorcodeptr);        if (!get_ucp(&ptr, &negated, &ptype, &pdata, &errorcodeptr))
3357        if (ptype < 0) return FALSE;          return FALSE;
3358        ptr++;      /* Point past the final curly ket */        ptr++;      /* Point past the final curly ket */
3359    
3360        /* 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
# Line 3420  switch(op_code) Line 3430  switch(op_code)
3430  *************************************************/  *************************************************/
3431    
3432  /* This function packages up the logic of adding a character or range of  /* This function packages up the logic of adding a character or range of
3433  characters to a class. The character values in the arguments will be within the  characters to a class. The character values in the arguments will be within the
3434  valid values for the current mode (8-bit, 16-bit, UTF, etc). This function is  valid values for the current mode (8-bit, 16-bit, UTF, etc). This function is
3435  mutually recursive with the function immediately below.  mutually recursive with the function immediately below.
3436    
3437  Arguments:  Arguments:
3438    classbits     the bit map for characters < 256    classbits     the bit map for characters < 256
3439    uchardptr     points to the pointer for extra data    uchardptr     points to the pointer for extra data
3440    options       the options word    options       the options word
3441    cd            contains pointers to tables etc.    cd            contains pointers to tables etc.
3442    start         start of range character    start         start of range character
3443    end           end of range character    end           end of range character
3444    
3445  Returns:        the number of < 256 characters added  Returns:        the number of < 256 characters added
3446                  the pointer to extra data is updated                  the pointer to extra data is updated
3447  */  */
# Line 3443  add_to_class(pcre_uint8 *classbits, pcre Line 3453  add_to_class(pcre_uint8 *classbits, pcre
3453  pcre_uint32 c;  pcre_uint32 c;
3454  int n8 = 0;  int n8 = 0;
3455    
3456  /* If caseless matching is required, scan the range and process alternate  /* If caseless matching is required, scan the range and process alternate
3457  cases. In Unicode, there are 8-bit characters that have alternate cases that  cases. In Unicode, there are 8-bit characters that have alternate cases that
3458  are greater than 255 and vice-versa. Sometimes we can just extend the original  are greater than 255 and vice-versa. Sometimes we can just extend the original
3459  range. */  range. */
3460    
3461  if ((options & PCRE_CASELESS) != 0)  if ((options & PCRE_CASELESS) != 0)
3462    {    {
3463  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3464    if ((options & PCRE_UTF8) != 0)    if ((options & PCRE_UTF8) != 0)
3465      {      {
3466      int rc;      int rc;
3467      pcre_uint32 oc, od;      pcre_uint32 oc, od;
3468    
3469      options &= ~PCRE_CASELESS;   /* Remove for recursive calls */      options &= ~PCRE_CASELESS;   /* Remove for recursive calls */
3470      c = start;      c = start;
3471    
3472      while ((rc = get_othercase_range(&c, end, &oc, &od)) >= 0)      while ((rc = get_othercase_range(&c, end, &oc, &od)) >= 0)
3473        {        {
3474        /* Handle a single character that has more than one other case. */        /* Handle a single character that has more than one other case. */
3475    
3476        if (rc > 0) n8 += add_list_to_class(classbits, uchardptr, options, cd,        if (rc > 0) n8 += add_list_to_class(classbits, uchardptr, options, cd,
3477          PRIV(ucd_caseless_sets) + rc, oc);          PRIV(ucd_caseless_sets) + rc, oc);
3478    
3479        /* Do nothing if the other case range is within the original range. */        /* Do nothing if the other case range is within the original range. */
3480    
3481        else if (oc >= start && od <= end) continue;        else if (oc >= start && od <= end) continue;
3482    
3483        /* Extend the original range if there is overlap, noting that if oc < c, we        /* Extend the original range if there is overlap, noting that if oc < c, we
3484        can't have od > end because a subrange is always shorter than the basic        can't have od > end because a subrange is always shorter than the basic
3485        range. Otherwise, use a recursive call to add the additional range. */        range. Otherwise, use a recursive call to add the additional range. */
3486    
3487        else if (oc < start && od >= start - 1) start = oc; /* Extend downwards */        else if (oc < start && od >= start - 1) start = oc; /* Extend downwards */
3488        else if (od > end && oc <= end + 1) end = od;       /* Extend upwards */        else if (od > end && oc <= end + 1) end = od;       /* Extend upwards */
3489        else n8 += add_to_class(classbits, uchardptr, options, cd, oc, od);        else n8 += add_to_class(classbits, uchardptr, options, cd, oc, od);
# Line 3483  if ((options & PCRE_CASELESS) != 0) Line 3493  if ((options & PCRE_CASELESS) != 0)
3493  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
3494    
3495    /* Not UTF-mode, or no UCP */    /* Not UTF-mode, or no UCP */
3496    
3497    for (c = start; c <= end && c < 256; c++)    for (c = start; c <= end && c < 256; c++)
3498      {      {
3499      SETBIT(classbits, cd->fcc[c]);      SETBIT(classbits, cd->fcc[c]);
3500      n8++;      n8++;
3501      }      }
3502    }    }
3503    
3504  /* Now handle the original range. Adjust the final value according to the bit  /* Now handle the original range. Adjust the final value according to the bit
3505  length - this means that the same lists of (e.g.) horizontal spaces can be used  length - this means that the same lists of (e.g.) horizontal spaces can be used
3506  in all cases. */  in all cases. */
# Line 3516  if (end < 0x100) Line 3526  if (end < 0x100)
3526    {    {
3527    for (c = start; c <= end; c++)    for (c = start; c <= end; c++)
3528      {      {
3529      n8++;      n8++;
3530      SETBIT(classbits, c);      SETBIT(classbits, c);
3531      }      }
3532    }    }
3533    
3534  else  else
3535    {    {
3536    pcre_uchar *uchardata = *uchardptr;    pcre_uchar *uchardata = *uchardptr;
3537    
3538  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3539    if ((options & PCRE_UTF8) != 0)  /* All UTFs use the same flag bit */    if ((options & PCRE_UTF8) != 0)  /* All UTFs use the same flag bit */
3540      {      {
3541      if (start < end)      if (start < end)
3542        {        {
3543        *uchardata++ = XCL_RANGE;        *uchardata++ = XCL_RANGE;
3544        uchardata += PRIV(ord2utf)(start, uchardata);        uchardata += PRIV(ord2utf)(start, uchardata);
3545        uchardata += PRIV(ord2utf)(end, uchardata);        uchardata += PRIV(ord2utf)(end, uchardata);
3546        }        }
3547      else if (start == end)      else if (start == end)
3548        {        {
3549        *uchardata++ = XCL_SINGLE;        *uchardata++ = XCL_SINGLE;
3550        uchardata += PRIV(ord2utf)(start, uchardata);        uchardata += PRIV(ord2utf)(start, uchardata);
3551        }        }
3552      }      }
3553    else    else
3554  #endif  /* SUPPORT_UTF */  #endif  /* SUPPORT_UTF */
3555    
3556    /* Without UTF support, character values are constrained by the bit length,    /* Without UTF support, character values are constrained by the bit length,
3557    and can only be > 256 for 16-bit and 32-bit libraries. */    and can only be > 256 for 16-bit and 32-bit libraries. */
3558    
3559  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
3560      {}      {}
3561  #else  #else
3562    if (start < end)    if (start < end)
3563      {      {
3564      *uchardata++ = XCL_RANGE;      *uchardata++ = XCL_RANGE;
# Line 3559  else Line 3569  else
3569      {      {
3570      *uchardata++ = XCL_SINGLE;      *uchardata++ = XCL_SINGLE;
3571      *uchardata++ = start;      *uchardata++ = start;
3572      }      }
3573  #endif  #endif
3574    
3575    *uchardptr = uchardata;   /* Updata extra data pointer */    *uchardptr = uchardata;   /* Updata extra data pointer */
3576    }    }
3577    
3578  return n8;    /* Number of 8-bit characters */  return n8;    /* Number of 8-bit characters */
3579  }  }
3580    
3581    
3582    
3583    
3584  /*************************************************  /*************************************************
3585  *        Add a list of characters to a class     *  *        Add a list of characters to a class     *
3586  *************************************************/  *************************************************/
3587    
3588  /* This function is used for adding a list of case-equivalent characters to a  /* This function is used for adding a list of case-equivalent characters to a
3589  class, and also for adding a list of horizontal or vertical whitespace. If the  class, and also for adding a list of horizontal or vertical whitespace. If the
3590  list is in order (which it should be), ranges of characters are detected and  list is in order (which it should be), ranges of characters are detected and
3591  handled appropriately. This function is mutually recursive with the function  handled appropriately. This function is mutually recursive with the function
# Line 3585  Arguments: Line 3595  Arguments:
3595    classbits     the bit map for characters < 256    classbits     the bit map for characters < 256
3596    uchardptr     points to the pointer for extra data    uchardptr     points to the pointer for extra data
3597    options       the options word    options       the options word
3598    cd            contains pointers to tables etc.    cd            contains pointers to tables etc.
3599    p             points to row of 32-bit values, terminated by NOTACHAR    p             points to row of 32-bit values, terminated by NOTACHAR
3600    except        character to omit; this is used when adding lists of    except        character to omit; this is used when adding lists of
3601                    case-equivalent characters to avoid including the one we                    case-equivalent characters to avoid including the one we
3602                    already know about                    already know about
3603    
3604  Returns:        the number of < 256 characters added  Returns:        the number of < 256 characters added
3605                  the pointer to extra data is updated                  the pointer to extra data is updated
3606  */  */
# Line 3604  while (p[0] < NOTACHAR) Line 3614  while (p[0] < NOTACHAR)
3614    {    {
3615    int n = 0;    int n = 0;
3616    if (p[0] != except)    if (p[0] != except)
3617      {      {
3618      while(p[n+1] == p[0] + n + 1) n++;      while(p[n+1] == p[0] + n + 1) n++;
3619      n8 += add_to_class(classbits, uchardptr, options, cd, p[0], p[n]);      n8 += add_to_class(classbits, uchardptr, options, cd, p[0], p[n]);
3620      }      }
3621    p += n + 1;    p += n + 1;
3622    }    }
3623  return n8;  return n8;
3624  }  }
3625    
3626    
3627    
# Line 3626  Arguments: Line 3636  Arguments:
3636    classbits     the bit map for characters < 256    classbits     the bit map for characters < 256
3637    uchardptr     points to the pointer for extra data    uchardptr     points to the pointer for extra data
3638    options       the options word    options       the options word
3639    cd            contains pointers to tables etc.    cd            contains pointers to tables etc.
3640    p             points to row of 32-bit values, terminated by NOTACHAR    p             points to row of 32-bit values, terminated by NOTACHAR
3641    
3642  Returns:        the number of < 256 characters added  Returns:        the number of < 256 characters added
3643                  the pointer to extra data is updated                  the pointer to extra data is updated
3644  */  */
3645    
3646  static int  static int
3647  add_not_list_to_class(pcre_uint8 *classbits, pcre_uchar **uchardptr,  add_not_list_to_class(pcre_uint8 *classbits, pcre_uchar **uchardptr,
3648    int options, compile_data *cd, const pcre_uint32 *p)    int options, compile_data *cd, const pcre_uint32 *p)
3649  {  {
3650  BOOL utf = (options & PCRE_UTF8) != 0;  BOOL utf = (options & PCRE_UTF8) != 0;
# Line 3646  while (p[0] < NOTACHAR) Line 3656  while (p[0] < NOTACHAR)
3656    while (p[1] == p[0] + 1) p++;    while (p[1] == p[0] + 1) p++;
3657    n8 += add_to_class(classbits, uchardptr, options, cd, p[0] + 1,    n8 += add_to_class(classbits, uchardptr, options, cd, p[0] + 1,
3658      (p[1] == NOTACHAR) ? (utf ? 0x10ffffu : 0xffffffffu) : p[1] - 1);      (p[1] == NOTACHAR) ? (utf ? 0x10ffffu : 0xffffffffu) : p[1] - 1);
3659    p++;    p++;
3660    }    }
3661  return n8;  return n8;
3662  }  }
3663    
3664    
3665    
# Line 3725  dynamically as we process the pattern. * Line 3735  dynamically as we process the pattern. *
3735  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3736  /* PCRE_UTF[16|32] have the same value as PCRE_UTF8. */  /* PCRE_UTF[16|32] have the same value as PCRE_UTF8. */
3737  BOOL utf = (options & PCRE_UTF8) != 0;  BOOL utf = (options & PCRE_UTF8) != 0;
3738    #ifndef COMPILE_PCRE32
3739  pcre_uchar utf_chars[6];  pcre_uchar utf_chars[6];
3740    #endif
3741  #else  #else
3742  BOOL utf = FALSE;  BOOL utf = FALSE;
3743  #endif  #endif
3744    
3745  /* Helper variables for OP_XCLASS opcode (for characters > 255). We define  /* Helper variables for OP_XCLASS opcode (for characters > 255). We define
3746  class_uchardata always so that it can be passed to add_to_class() always,  class_uchardata always so that it can be passed to add_to_class() always,
3747  though it will not be used in non-UTF 8-bit cases. This avoids having to supply  though it will not be used in non-UTF 8-bit cases. This avoids having to supply
3748  alternative calls for the different cases. */  alternative calls for the different cases. */
3749    
3750  pcre_uchar *class_uchardata;  pcre_uchar *class_uchardata;
# Line 3790  for (;; ptr++) Line 3802  for (;; ptr++)
3802    pcre_uint32 subreqchar, subfirstchar;    pcre_uint32 subreqchar, subfirstchar;
3803    pcre_int32 subreqcharflags, subfirstcharflags;    pcre_int32 subreqcharflags, subfirstcharflags;
3804    int terminator;    int terminator;
3805    int mclength;    unsigned int mclength;
3806    int tempbracount;    unsigned int tempbracount;
3807    pcre_uint32 ec;    pcre_uint32 ec;
3808    pcre_uchar mcbuffer[8];    pcre_uchar mcbuffer[8];
3809    
# Line 3802  for (;; ptr++) Line 3814  for (;; ptr++)
3814    /* 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
3815    string. Nesting only happens one level deep. */    string. Nesting only happens one level deep. */
3816    
3817    if (c == 0 && nestptr != NULL)    if (c == CHAR_NULL && nestptr != NULL)
3818      {      {
3819      ptr = nestptr;      ptr = nestptr;
3820      nestptr = NULL;      nestptr = NULL;
# Line 3877  for (;; ptr++) Line 3889  for (;; ptr++)
3889    
3890    /* If in \Q...\E, check for the end; if not, we have a literal */    /* If in \Q...\E, check for the end; if not, we have a literal */
3891    
3892    if (inescq && c != 0)    if (inescq && c != CHAR_NULL)
3893      {      {
3894      if (c == CHAR_BACKSLASH && ptr[1] == CHAR_E)      if (c == CHAR_BACKSLASH && ptr[1] == CHAR_E)
3895        {        {
# Line 3925  for (;; ptr++) Line 3937  for (;; ptr++)
3937      if (c == CHAR_NUMBER_SIGN)      if (c == CHAR_NUMBER_SIGN)
3938        {        {
3939        ptr++;        ptr++;
3940        while (*ptr != 0)        while (*ptr != CHAR_NULL)
3941          {          {
3942          if (IS_NEWLINE(ptr)) { ptr += cd->nllen - 1; break; }          if (IS_NEWLINE(ptr)) { ptr += cd->nllen - 1; break; }
3943          ptr++;          ptr++;
# Line 3933  for (;; ptr++) Line 3945  for (;; ptr++)
3945          if (utf) FORWARDCHAR(ptr);          if (utf) FORWARDCHAR(ptr);
3946  #endif  #endif
3947          }          }
3948        if (*ptr != 0) continue;        if (*ptr != CHAR_NULL) continue;
3949    
3950        /* Else fall through to handle end of string */        /* Else fall through to handle end of string */
3951        c = 0;        c = 0;
# Line 4111  for (;; ptr++) Line 4123  for (;; ptr++)
4123      means that an initial ] is taken as a data character. At the start of the      means that an initial ] is taken as a data character. At the start of the
4124      loop, c contains the first byte of the character. */      loop, c contains the first byte of the character. */
4125    
4126      if (c != 0) do      if (c != CHAR_NULL) do
4127        {        {
4128        const pcre_uchar *oldptr;        const pcre_uchar *oldptr;
4129    
# Line 4126  for (;; ptr++) Line 4138  for (;; ptr++)
4138        /* In the pre-compile phase, accumulate the length of any extra        /* In the pre-compile phase, accumulate the length of any extra
4139        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
4140        contain a zillion > 255 characters no longer overwrite the work space        contain a zillion > 255 characters no longer overwrite the work space
4141        (which is on the stack). We have to remember that there was XCLASS data,        (which is on the stack). We have to remember that there was XCLASS data,
4142        however. */        however. */
4143    
4144        if (lengthptr != NULL && class_uchardata > class_uchardata_base)        if (lengthptr != NULL && class_uchardata > class_uchardata_base)
# Line 4190  for (;; ptr++) Line 4202  for (;; ptr++)
4202          alpha. This relies on the fact that the class table starts with          alpha. This relies on the fact that the class table starts with
4203          alpha, lower, upper as the first 3 entries. */          alpha, lower, upper as the first 3 entries. */
4204    
4205          if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)          if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)
4206            posix_class = 0;            posix_class = 0;
4207    
4208          /* 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
# Line 4267  for (;; ptr++) Line 4279  for (;; ptr++)
4279    
4280        if (c == CHAR_BACKSLASH)        if (c == CHAR_BACKSLASH)
4281          {          {
4282          escape = check_escape(&ptr, &ec, errorcodeptr, cd->bracount, options, TRUE);          escape = check_escape(&ptr, &ec, errorcodeptr, cd->bracount, options,
4283              TRUE);
4284          if (*errorcodeptr != 0) goto FAILED;          if (*errorcodeptr != 0) goto FAILED;
4285            if (escape == 0) c = ec;
         if (escape == 0)  
           c = ec;  
4286          else if (escape == ESC_b) c = CHAR_BS; /* \b is backspace in a class */          else if (escape == ESC_b) c = CHAR_BS; /* \b is backspace in a class */
4287          else if (escape == ESC_N)            /* \N is not supported in a class */          else if (escape == ESC_N)          /* \N is not supported in a class */
4288            {            {
4289            *errorcodeptr = ERR71;            *errorcodeptr = ERR71;
4290            goto FAILED;            goto FAILED;
# Line 4346  for (;; ptr++) Line 4356  for (;; ptr++)
4356              for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_space];              for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_space];
4357              classbits[1] |= 0x08;    /* Perl 5.004 onwards omits VT from \s */              classbits[1] |= 0x08;    /* Perl 5.004 onwards omits VT from \s */
4358              continue;              continue;
4359    
4360              /* The rest apply in both UCP and non-UCP cases. */              /* The rest apply in both UCP and non-UCP cases. */
4361    
4362              case ESC_h:              case ESC_h:
4363              (void)add_list_to_class(classbits, &class_uchardata, options, cd,              (void)add_list_to_class(classbits, &class_uchardata, options, cd,
4364                PRIV(hspace_list), NOTACHAR);                PRIV(hspace_list), NOTACHAR);
4365              continue;              continue;
4366    
4367              case ESC_H:              case ESC_H:
4368              (void)add_not_list_to_class(classbits, &class_uchardata, options,              (void)add_not_list_to_class(classbits, &class_uchardata, options,
4369                cd, PRIV(hspace_list));                cd, PRIV(hspace_list));
4370              continue;              continue;
4371    
4372              case ESC_v:              case ESC_v:
4373              (void)add_list_to_class(classbits, &class_uchardata, options, cd,              (void)add_list_to_class(classbits, &class_uchardata, options, cd,
4374                PRIV(vspace_list), NOTACHAR);                PRIV(vspace_list), NOTACHAR);
4375              continue;              continue;
4376    
4377              case ESC_V:              case ESC_V:
4378              (void)add_not_list_to_class(classbits, &class_uchardata, options,              (void)add_not_list_to_class(classbits, &class_uchardata, options,
4379                cd, PRIV(vspace_list));                cd, PRIV(vspace_list));
4380              continue;              continue;
4381    
4382  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 4374  for (;; ptr++) Line 4384  for (;; ptr++)
4384              case ESC_P:              case ESC_P:
4385                {                {
4386                BOOL negated;                BOOL negated;
4387                int pdata;                unsigned int ptype = 0, pdata = 0;
4388                int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr);                if (!get_ucp(&ptr, &negated, &ptype, &pdata, errorcodeptr))
4389                if (ptype < 0) goto FAILED;                  goto FAILED;
4390                *class_uchardata++ = ((escape == ESC_p) != negated)?                *class_uchardata++ = ((escape == ESC_p) != negated)?
4391                  XCL_PROP : XCL_NOTPROP;                  XCL_PROP : XCL_NOTPROP;
4392                *class_uchardata++ = ptype;                *class_uchardata++ = ptype;
# Line 4404  for (;; ptr++) Line 4414  for (;; ptr++)
4414    
4415          /* Fall through if the escape just defined a single character (c >= 0).          /* Fall through if the escape just defined a single character (c >= 0).
4416          This may be greater than 256. */          This may be greater than 256. */
4417    
4418          escape = 0;          escape = 0;
4419    
4420          }   /* End of backslash handling */          }   /* End of backslash handling */
# Line 4445  for (;; ptr++) Line 4455  for (;; ptr++)
4455            inescq = TRUE;            inescq = TRUE;
4456            break;            break;
4457            }            }
4458    
4459          /* Minus (hyphen) at the end of a class is treated as a literal, so put          /* Minus (hyphen) at the end of a class is treated as a literal, so put
4460          back the pointer and jump to handle the character that preceded it. */          back the pointer and jump to handle the character that preceded it. */
4461    
4462          if (*ptr == 0 || (!inescq && *ptr == CHAR_RIGHT_SQUARE_BRACKET))          if (*ptr == CHAR_NULL || (!inescq && *ptr == CHAR_RIGHT_SQUARE_BRACKET))
4463            {            {
4464            ptr = oldptr;            ptr = oldptr;
4465            goto CLASS_SINGLE_CHARACTER;            goto CLASS_SINGLE_CHARACTER;
4466            }            }
4467    
4468          /* Otherwise, we have a potential range; pick up the next character */          /* Otherwise, we have a potential range; pick up the next character */
4469    
4470  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
# Line 4501  for (;; ptr++) Line 4511  for (;; ptr++)
4511          /* We have found a character range, so single character optimizations          /* We have found a character range, so single character optimizations
4512          cannot be done anymore. Any value greater than 1 indicates that there          cannot be done anymore. Any value greater than 1 indicates that there
4513          is more than one character. */          is more than one character. */
4514    
4515          class_one_char = 2;          class_one_char = 2;
4516    
4517          /* Remember an explicit \r or \n, and add the range to the class. */          /* Remember an explicit \r or \n, and add the range to the class. */
4518    
4519          if (d == CHAR_CR || d == CHAR_NL) cd->external_flags |= PCRE_HASCRORLF;          if (d == CHAR_CR || d == CHAR_NL) cd->external_flags |= PCRE_HASCRORLF;
4520    
4521          class_has_8bitchar +=          class_has_8bitchar +=
4522            add_to_class(classbits, &class_uchardata, options, cd, c, d);            add_to_class(classbits, &class_uchardata, options, cd, c, d);
4523    
4524          continue;   /* Go get the next char in the class */          continue;   /* Go get the next char in the class */
4525          }          }
4526    
4527        /* Handle a single character - we can get here for a normal non-escape        /* Handle a single character - we can get here for a normal non-escape
4528        char, or after \ that introduces a single character or for an apparent        char, or after \ that introduces a single character or for an apparent
4529        range that isn't. Only the value 1 matters for class_one_char, so don't        range that isn't. Only the value 1 matters for class_one_char, so don't
4530        increase it if it is already 2 or more ... just in case there's a class        increase it if it is already 2 or more ... just in case there's a class
4531        with a zillion characters in it. */        with a zillion characters in it. */
4532    
4533        CLASS_SINGLE_CHARACTER:        CLASS_SINGLE_CHARACTER:
# Line 4540  for (;; ptr++) Line 4550  for (;; ptr++)
4550    
4551          if (negate_class)          if (negate_class)
4552            {            {
4553  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
4554            int d;            int d;
4555  #endif  #endif
4556            if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;            if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
4557            zerofirstchar = firstchar;            zerofirstchar = firstchar;
4558            zerofirstcharflags = firstcharflags;            zerofirstcharflags = firstcharflags;
# Line 4550  for (;; ptr++) Line 4560  for (;; ptr++)
4560            /* For caseless UTF-8 mode when UCP support is available, check            /* For caseless UTF-8 mode when UCP support is available, check
4561            whether this character has more than one other case. If so, generate            whether this character has more than one other case. If so, generate
4562            a special OP_NOTPROP item instead of OP_NOTI. */            a special OP_NOTPROP item instead of OP_NOTI. */
4563    
4564  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
4565            if (utf && (options & PCRE_CASELESS) != 0 &&            if (utf && (options & PCRE_CASELESS) != 0 &&
4566                (d = UCD_CASESET(c)) != 0)                (d = UCD_CASESET(c)) != 0)
4567              {              {
4568              *code++ = OP_NOTPROP;              *code++ = OP_NOTPROP;
4569              *code++ = PT_CLIST;              *code++ = PT_CLIST;
4570              *code++ = d;              *code++ = d;
4571              }              }
4572            else            else
4573  #endif  #endif
4574            /* Char has only one other case, or UCP not available */            /* Char has only one other case, or UCP not available */
4575    
# Line 4572  for (;; ptr++) Line 4582  for (;; ptr++)
4582  #endif  #endif
4583                *code++ = c;                *code++ = c;
4584              }              }
4585    
4586            /* We are finished with this character class */            /* We are finished with this character class */
4587    
4588            goto END_CLASS;            goto END_CLASS;
4589            }            }
4590    
# Line 4592  for (;; ptr++) Line 4602  for (;; ptr++)
4602            }            }
4603          goto ONE_CHAR;          goto ONE_CHAR;
4604          }       /* End of 1-char optimization */          }       /* End of 1-char optimization */
4605    
4606        /* There is more than one character in the class, or an XCLASS item        /* There is more than one character in the class, or an XCLASS item
4607        has been generated. Add this character to the class. */        has been generated. Add this character to the class. */
4608    
4609        class_has_8bitchar +=        class_has_8bitchar +=
4610          add_to_class(classbits, &class_uchardata, options, cd, c, c);          add_to_class(classbits, &class_uchardata, options, cd, c, c);
4611        }        }
4612    
# Line 4604  for (;; ptr++) Line 4614  for (;; ptr++)
4614      If we are at the end of an internal nested string, revert to the outer      If we are at the end of an internal nested string, revert to the outer
4615      string. */      string. */
4616    
4617      while (((c = *(++ptr)) != 0 ||      while (((c = *(++ptr)) != CHAR_NULL ||
4618             (nestptr != NULL &&             (nestptr != NULL &&
4619               (ptr = nestptr, nestptr = NULL, c = *(++ptr)) != 0)) &&               (ptr = nestptr, nestptr = NULL, c = *(++ptr)) != CHAR_NULL)) &&
4620             (c != CHAR_RIGHT_SQUARE_BRACKET || inescq));             (c != CHAR_RIGHT_SQUARE_BRACKET || inescq));
4621    
4622      /* Check for missing terminating ']' */      /* Check for missing terminating ']' */
4623    
4624      if (c == 0)      if (c == CHAR_NULL)
4625        {        {
4626        *errorcodeptr = ERR6;        *errorcodeptr = ERR6;
4627        goto FAILED;        goto FAILED;
4628        }        }
4629    
4630      /* We will need an XCLASS if data has been placed in class_uchardata. In      /* We will need an XCLASS if data has been placed in class_uchardata. In
4631      the second phase this is a sufficient test. However, in the pre-compile      the second phase this is a sufficient test. However, in the pre-compile
4632      phase, class_uchardata gets emptied to prevent workspace overflow, so it      phase, class_uchardata gets emptied to prevent workspace overflow, so it
4633      only if the very last character in the class needs XCLASS will it contain      only if the very last character in the class needs XCLASS will it contain
4634      anything at this point. For this reason, xclass gets set TRUE above when      anything at this point. For this reason, xclass gets set TRUE above when
4635      uchar_classdata is emptied, and that's why this code is the way it is here      uchar_classdata is emptied, and that's why this code is the way it is here
4636      instead of just doing a test on class_uchardata below. */      instead of just doing a test on class_uchardata below. */
4637    
4638  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
4639      if (class_uchardata > class_uchardata_base) xclass = TRUE;      if (class_uchardata > class_uchardata_base) xclass = TRUE;
4640  #endif  #endif
# Line 4693  for (;; ptr++) Line 4703  for (;; ptr++)
4703        memcpy(code, classbits, 32);        memcpy(code, classbits, 32);
4704        }        }
4705      code += 32 / sizeof(pcre_uchar);      code += 32 / sizeof(pcre_uchar);
4706    
4707      END_CLASS:      END_CLASS:
4708      break;      break;
4709    
# Line 4897  for (;; ptr++) Line 4907  for (;; ptr++)
4907    
4908        if (repeat_max == 0) goto END_REPEAT;        if (repeat_max == 0) goto END_REPEAT;
4909    
       /*--------------------------------------------------------------------*/  
       /* This code is obsolete from release 8.00; the restriction was finally  
       removed: */  
   
       /* All real repeats make it impossible to handle partial matching (maybe  
       one day we will be able to remove this restriction). */  
   
       /* if (repeat_max != 1) cd->external_flags |= PCRE_NOPARTIAL; */  
       /*--------------------------------------------------------------------*/  
   
4910        /* Combine the op_type with the repeat_type */        /* Combine the op_type with the repeat_type */
4911    
4912        repeat_type += op_type;        repeat_type += op_type;
# Line 5053  for (;; ptr++) Line 5053  for (;; ptr++)
5053          goto END_REPEAT;          goto END_REPEAT;
5054          }          }
5055    
       /*--------------------------------------------------------------------*/  
       /* This code is obsolete from release 8.00; the restriction was finally  
       removed: */  
   
       /* All real repeats make it impossible to handle partial matching (maybe  
       one day we will be able to remove this restriction). */  
   
       /* if (repeat_max != 1) cd->external_flags |= PCRE_NOPARTIAL; */  
       /*--------------------------------------------------------------------*/  
   
5056        if (repeat_min == 0 && repeat_max == -1)        if (repeat_min == 0 && repeat_max == -1)
5057          *code++ = OP_CRSTAR + repeat_type;          *code++ = OP_CRSTAR + repeat_type;
5058        else if (repeat_min == 1 && repeat_max == -1)        else if (repeat_min == 1 && repeat_max == -1)
# Line 5601  for (;; ptr++) Line 5591  for (;; ptr++)
5591        if (*ptr == CHAR_COLON)        if (*ptr == CHAR_COLON)
5592          {          {
5593          arg = ++ptr;          arg = ++ptr;
5594          while (*ptr != 0 && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;          while (*ptr != CHAR_NULL && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;
5595          arglen = (int)(ptr - arg);          arglen = (int)(ptr - arg);
5596          if ((unsigned int)arglen > MAX_MARK)          if ((unsigned int)arglen > MAX_MARK)
5597            {            {
# Line 5715  for (;; ptr++) Line 5705  for (;; ptr++)
5705          {          {
5706          case CHAR_NUMBER_SIGN:                 /* Comment; skip to ket */          case CHAR_NUMBER_SIGN:                 /* Comment; skip to ket */
5707          ptr++;          ptr++;
5708          while (*ptr != 0 && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;          while (*ptr != CHAR_NULL && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;
5709          if (*ptr == 0)          if (*ptr == CHAR_NULL)
5710            {            {
5711            *errorcodeptr = ERR18;            *errorcodeptr = ERR18;
5712            goto FAILED;            goto FAILED;
# Line 5792  for (;; ptr++) Line 5782  for (;; ptr++)
5782            }            }
5783          else          else
5784            {            {
5785            terminator = 0;            terminator = CHAR_NULL;
5786            if (ptr[1] == CHAR_MINUS || ptr[1] == CHAR_PLUS) refsign = *(++ptr);            if (ptr[1] == CHAR_MINUS || ptr[1] == CHAR_PLUS) refsign = *(++ptr);
5787            }            }
5788    
# Line 5817  for (;; ptr++) Line 5807  for (;; ptr++)
5807            }            }
5808          namelen = (int)(ptr - name);          namelen = (int)(ptr - name);
5809    
5810          if ((terminator > 0 && *ptr++ != terminator) ||          if ((terminator > 0 && *ptr++ != (pcre_uchar)terminator) ||
5811              *ptr++ != CHAR_RIGHT_PARENTHESIS)              *ptr++ != CHAR_RIGHT_PARENTHESIS)
5812            {            {
5813            ptr--;      /* Error offset */            ptr--;      /* Error offset */
# Line 5882  for (;; ptr++) Line 5872  for (;; ptr++)
5872            code[1+LINK_SIZE]++;            code[1+LINK_SIZE]++;
5873            }            }
5874    
5875          /* If terminator == 0 it means that the name followed directly after          /* If terminator == CHAR_NULL it means that the name followed directly
5876          the opening parenthesis [e.g. (?(abc)...] and in this case there are          after the opening parenthesis [e.g. (?(abc)...] and in this case there
5877          some further alternatives to try. For the cases where terminator != 0          are some further alternatives to try. For the cases where terminator !=
5878          [things like (?(<name>... or (?('name')... or (?(R&name)... ] we have          0 [things like (?(<name>... or (?('name')... or (?(R&name)... ] we have
5879          now checked all the possibilities, so give an error. */          now checked all the possibilities, so give an error. */
5880    
5881          else if (terminator != 0)          else if (terminator != CHAR_NULL)
5882            {            {
5883            *errorcodeptr = ERR15;            *errorcodeptr = ERR15;
5884            goto FAILED;            goto FAILED;
# Line 6057  for (;; ptr++) Line 6047  for (;; ptr++)
6047    
6048            if (lengthptr != NULL)            if (lengthptr != NULL)
6049              {              {
6050              if (*ptr != terminator)              if (*ptr != (pcre_uchar)terminator)
6051                {                {
6052                *errorcodeptr = ERR42;                *errorcodeptr = ERR42;
6053                goto FAILED;                goto FAILED;
# Line 6199  for (;; ptr++) Line 6189  for (;; ptr++)
6189              *errorcodeptr = ERR62;              *errorcodeptr = ERR62;
6190              goto FAILED;              goto FAILED;
6191              }              }
6192            if (*ptr != terminator)            if (*ptr != (pcre_uchar)terminator)
6193              {              {
6194              *errorcodeptr = ERR42;              *errorcodeptr = ERR42;
6195              goto FAILED;              goto FAILED;
# Line 6305  for (;; ptr++) Line 6295  for (;; ptr++)
6295            while(IS_DIGIT(*ptr))            while(IS_DIGIT(*ptr))
6296              recno = recno * 10 + *ptr++ - CHAR_0;              recno = recno * 10 + *ptr++ - CHAR_0;
6297    
6298            if (*ptr != terminator)            if (*ptr != (pcre_uchar)terminator)
6299              {              {
6300              *errorcodeptr = ERR29;              *errorcodeptr = ERR29;
6301              goto FAILED;              goto FAILED;
# Line 6693  for (;; ptr++) Line 6683  for (;; ptr++)
6683        /* If the subpattern set a required byte (or set a first byte that isn't        /* If the subpattern set a required byte (or set a first byte that isn't
6684        really the first byte - see above), set it. */        really the first byte - see above), set it. */
6685    
6686        if (subreqcharflags >= 0)        if (subreqcharflags >= 0)
6687          {          {
6688          reqchar = subreqchar;          reqchar = subreqchar;
6689          reqcharflags = subreqcharflags;          reqcharflags = subreqcharflags;
# Line 6728  for (;; ptr++) Line 6718  for (;; ptr++)
6718      case CHAR_BACKSLASH:      case CHAR_BACKSLASH:
6719      tempptr = ptr;      tempptr = ptr;
6720      escape = check_escape(&ptr, &ec, errorcodeptr, cd->bracount, options, FALSE);      escape = check_escape(&ptr, &ec, errorcodeptr, cd->bracount, options, FALSE);
   
6721      if (*errorcodeptr != 0) goto FAILED;      if (*errorcodeptr != 0) goto FAILED;
6722    
6723      if (escape == 0)      if (escape == 0)                  /* The escape coded a single character */
6724        c = ec;        c = ec;
6725      else      else
6726        {        {
# Line 6785  for (;; ptr++) Line 6774  for (;; ptr++)
6774          if (ptr[1] != CHAR_PLUS && ptr[1] != CHAR_MINUS)          if (ptr[1] != CHAR_PLUS && ptr[1] != CHAR_MINUS)
6775            {            {
6776            BOOL is_a_number = TRUE;            BOOL is_a_number = TRUE;
6777            for (p = ptr + 1; *p != 0 && *p != terminator; p++)            for (p = ptr + 1; *p != CHAR_NULL && *p != (pcre_uchar)terminator; p++)
6778              {              {
6779              if (!MAX_255(*p)) { is_a_number = FALSE; break; }              if (!MAX_255(*p)) { is_a_number = FALSE; break; }
6780              if ((cd->ctypes[*p] & ctype_digit) == 0) is_a_number = FALSE;              if ((cd->ctypes[*p] & ctype_digit) == 0) is_a_number = FALSE;
6781              if ((cd->ctypes[*p] & ctype_word) == 0) break;              if ((cd->ctypes[*p] & ctype_word) == 0) break;
6782              }              }
6783            if (*p != terminator)            if (*p != (pcre_uchar)terminator)
6784              {              {
6785              *errorcodeptr = ERR57;              *errorcodeptr = ERR57;
6786              break;              break;
# Line 6809  for (;; ptr++) Line 6798  for (;; ptr++)
6798    
6799          p = ptr + 2;          p = ptr + 2;
6800          while (IS_DIGIT(*p)) p++;          while (IS_DIGIT(*p)) p++;
6801          if (*p != terminator)          if (*p != (pcre_uchar)terminator)
6802            {            {
6803            *errorcodeptr = ERR57;            *errorcodeptr = ERR57;
6804            break;            break;
# Line 6873  for (;; ptr++) Line 6862  for (;; ptr++)
6862        else if (escape == ESC_P || escape == ESC_p)        else if (escape == ESC_P || escape == ESC_p)
6863          {          {
6864          BOOL negated;          BOOL negated;
6865          int pdata;          unsigned int ptype = 0, pdata = 0;
6866          int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr);          if (!get_ucp(&ptr, &negated, &ptype, &pdata, errorcodeptr))
6867          if (ptype < 0) goto FAILED;            goto FAILED;
6868          previous = code;          previous = code;
6869          *code++ = ((escape == ESC_p) != negated)? OP_PROP : OP_NOTPROP;          *code++ = ((escape == ESC_p) != negated)? OP_PROP : OP_NOTPROP;
6870          *code++ = ptype;          *code++ = ptype;
# Line 6897  for (;; ptr++) Line 6886  for (;; ptr++)
6886        can obtain the OP value by negating the escape value in the default        can obtain the OP value by negating the escape value in the default
6887        situation when PCRE_UCP is not set. When it *is* set, we substitute        situation when PCRE_UCP is not set. When it *is* set, we substitute
6888        Unicode property tests. Note that \b and \B do a one-character        Unicode property tests. Note that \b and \B do a one-character
6889        lookbehind. */        lookbehind, and \A also behaves as if it does. */
6890    
6891        else        else
6892          {          {
6893          if ((escape == ESC_b || escape == ESC_B) && cd->max_lookbehind == 0)          if ((escape == ESC_b || escape == ESC_B || escape == ESC_A) &&
6894                 cd->max_lookbehind == 0)
6895            cd->max_lookbehind = 1;            cd->max_lookbehind = 1;
6896  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
6897          if (escape >= ESC_DU && escape <= ESC_wu)          if (escape >= ESC_DU && escape <= ESC_wu)
# Line 6959  for (;; ptr++) Line 6949  for (;; ptr++)
6949    
6950      ONE_CHAR:      ONE_CHAR:
6951      previous = code;      previous = code;
6952    
6953      /* For caseless UTF-8 mode when UCP support is available, check whether      /* For caseless UTF-8 mode when UCP support is available, check whether
6954      this character has more than one other case. If so, generate a special      this character has more than one other case. If so, generate a special
6955      OP_PROP item instead of OP_CHARI. */      OP_PROP item instead of OP_CHARI. */
6956    
6957  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
6958      if (utf && (options & PCRE_CASELESS) != 0)      if (utf && (options & PCRE_CASELESS) != 0)
6959        {        {
# Line 6973  for (;; ptr++) Line 6963  for (;; ptr++)
6963          *code++ = OP_PROP;          *code++ = OP_PROP;
6964          *code++ = PT_CLIST;          *code++ = PT_CLIST;
6965          *code++ = c;          *code++ = c;
6966          if (firstcharflags == REQ_UNSET) firstcharflags = zerofirstcharflags = REQ_NONE;          if (firstcharflags == REQ_UNSET) firstcharflags = zerofirstcharflags = REQ_NONE;
6967          break;          break;
6968          }          }
6969        }        }
6970  #endif  #endif
6971    
6972      /* Caseful matches, or not one of the multicase characters. */      /* Caseful matches, or not one of the multicase characters. */
6973    
6974      *code++ = ((options & PCRE_CASELESS) != 0)? OP_CHARI : OP_CHAR;      *code++ = ((options & PCRE_CASELESS) != 0)? OP_CHARI : OP_CHAR;
6975      for (c = 0; c < mclength; c++) *code++ = mcbuffer[c];      for (c = 0; c < mclength; c++) *code++ = mcbuffer[c];
6976    
# Line 7102  pcre_int32 firstcharflags, reqcharflags; Line 7092  pcre_int32 firstcharflags, reqcharflags;
7092  pcre_uint32 branchfirstchar, branchreqchar;  pcre_uint32 branchfirstchar, branchreqchar;
7093  pcre_int32 branchfirstcharflags, branchreqcharflags;  pcre_int32 branchfirstcharflags, branchreqcharflags;
7094  int length;  int length;
7095  int orig_bracount;  unsigned int orig_bracount;
7096  int max_bracount;  unsigned int max_bracount;
7097  branch_chain bc;  branch_chain bc;
7098    
7099  bc.outer = bcptr;  bc.outer = bcptr;
# Line 7170  for (;;) Line 7160  for (;;)
7160    into the length. */    into the length. */
7161    
7162    if (!compile_branch(&options, &code, &ptr, errorcodeptr, &branchfirstchar,    if (!compile_branch(&options, &code, &ptr, errorcodeptr, &branchfirstchar,
7163          &branchfirstcharflags, &branchreqchar, &branchreqcharflags, &bc,          &branchfirstcharflags, &branchreqchar, &branchreqcharflags, &bc,
7164          cond_depth, cd, (lengthptr == NULL)? NULL : &length))          cond_depth, cd, (lengthptr == NULL)? NULL : &length))
7165      {      {
7166      *ptrptr = ptr;      *ptrptr = ptr;
# Line 7208  for (;;) Line 7198  for (;;)
7198        we have to abandon the firstchar for the regex, but if there was        we have to abandon the firstchar for the regex, but if there was
7199        previously no reqchar, it takes on the value of the old firstchar. */        previously no reqchar, it takes on the value of the old firstchar. */
7200    
7201        if (firstcharflags >= 0 &&        if (firstcharflags >= 0 &&
7202            (firstcharflags != branchfirstcharflags || firstchar != branchfirstchar))            (firstcharflags != branchfirstcharflags || firstchar != branchfirstchar))
7203          {          {
7204          if (reqcharflags < 0)          if (reqcharflags < 0)
7205            {            {
7206            reqchar = firstchar;            reqchar = firstchar;
7207            reqcharflags = firstcharflags;            reqcharflags = firstcharflags;
# Line 7570  do { Line 7560  do {
7560       {       {
7561       if (!is_startline(scode, bracket_map, cd, atomcount)) return FALSE;       if (!is_startline(scode, bracket_map, cd, atomcount)) return FALSE;
7562       }       }
7563    
7564     /* Atomic brackets */     /* Atomic brackets */
7565    
7566     else if (op == OP_ONCE || op == OP_ONCE_NC)     else if (op == OP_ONCE || op == OP_ONCE_NC)
# Line 7839  while (ptr[skipatstart] == CHAR_LEFT_PAR Line 7829  while (ptr[skipatstart] == CHAR_LEFT_PAR
7829    int newnl = 0;    int newnl = 0;
7830    int newbsr = 0;    int newbsr = 0;
7831    
7832    /* For completeness and backward compatibility, (*UTFn) is supported in the
7833    relevant libraries, but (*UTF) is generic and always supported. Note that
7834    PCRE_UTF8 == PCRE_UTF16 == PCRE_UTF32. */
7835    
7836  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
7837    if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF_RIGHTPAR, 5) == 0)    if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF8_RIGHTPAR, 5) == 0)
7838      { skipatstart += 7; options |= PCRE_UTF8; continue; }      { skipatstart += 7; options |= PCRE_UTF8; continue; }
7839  #endif  #endif
7840  #ifdef COMPILE_PCRE16  #ifdef COMPILE_PCRE16
7841    if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF_RIGHTPAR, 6) == 0)    if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF16_RIGHTPAR, 6) == 0)
7842      { skipatstart += 8; options |= PCRE_UTF16; continue; }      { skipatstart += 8; options |= PCRE_UTF16; continue; }
7843  #endif  #endif
7844  #ifdef COMPILE_PCRE32  #ifdef COMPILE_PCRE32
7845    if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF_RIGHTPAR, 6) == 0)    if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF32_RIGHTPAR, 6) == 0)
7846      { skipatstart += 8; options |= PCRE_UTF32; continue; }      { skipatstart += 8; options |= PCRE_UTF32; continue; }
7847  #endif  #endif
7848    
7849      else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF_RIGHTPAR, 4) == 0)
7850        { skipatstart += 6; options |= PCRE_UTF8; continue; }
7851    else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UCP_RIGHTPAR, 4) == 0)    else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UCP_RIGHTPAR, 4) == 0)
7852      { skipatstart += 6; options |= PCRE_UCP; continue; }      { skipatstart += 6; options |= PCRE_UCP; continue; }
7853    else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_NO_START_OPT_RIGHTPAR, 13) == 0)    else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_NO_START_OPT_RIGHTPAR, 13) == 0)
# Line 8109  if (cd->had_accept) Line 8106  if (cd->had_accept)
8106    
8107  /* If not reached end of pattern on success, there's an excess bracket. */  /* If not reached end of pattern on success, there's an excess bracket. */
8108    
8109  if (errorcode == 0 && *ptr != 0) errorcode = ERR22;  if (errorcode == 0 && *ptr != CHAR_NULL) errorcode = ERR22;
8110    
8111  /* Fill in the terminating state and check for disastrous overflow, but  /* Fill in the terminating state and check for disastrous overflow, but
8112  if debugging, leave the test till after things are printed out. */  if debugging, leave the test till after things are printed out. */
# Line 8120  if debugging, leave the test till after Line 8117  if debugging, leave the test till after
8117  if (code - codestart > length) errorcode = ERR23;  if (code - codestart > length) errorcode = ERR23;
8118  #endif  #endif
8119    
8120    #ifdef SUPPORT_VALGRIND
8121    /* If the estimated length exceeds the really used length, mark the extra
8122    allocated memory as unadressable, so that any out-of-bound reads can be
8123    detected. */
8124    VALGRIND_MAKE_MEM_NOACCESS(code, (length - (code - codestart)) * sizeof(pcre_uchar));
8125    #endif
8126    
8127  /* Fill in any forward references that are required. There may be repeated  /* Fill in any forward references that are required. There may be repeated
8128  references; optimize for them, as searching a large regex takes time. */  references; optimize for them, as searching a large regex takes time. */
8129    

Legend:
Removed from v.1114  
changed lines
  Added in v.1253

  ViewVC Help
Powered by ViewVC 1.1.5