/[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 1045 by ph10, Sun Sep 23 16:50:00 2012 UTC revision 1059 by chpe, Tue Oct 16 15:53:53 2012 UTC
# Line 53  supporting internal functions that are n Line 53  supporting internal functions that are n
53  #include "pcre_internal.h"  #include "pcre_internal.h"
54    
55    
56  /* When PCRE_DEBUG is defined, we need the pcre(16)_printint() function, which  /* When PCRE_DEBUG is defined, we need the pcre(16|32)_printint() function, which
57  is also used by pcretest. PCRE_DEBUG is not defined when building a production  is also used by pcretest. PCRE_DEBUG is not defined when building a production
58  library. We do not need to select pcre16_printint.c specially, because the  library. We do not need to select pcre16_printint.c specially, because the
59  COMPILE_PCREx macro will already be appropriately set. */  COMPILE_PCREx macro will already be appropriately set. */
# Line 123  overrun before it actually does run off Line 123  overrun before it actually does run off
123    
124  #define REQ_CASELESS   0x10000000l      /* Indicates caselessness */  #define REQ_CASELESS   0x10000000l      /* Indicates caselessness */
125  #define REQ_VARY       0x20000000l      /* Reqchar followed non-literal item */  #define REQ_VARY       0x20000000l      /* Reqchar followed non-literal item */
126    #define REQ_MASK       (REQ_CASELESS | REQ_VARY)
127    
128  /* Repeated character flags. */  /* Repeated character flags. */
129    
# Line 503  static const char error_texts[] = Line 504  static const char error_texts[] =
504    /* 75 */    /* 75 */
505    "name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN)\0"    "name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN)\0"
506    "character value in \\u.... sequence is too large\0"    "character value in \\u.... sequence is too large\0"
507      "invalid UTF-32 string\0"
508    ;    ;
509    
510  /* 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 747  return (*p == CHAR_RIGHT_CURLY_BRACKET); Line 749  return (*p == CHAR_RIGHT_CURLY_BRACKET);
749  *************************************************/  *************************************************/
750    
751  /* This function is called when a \ has been encountered. It either returns a  /* This function is called when a \ has been encountered. It either returns a
752  positive value for a simple escape such as \n, or a negative value which  positive value for a simple escape such as \n, or 0 for a data character
753  encodes one of the more complicated things such as \d. A backreference to group  which will be placed in chptr. A backreference to group
754  n is returned as -(ESC_REF + n); ESC_REF is the highest ESC_xxx macro. When  n is returned as ESC_REF + n; ESC_REF is the highest ESC_xxx macro. When
755  UTF-8 is enabled, a positive value greater than 255 may be returned. On entry,  UTF-8 is enabled, a positive value greater than 255 may be returned in chptr.
756  ptr is pointing at the \. On exit, it is on the final character of the escape  On entry,ptr is pointing at the \. On exit, it is on the final character of the
757  sequence.  escape sequence.
758    
759  Arguments:  Arguments:
760    ptrptr         points to the pattern position pointer    ptrptr         points to the pattern position pointer
761      chptr          points to the data character
762    errorcodeptr   points to the errorcode variable    errorcodeptr   points to the errorcode variable
763    bracount       number of previous extracting brackets    bracount       number of previous extracting brackets
764    options        the options bits    options        the options bits
765    isclass        TRUE if inside a character class    isclass        TRUE if inside a character class
766    
767  Returns:         zero or positive => a data character  Returns:         zero => a data character
768                   negative => a special escape sequence                   positive => a special escape sequence
769                   on error, errorcodeptr is set                   on error, errorcodeptr is set
770  */  */
771    
772  static int  static int
773  check_escape(const pcre_uchar **ptrptr, int *errorcodeptr, int bracount,  check_escape(const pcre_uchar **ptrptr, int *chptr, int *errorcodeptr,
774    int options, BOOL isclass)    int bracount, int options, BOOL isclass)
775  {  {
776  /* PCRE_UTF16 has the same value as PCRE_UTF8. */  /* PCRE_UTF16 has the same value as PCRE_UTF8. */
777  BOOL utf = (options & PCRE_UTF8) != 0;  BOOL utf = (options & PCRE_UTF8) != 0;
778  const pcre_uchar *ptr = *ptrptr + 1;  const pcre_uchar *ptr = *ptrptr + 1;
779  pcre_int32 c;  pcre_int32 c;
780    int escape = 0;
781  int i;  int i;
782    
783  GETCHARINCTEST(c, ptr);           /* Get character value, increment pointer */  GETCHARINCTEST(c, ptr);           /* Get character value, increment pointer */
# Line 790  Otherwise further processing may be requ Line 794  Otherwise further processing may be requ
794  #ifndef EBCDIC  /* ASCII/UTF-8 coding */  #ifndef EBCDIC  /* ASCII/UTF-8 coding */
795  /* Not alphanumeric */  /* Not alphanumeric */
796  else if (c < CHAR_0 || c > CHAR_z) {}  else if (c < CHAR_0 || c > CHAR_z) {}
797  else if ((i = escapes[c - CHAR_0]) != 0) c = i;  else if ((i = escapes[c - CHAR_0]) != 0) { if (i > 0) c = i; else escape = -i; }
798    
799  #else           /* EBCDIC coding */  #else           /* EBCDIC coding */
800  /* Not alphanumeric */  /* Not alphanumeric */
801  else if (c < CHAR_a || (!MAX_255(c) || (ebcdic_chartab[c] & 0x0E) == 0)) {}  else if (c < CHAR_a || (!MAX_255(c) || (ebcdic_chartab[c] & 0x0E) == 0)) {}
802  else if ((i = escapes[c - 0x48]) != 0)  c = i;  else if ((i = escapes[c - 0x48]) != 0)  { if (i > 0) c = i; else escape = -i; }
803  #endif  #endif
804    
805  /* Escapes that need further processing, or are illegal. */  /* Escapes that need further processing, or are illegal. */
# Line 838  else Line 842  else
842  #endif  #endif
843            }            }
844    
845  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
846          if (c > (utf ? 0x10ffff : 0xff))          if (c > (utf ? 0x10ffff : 0xff))
847  #else  #elif defined COMPILE_PCRE16
 #ifdef COMPILE_PCRE16  
848          if (c > (utf ? 0x10ffff : 0xffff))          if (c > (utf ? 0x10ffff : 0xffff))
849  #endif  #elif defined COMPILE_PCRE32
850            if (utf && c > 0x10ffff)
851  #endif  #endif
852            {            {
853            *errorcodeptr = ERR76;            *errorcodeptr = ERR76;
# Line 875  else Line 879  else
879      (3) For Oniguruma compatibility we also support \g followed by a name or a      (3) For Oniguruma compatibility we also support \g followed by a name or a
880      number either in angle brackets or in single quotes. However, these are      number either in angle brackets or in single quotes. However, these are
881      (possibly recursive) subroutine calls, _not_ backreferences. Just return      (possibly recursive) subroutine calls, _not_ backreferences. Just return
882      the -ESC_g code (cf \k). */      the ESC_g code (cf \k). */
883    
884      case CHAR_g:      case CHAR_g:
885      if (isclass) break;      if (isclass) break;
886      if (ptr[1] == CHAR_LESS_THAN_SIGN || ptr[1] == CHAR_APOSTROPHE)      if (ptr[1] == CHAR_LESS_THAN_SIGN || ptr[1] == CHAR_APOSTROPHE)
887        {        {
888        c = -ESC_g;        escape = ESC_g;
889        break;        break;
890        }        }
891    
# Line 894  else Line 898  else
898          if (*p != CHAR_MINUS && !IS_DIGIT(*p)) break;          if (*p != CHAR_MINUS && !IS_DIGIT(*p)) break;
899        if (*p != 0 && *p != CHAR_RIGHT_CURLY_BRACKET)        if (*p != 0 && *p != CHAR_RIGHT_CURLY_BRACKET)
900          {          {
901          c = -ESC_k;          escape = ESC_k;
902          break;          break;
903          }          }
904        braced = TRUE;        braced = TRUE;
# Line 950  else Line 954  else
954        c = bracount - (c - 1);        c = bracount - (c - 1);
955        }        }
956    
957      c = -(ESC_REF + c);      escape = ESC_REF + c;
958      break;      break;
959    
960      /* The handling of escape sequences consisting of a string of digits      /* The handling of escape sequences consisting of a string of digits
# Line 991  else Line 995  else
995          }          }
996        if (c < 10 || c <= bracount)        if (c < 10 || c <= bracount)
997          {          {
998          c = -(ESC_REF + c);          escape = ESC_REF + c;
999          break;          break;
1000          }          }
1001        ptr = oldptr;      /* Put the pointer back and fall through */        ptr = oldptr;      /* Put the pointer back and fall through */
# Line 1069  else Line 1073  else
1073          c = (c << 4) + cc - ((cc >= CHAR_0)? CHAR_0 : (CHAR_A - 10));          c = (c << 4) + cc - ((cc >= CHAR_0)? CHAR_0 : (CHAR_A - 10));
1074  #endif  #endif
1075    
1076  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
1077          if (c > (utf ? 0x10ffff : 0xff)) { c = -1; break; }          if (c > (utf ? 0x10ffff : 0xff)) { c = -1; break; }
1078  #else  #elif defined COMPILE_PCRE16
 #ifdef COMPILE_PCRE16  
1079          if (c > (utf ? 0x10ffff : 0xffff)) { c = -1; break; }          if (c > (utf ? 0x10ffff : 0xffff)) { c = -1; break; }
1080  #endif  #elif defined COMPILE_PCRE32
1081            if (utf && c > 0x10ffff) { c = -1; break; }
1082  #endif  #endif
1083          }          }
1084    
# Line 1159  else Line 1163  else
1163  newline". PCRE does not support \N{name}. However, it does support  newline". PCRE does not support \N{name}. However, it does support
1164  quantification such as \N{2,3}. */  quantification such as \N{2,3}. */
1165    
1166  if (c == -ESC_N && ptr[1] == CHAR_LEFT_CURLY_BRACKET &&  if (escape == ESC_N && ptr[1] == CHAR_LEFT_CURLY_BRACKET &&
1167       !is_counted_repeat(ptr+2))       !is_counted_repeat(ptr+2))
1168    *errorcodeptr = ERR37;    *errorcodeptr = ERR37;
1169    
1170  /* If PCRE_UCP is set, we change the values for \d etc. */  /* If PCRE_UCP is set, we change the values for \d etc. */
1171    
1172  if ((options & PCRE_UCP) != 0 && c <= -ESC_D && c >= -ESC_w)  if ((options & PCRE_UCP) != 0 && escape >= ESC_D && escape <= ESC_w)
1173    c -= (ESC_DU - ESC_D);    escape += (ESC_DU - ESC_D);
1174    
1175  /* Set the pointer to the final character before returning. */  /* Set the pointer to the final character before returning. */
1176    
1177  *ptrptr = ptr;  *ptrptr = ptr;
1178  return c;  *chptr = c;
1179    return escape;
1180  }  }
1181    
   
   
1182  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
1183  /*************************************************  /*************************************************
1184  *               Handle \P and \p                 *  *               Handle \P and \p                 *
# Line 1367  Arguments: Line 1370  Arguments:
1370    name         name to seek, or NULL if seeking a numbered subpattern    name         name to seek, or NULL if seeking a numbered subpattern
1371    lorn         name length, or subpattern number if name is NULL    lorn         name length, or subpattern number if name is NULL
1372    xmode        TRUE if we are in /x mode    xmode        TRUE if we are in /x mode
1373    utf          TRUE if we are in UTF-8 / UTF-16 mode    utf          TRUE if we are in UTF-8 / UTF-16 / UTF-32 mode
1374    count        pointer to the current capturing subpattern number (updated)    count        pointer to the current capturing subpattern number (updated)
1375    
1376  Returns:       the number of the named subpattern, or -1 if not found  Returns:       the number of the named subpattern, or -1 if not found
# Line 1601  Arguments: Line 1604  Arguments:
1604    name         name to seek, or NULL if seeking a numbered subpattern    name         name to seek, or NULL if seeking a numbered subpattern
1605    lorn         name length, or subpattern number if name is NULL    lorn         name length, or subpattern number if name is NULL
1606    xmode        TRUE if we are in /x mode    xmode        TRUE if we are in /x mode
1607    utf          TRUE if we are in UTF-8 / UTF-16 mode    utf          TRUE if we are in UTF-8 / UTF-16 / UTF-32 mode
1608    
1609  Returns:       the number of the found subpattern, or -1 if not found  Returns:       the number of the found subpattern, or -1 if not found
1610  */  */
# Line 1704  and doing the check at the end; a flag s Line 1707  and doing the check at the end; a flag s
1707    
1708  Arguments:  Arguments:
1709    code     points to the start of the pattern (the bracket)    code     points to the start of the pattern (the bracket)
1710    utf      TRUE in UTF-8 / UTF-16 mode    utf      TRUE in UTF-8 / UTF-16 / UTF-32 mode
1711    atend    TRUE if called when the pattern is complete    atend    TRUE if called when the pattern is complete
1712    cd       the "compile data" structure    cd       the "compile data" structure
1713    
# Line 1838  for (;;) Line 1841  for (;;)
1841      case OP_NOTI:      case OP_NOTI:
1842      branchlength++;      branchlength++;
1843      cc += 2;      cc += 2;
1844  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
1845      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1846  #endif  #endif
1847      break;      break;
# Line 1852  for (;;) Line 1855  for (;;)
1855      case OP_NOTEXACTI:      case OP_NOTEXACTI:
1856      branchlength += GET2(cc,1);      branchlength += GET2(cc,1);
1857      cc += 2 + IMM2_SIZE;      cc += 2 + IMM2_SIZE;
1858  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
1859      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1860  #endif  #endif
1861      break;      break;
1862    
1863      case OP_TYPEEXACT:      case OP_TYPEEXACT:
1864      branchlength += GET2(cc,1);      branchlength += GET2(cc,1);
1865      if (cc[1 + IMM2_SIZE] == OP_PROP || cc[1 + IMM2_SIZE] == OP_NOTPROP) cc += 2;      if (cc[1 + IMM2_SIZE] == OP_PROP || cc[1 + IMM2_SIZE] == OP_NOTPROP)
1866          cc += 2;
1867      cc += 1 + IMM2_SIZE + 1;      cc += 1 + IMM2_SIZE + 1;
1868      break;      break;
1869    
# Line 1894  for (;;) Line 1898  for (;;)
1898    
1899      /* Check a class for variable quantification */      /* Check a class for variable quantification */
1900    
1901  #if defined SUPPORT_UTF || defined COMPILE_PCRE16  #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1902      case OP_XCLASS:      case OP_XCLASS:
1903      cc += GET(cc, 1) - PRIV(OP_lengths)[OP_CLASS];      cc += GET(cc, 1) - PRIV(OP_lengths)[OP_CLASS];
1904      /* Fall through */      /* Fall through */
# Line 2033  length. Line 2037  length.
2037    
2038  Arguments:  Arguments:
2039    code        points to start of expression    code        points to start of expression
2040    utf         TRUE in UTF-8 / UTF-16 mode    utf         TRUE in UTF-8 / UTF-16 / UTF-32 mode
2041    number      the required bracket number or negative to find a lookbehind    number      the required bracket number or negative to find a lookbehind
2042    
2043  Returns:      pointer to the opcode for the bracket, or NULL if not found  Returns:      pointer to the opcode for the bracket, or NULL if not found
# Line 2097  for (;;) Line 2101  for (;;)
2101        case OP_TYPEMINUPTO:        case OP_TYPEMINUPTO:
2102        case OP_TYPEEXACT:        case OP_TYPEEXACT:
2103        case OP_TYPEPOSUPTO:        case OP_TYPEPOSUPTO:
2104        if (code[1 + IMM2_SIZE] == OP_PROP        if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
2105          || code[1 + IMM2_SIZE] == OP_NOTPROP) code += 2;          code += 2;
2106        break;        break;
2107    
2108        case OP_MARK:        case OP_MARK:
# Line 2120  for (;;) Line 2124  for (;;)
2124    a multi-byte character. The length in the table is a minimum, so we have to    a multi-byte character. The length in the table is a minimum, so we have to
2125    arrange to skip the extra bytes. */    arrange to skip the extra bytes. */
2126    
2127  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
2128      if (utf) switch(c)      if (utf) switch(c)
2129        {        {
2130        case OP_CHAR:        case OP_CHAR:
# Line 2172  instance of OP_RECURSE. Line 2176  instance of OP_RECURSE.
2176    
2177  Arguments:  Arguments:
2178    code        points to start of expression    code        points to start of expression
2179    utf         TRUE in UTF-8 / UTF-16 mode    utf         TRUE in UTF-8 / UTF-16 / UTF-32 mode
2180    
2181  Returns:      pointer to the opcode for OP_RECURSE, or NULL if not found  Returns:      pointer to the opcode for OP_RECURSE, or NULL if not found
2182  */  */
# Line 2217  for (;;) Line 2221  for (;;)
2221        case OP_TYPEUPTO:        case OP_TYPEUPTO:
2222        case OP_TYPEMINUPTO:        case OP_TYPEMINUPTO:
2223        case OP_TYPEEXACT:        case OP_TYPEEXACT:
2224        if (code[1 + IMM2_SIZE] == OP_PROP        if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
2225          || code[1 + IMM2_SIZE] == OP_NOTPROP) code += 2;          code += 2;
2226        break;        break;
2227    
2228        case OP_MARK:        case OP_MARK:
# Line 2240  for (;;) Line 2244  for (;;)
2244      by a multi-byte character. The length in the table is a minimum, so we have      by a multi-byte character. The length in the table is a minimum, so we have
2245      to arrange to skip the extra bytes. */      to arrange to skip the extra bytes. */
2246    
2247  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
2248      if (utf) switch(c)      if (utf) switch(c)
2249        {        {
2250        case OP_CHAR:        case OP_CHAR:
# Line 2326  bracket whose current branch will alread Line 2330  bracket whose current branch will alread
2330  Arguments:  Arguments:
2331    code        points to start of search    code        points to start of search
2332    endcode     points to where to stop    endcode     points to where to stop
2333    utf         TRUE if in UTF-8 / UTF-16 mode    utf         TRUE if in UTF-8 / UTF-16 / UTF-32 mode
2334    cd          contains pointers to tables etc.    cd          contains pointers to tables etc.
2335    
2336  Returns:      TRUE if what is matched could be empty  Returns:      TRUE if what is matched could be empty
# Line 2543  for (code = first_significant_code(code Line 2547  for (code = first_significant_code(code
2547      case OP_TYPEUPTO:      case OP_TYPEUPTO:
2548      case OP_TYPEMINUPTO:      case OP_TYPEMINUPTO:
2549      case OP_TYPEPOSUPTO:      case OP_TYPEPOSUPTO:
2550      if (code[1 + IMM2_SIZE] == OP_PROP      if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
2551        || code[1 + IMM2_SIZE] == OP_NOTPROP) code += 2;        code += 2;
2552      break;      break;
2553    
2554      /* End of branch */      /* End of branch */
# Line 2559  for (code = first_significant_code(code Line 2563  for (code = first_significant_code(code
2563      /* In UTF-8 mode, STAR, MINSTAR, POSSTAR, QUERY, MINQUERY, POSQUERY, UPTO,      /* In UTF-8 mode, STAR, MINSTAR, POSSTAR, QUERY, MINQUERY, POSQUERY, UPTO,
2564      MINUPTO, and POSUPTO may be followed by a multibyte character */      MINUPTO, and POSUPTO may be followed by a multibyte character */
2565    
2566  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
2567      case OP_STAR:      case OP_STAR:
2568      case OP_STARI:      case OP_STARI:
2569      case OP_MINSTAR:      case OP_MINSTAR:
# Line 2625  Arguments: Line 2629  Arguments:
2629    code        points to start of the recursion    code        points to start of the recursion
2630    endcode     points to where to stop (current RECURSE item)    endcode     points to where to stop (current RECURSE item)
2631    bcptr       points to the chain of current (unclosed) branch starts    bcptr       points to the chain of current (unclosed) branch starts
2632    utf         TRUE if in UTF-8 / UTF-16 mode    utf         TRUE if in UTF-8 / UTF-16 / UTF-32 mode
2633    cd          pointers to tables etc    cd          pointers to tables etc
2634    
2635  Returns:      TRUE if what is matched could be empty  Returns:      TRUE if what is matched could be empty
# Line 2772  value in the reference (which is a group Line 2776  value in the reference (which is a group
2776  Arguments:  Arguments:
2777    group      points to the start of the group    group      points to the start of the group
2778    adjust     the amount by which the group is to be moved    adjust     the amount by which the group is to be moved
2779    utf        TRUE in UTF-8 / UTF-16 mode    utf        TRUE in UTF-8 / UTF-16 / UTF-32 mode
2780    cd         contains pointers to tables etc.    cd         contains pointers to tables etc.
2781    save_hwm   the hwm forward reference pointer at the start of the group    save_hwm   the hwm forward reference pointer at the start of the group
2782    
# Line 2951  Returns:       TRUE if auto-possessifyin Line 2955  Returns:       TRUE if auto-possessifyin
2955  static BOOL  static BOOL
2956  check_char_prop(int c, int ptype, int pdata, BOOL negated)  check_char_prop(int c, int ptype, int pdata, BOOL negated)
2957  {  {
2958    #ifdef SUPPORT_UCP
2959    const pcre_uint32 *p;
2960    #endif
2961    
2962  const ucd_record *prop = GET_UCD(c);  const ucd_record *prop = GET_UCD(c);
2963    
2964  switch(ptype)  switch(ptype)
2965    {    {
2966    case PT_LAMP:    case PT_LAMP:
# Line 2989  switch(ptype) Line 2998  switch(ptype)
2998    return (PRIV(ucp_gentype)[prop->chartype] == ucp_L ||    return (PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
2999            PRIV(ucp_gentype)[prop->chartype] == ucp_N ||            PRIV(ucp_gentype)[prop->chartype] == ucp_N ||
3000            c == CHAR_UNDERSCORE) == negated;            c == CHAR_UNDERSCORE) == negated;
3001    
3002    #ifdef SUPPORT_UCP
3003      case PT_CLIST:
3004      p = PRIV(ucd_caseless_sets) + prop->caseset;
3005      for (;;)
3006        {
3007        if ((unsigned int)c < *p) return !negated;
3008        if ((unsigned int)c == *p++) return negated;
3009        }
3010      break;  /* Control never reaches here */
3011    #endif
3012    }    }
3013    
3014  return FALSE;  return FALSE;
3015  }  }
3016  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
# Line 3006  sense to automatically possessify the re Line 3027  sense to automatically possessify the re
3027    
3028  Arguments:  Arguments:
3029    previous      pointer to the repeated opcode    previous      pointer to the repeated opcode
3030    utf           TRUE in UTF-8 / UTF-16 mode    utf           TRUE in UTF-8 / UTF-16 / UTF-32 mode
3031    ptr           next character in pattern    ptr           next character in pattern
3032    options       options bits    options       options bits
3033    cd            contains pointers to tables etc.    cd            contains pointers to tables etc.
# Line 3018  static BOOL Line 3039  static BOOL
3039  check_auto_possessive(const pcre_uchar *previous, BOOL utf,  check_auto_possessive(const pcre_uchar *previous, BOOL utf,
3040    const pcre_uchar *ptr, int options, compile_data *cd)    const pcre_uchar *ptr, int options, compile_data *cd)
3041  {  {
3042  pcre_int32 c, next;  pcre_int32 c = NOTACHAR; // FIXMEchpe pcre_uint32
3043    pcre_int32 next;
3044    int escape;
3045  int op_code = *previous++;  int op_code = *previous++;
3046    
3047  /* Skip whitespace and comments in extended mode */  /* Skip whitespace and comments in extended mode */
# Line 3050  value is a character, a negative value i Line 3073  value is a character, a negative value i
3073  if (*ptr == CHAR_BACKSLASH)  if (*ptr == CHAR_BACKSLASH)
3074    {    {
3075    int temperrorcode = 0;    int temperrorcode = 0;
3076    next = check_escape(&ptr, &temperrorcode, cd->bracount, options, FALSE);    escape = check_escape(&ptr, &next, &temperrorcode, cd->bracount, options, FALSE);
3077    if (temperrorcode != 0) return FALSE;    if (temperrorcode != 0) return FALSE;
3078    ptr++;    /* Point after the escape sequence */    ptr++;    /* Point after the escape sequence */
3079    }    }
3080  else if (!MAX_255(*ptr) || (cd->ctypes[*ptr] & ctype_meta) == 0)  else if (!MAX_255(*ptr) || (cd->ctypes[*ptr] & ctype_meta) == 0)
3081    {    {
3082      escape = 0;
3083  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3084    if (utf) { GETCHARINC(next, ptr); } else    if (utf) { GETCHARINC(next, ptr); } else
3085  #endif  #endif
# Line 3092  if (*ptr == CHAR_ASTERISK || *ptr == CHA Line 3116  if (*ptr == CHAR_ASTERISK || *ptr == CHA
3116    STRNCMP_UC_C8(ptr, STR_LEFT_CURLY_BRACKET STR_0 STR_COMMA, 3) == 0)    STRNCMP_UC_C8(ptr, STR_LEFT_CURLY_BRACKET STR_0 STR_COMMA, 3) == 0)
3117      return FALSE;      return FALSE;
3118    
3119  /* Now compare the next item with the previous opcode. First, handle cases when  /* If the previous item is a character, get its value. */
 the next item is a character. */  
3120    
3121  if (next >= 0) switch(op_code)  if (op_code == OP_CHAR || op_code == OP_CHARI ||
3122        op_code == OP_NOT || op_code == OP_NOTI)
3123      //if (escape == 0) switch(op_code)
3124    {    {
   case OP_CHAR:  
3125  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3126    GETCHARTEST(c, previous);    GETCHARTEST(c, previous);
3127  #else  #else
3128    c = *previous;    c = *previous;
3129  #endif  #endif
3130    return c != next;    }
3131    
3132    /* For CHARI (caseless character) we must check the other case. If we have  /* Now compare the next item with the previous opcode. First, handle cases when
3133    Unicode property support, we can use it to test the other case of  the next item is a character. */
   high-valued characters. */  
3134    
3135    case OP_CHARI:  if (escape == 0)
3136  #ifdef SUPPORT_UTF    {
3137    GETCHARTEST(c, previous);    /* For a caseless UTF match, the next character may have more than one other
3138  #else    case, which maps to the special PT_CLIST property. Check this first. */
3139    c = *previous;  
 #endif  
   if (c == next) return FALSE;  
 #ifdef SUPPORT_UTF  
   if (utf)  
     {  
     unsigned int othercase;  
     if (next < 128) othercase = cd->fcc[next]; else  
3140  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3141      othercase = UCD_OTHERCASE((unsigned int)next);    if (utf && (unsigned int)c != NOTACHAR && (options & PCRE_CASELESS) != 0)
3142  #else      {
3143      othercase = NOTACHAR;      int ocs = UCD_CASESET(next);
3144  #endif      if (ocs > 0) return check_char_prop(c, PT_CLIST, ocs, op_code >= OP_NOT);
     return (unsigned int)c != othercase;  
3145      }      }
   else  
 #endif  /* SUPPORT_UTF */  
   return (c != TABLE_GET((unsigned int)next, cd->fcc, next));  /* Non-UTF-8 mode */  
   
   case OP_NOT:  
 #ifdef SUPPORT_UTF  
   GETCHARTEST(c, previous);  
 #else  
   c = *previous;  
3146  #endif  #endif
   return c == next;  
3147    
3148    case OP_NOTI:    switch(op_code)
3149        {
3150        case OP_CHAR:
3151        return c != next;
3152    
3153        /* For CHARI (caseless character) we must check the other case. If we have
3154        Unicode property support, we can use it to test the other case of
3155        high-valued characters. We know that next can have only one other case,
3156        because multi-other-case characters are dealt with above. */
3157    
3158        case OP_CHARI:
3159        if (c == next) return FALSE;
3160  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3161    GETCHARTEST(c, previous);      if (utf)
3162          {
3163          unsigned int othercase;
3164          if (next < 128) othercase = cd->fcc[next]; else
3165    #ifdef SUPPORT_UCP
3166          othercase = UCD_OTHERCASE((unsigned int)next);
3167  #else  #else
3168    c = *previous;        othercase = NOTACHAR;
3169  #endif  #endif
3170    if (c == next) return TRUE;        return (unsigned int)c != othercase;
3171          }
3172        else
3173    #endif  /* SUPPORT_UTF */
3174        return (c != TABLE_GET((unsigned int)next, cd->fcc, next));  /* Not UTF */
3175    
3176        case OP_NOT:
3177        return c == next;
3178    
3179        case OP_NOTI:
3180        if (c == next) return TRUE;
3181  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3182    if (utf)      if (utf)
3183      {        {
3184      unsigned int othercase;        unsigned int othercase;
3185      if (next < 128) othercase = cd->fcc[next]; else        if (next < 128) othercase = cd->fcc[next]; else
3186  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3187      othercase = UCD_OTHERCASE((unsigned int)next);        othercase = UCD_OTHERCASE((unsigned int)next);
3188  #else  #else
3189      othercase = NOTACHAR;        othercase = NOTACHAR;
3190  #endif  #endif
3191      return (unsigned int)c == othercase;        return (unsigned int)c == othercase;
3192      }        }
3193    else      else
3194  #endif  /* SUPPORT_UTF */  #endif  /* SUPPORT_UTF */
3195    return (c == TABLE_GET((unsigned int)next, cd->fcc, next));  /* Non-UTF-8 mode */      return (c == TABLE_GET((unsigned int)next, cd->fcc, next));  /* Not UTF */
3196    
3197    /* 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.
3198    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. */
3199    
3200    case OP_DIGIT:      case OP_DIGIT:
3201    return next > 255 || (cd->ctypes[next] & ctype_digit) == 0;      return next > 255 || (cd->ctypes[next] & ctype_digit) == 0;
3202    
3203    case OP_NOT_DIGIT:      case OP_NOT_DIGIT:
3204    return next <= 255 && (cd->ctypes[next] & ctype_digit) != 0;      return next <= 255 && (cd->ctypes[next] & ctype_digit) != 0;
3205    
3206    case OP_WHITESPACE:      case OP_WHITESPACE:
3207    return next > 255 || (cd->ctypes[next] & ctype_space) == 0;      return next > 255 || (cd->ctypes[next] & ctype_space) == 0;
3208    
3209    case OP_NOT_WHITESPACE:      case OP_NOT_WHITESPACE:
3210    return next <= 255 && (cd->ctypes[next] & ctype_space) != 0;      return next <= 255 && (cd->ctypes[next] & ctype_space) != 0;
3211    
3212    case OP_WORDCHAR:      case OP_WORDCHAR:
3213    return next > 255 || (cd->ctypes[next] & ctype_word) == 0;      return next > 255 || (cd->ctypes[next] & ctype_word) == 0;
3214    
3215    case OP_NOT_WORDCHAR:      case OP_NOT_WORDCHAR:
3216    return next <= 255 && (cd->ctypes[next] & ctype_word) != 0;      return next <= 255 && (cd->ctypes[next] & ctype_word) != 0;
3217    
3218    case OP_HSPACE:      case OP_HSPACE:
3219    case OP_NOT_HSPACE:      case OP_NOT_HSPACE:
3220    switch(next)      switch(next)
3221      {        {
3222      HSPACE_CASES:        HSPACE_CASES:
3223      return op_code == OP_NOT_HSPACE;        return op_code == OP_NOT_HSPACE;
   
     default:  
     return op_code != OP_NOT_HSPACE;  
     }  
3224    
3225    case OP_ANYNL:        default:
3226    case OP_VSPACE:        return op_code != OP_NOT_HSPACE;
3227    case OP_NOT_VSPACE:        }
3228    switch(next)  
3229      {      case OP_ANYNL:
3230      VSPACE_CASES:      case OP_VSPACE:
3231      return op_code == OP_NOT_VSPACE;      case OP_NOT_VSPACE:
3232        switch(next)
3233      default:        {
3234      return op_code != OP_NOT_VSPACE;        VSPACE_CASES:
3235      }        return op_code == OP_NOT_VSPACE;
3236    
3237          default:
3238          return op_code != OP_NOT_VSPACE;
3239          }
3240    
3241  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3242    case OP_PROP:      case OP_PROP:
3243    return check_char_prop(next, previous[0], previous[1], FALSE);      return check_char_prop(next, previous[0], previous[1], FALSE);
3244    
3245    case OP_NOTPROP:      case OP_NOTPROP:
3246    return check_char_prop(next, previous[0], previous[1], TRUE);      return check_char_prop(next, previous[0], previous[1], TRUE);
3247  #endif  #endif
3248    
3249    default:      default:
3250    return FALSE;      return FALSE;
3251        }
3252    }    }
3253    
   
3254  /* 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
3255  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
3256  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
# Line 3230  switch(op_code) Line 3261  switch(op_code)
3261    {    {
3262    case OP_CHAR:    case OP_CHAR:
3263    case OP_CHARI:    case OP_CHARI:
3264  #ifdef SUPPORT_UTF    switch(escape)
   GETCHARTEST(c, previous);  
 #else  
   c = *previous;  
 #endif  
   switch(-next)  
3265      {      {
3266      case ESC_d:      case ESC_d:
3267      return c > 255 || (cd->ctypes[c] & ctype_digit) == 0;      return c > 255 || (cd->ctypes[c] & ctype_digit) == 0;
# Line 3260  switch(op_code) Line 3286  switch(op_code)
3286      switch(c)      switch(c)
3287        {        {
3288        HSPACE_CASES:        HSPACE_CASES:
3289        return -next != ESC_h;        return escape != ESC_h;
3290    
3291        default:        default:
3292        return -next == ESC_h;        return escape == ESC_h;
3293        }        }
3294    
3295      case ESC_v:      case ESC_v:
# Line 3271  switch(op_code) Line 3297  switch(op_code)
3297      switch(c)      switch(c)
3298        {        {
3299        VSPACE_CASES:        VSPACE_CASES:
3300        return -next != ESC_v;        return escape != ESC_v;
3301    
3302        default:        default:
3303        return -next == ESC_v;        return escape == ESC_v;
3304        }        }
3305    
3306      /* 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
3307      their substitutions and process them. The result will always be either      their substitutions and process them. The result will always be either
3308      -ESC_p or -ESC_P. Then fall through to process those values. */      ESC_p or ESC_P. Then fall through to process those values. */
3309    
3310  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3311      case ESC_du:      case ESC_du:
# Line 3290  switch(op_code) Line 3316  switch(op_code)
3316      case ESC_SU:      case ESC_SU:
3317        {        {
3318        int temperrorcode = 0;        int temperrorcode = 0;
3319        ptr = substitutes[-next - ESC_DU];        ptr = substitutes[escape - ESC_DU];
3320        next = check_escape(&ptr, &temperrorcode, 0, options, FALSE);        escape = check_escape(&ptr, &next, &temperrorcode, 0, options, FALSE);
3321        if (temperrorcode != 0) return FALSE;        if (temperrorcode != 0) return FALSE;
3322        ptr++;    /* For compatibility */        ptr++;    /* For compatibility */
3323        }        }
# Line 3318  switch(op_code) Line 3344  switch(op_code)
3344    
3345        /* Do the property check. */        /* Do the property check. */
3346    
3347        return check_char_prop(c, ptype, pdata, (next == -ESC_P) != negated);        return check_char_prop(c, ptype, pdata, (escape == ESC_P) != negated);
3348        }        }
3349  #endif  #endif
3350    
# Line 3333  switch(op_code) Line 3359  switch(op_code)
3359    these op-codes are never generated.) */    these op-codes are never generated.) */
3360    
3361    case OP_DIGIT:    case OP_DIGIT:
3362    return next == -ESC_D || next == -ESC_s || next == -ESC_W ||    return escape == ESC_D || escape == ESC_s || escape == ESC_W ||
3363           next == -ESC_h || next == -ESC_v || next == -ESC_R;           escape == ESC_h || escape == ESC_v || escape == ESC_R;
3364    
3365    case OP_NOT_DIGIT:    case OP_NOT_DIGIT:
3366    return next == -ESC_d;    return escape == ESC_d;
3367    
3368    case OP_WHITESPACE:    case OP_WHITESPACE:
3369    return next == -ESC_S || next == -ESC_d || next == -ESC_w;    return escape == ESC_S || escape == ESC_d || escape == ESC_w;
3370    
3371    case OP_NOT_WHITESPACE:    case OP_NOT_WHITESPACE:
3372    return next == -ESC_s || next == -ESC_h || next == -ESC_v || next == -ESC_R;    return escape == ESC_s || escape == ESC_h || escape == ESC_v || escape == ESC_R;
3373    
3374    case OP_HSPACE:    case OP_HSPACE:
3375    return next == -ESC_S || next == -ESC_H || next == -ESC_d ||    return escape == ESC_S || escape == ESC_H || escape == ESC_d ||
3376           next == -ESC_w || next == -ESC_v || next == -ESC_R;           escape == ESC_w || escape == ESC_v || escape == ESC_R;
3377    
3378    case OP_NOT_HSPACE:    case OP_NOT_HSPACE:
3379    return next == -ESC_h;    return escape == ESC_h;
3380    
3381    /* Can't have \S in here because VT matches \S (Perl anomaly) */    /* Can't have \S in here because VT matches \S (Perl anomaly) */
3382    case OP_ANYNL:    case OP_ANYNL:
3383    case OP_VSPACE:    case OP_VSPACE:
3384    return next == -ESC_V || next == -ESC_d || next == -ESC_w;    return escape == ESC_V || escape == ESC_d || escape == ESC_w;
3385    
3386    case OP_NOT_VSPACE:    case OP_NOT_VSPACE:
3387    return next == -ESC_v || next == -ESC_R;    return escape == ESC_v || escape == ESC_R;
3388    
3389    case OP_WORDCHAR:    case OP_WORDCHAR:
3390    return next == -ESC_W || next == -ESC_s || next == -ESC_h ||    return escape == ESC_W || escape == ESC_s || escape == ESC_h ||
3391           next == -ESC_v || next == -ESC_R;           escape == ESC_v || escape == ESC_R;
3392    
3393    case OP_NOT_WORDCHAR:    case OP_NOT_WORDCHAR:
3394    return next == -ESC_w || next == -ESC_d;    return escape == ESC_w || escape == ESC_d;
3395    
3396    default:    default:
3397    return FALSE;    return FALSE;
# Line 3399  Returns:        the number of < 256 char Line 3425  Returns:        the number of < 256 char
3425    
3426  static int  static int
3427  add_to_class(pcre_uint8 *classbits, pcre_uchar **uchardptr, int options,  add_to_class(pcre_uint8 *classbits, pcre_uchar **uchardptr, int options,
3428    compile_data *cd, unsigned int start, unsigned int end)    compile_data *cd, pcre_uint32 start, pcre_uint32 end)
3429  {  {
3430  unsigned int c;  pcre_uint32 c;
3431  int n8 = 0;  int n8 = 0;
3432    
3433  /* If caseless matching is required, scan the range and process alternate  /* If caseless matching is required, scan the range and process alternate
# Line 3415  if ((options & PCRE_CASELESS) != 0) Line 3441  if ((options & PCRE_CASELESS) != 0)
3441    if ((options & PCRE_UTF8) != 0)    if ((options & PCRE_UTF8) != 0)
3442      {      {
3443      int rc;      int rc;
3444      unsigned int oc, od;      pcre_uint32 oc, od;
3445    
3446      options &= ~PCRE_CASELESS;   /* Remove for recursive calls */      options &= ~PCRE_CASELESS;   /* Remove for recursive calls */
3447      c = start;      c = start;
# Line 3456  if ((options & PCRE_CASELESS) != 0) Line 3482  if ((options & PCRE_CASELESS) != 0)
3482  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
3483  in all cases. */  in all cases. */
3484    
3485  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
3486  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3487    if ((options & PCRE_UTF8) == 0)    if ((options & PCRE_UTF8) == 0)
3488  #endif  #endif
3489    if (end > 0xff) end = 0xff;    if (end > 0xff) end = 0xff;
 #endif  
3490    
3491  #ifdef COMPILE_PCRE16  #elif defined COMPILE_PCRE16
3492  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3493    if ((options & PCRE_UTF16) == 0)    if ((options & PCRE_UTF16) == 0)
3494  #endif  #endif
3495    if (end > 0xffff) end = 0xffff;    if (end > 0xffff) end = 0xffff;
3496  #endif  
3497    #endif /* COMPILE_PCRE[8|16] */
3498    
3499  /* If all characters are less than 256, use the bit map. Otherwise use extra  /* If all characters are less than 256, use the bit map. Otherwise use extra
3500  data. */  data. */
# Line 3598  static int Line 3624  static int
3624  add_not_list_to_class(pcre_uint8 *classbits, pcre_uchar **uchardptr,  add_not_list_to_class(pcre_uint8 *classbits, pcre_uchar **uchardptr,
3625    int options, compile_data *cd, const pcre_uint32 *p)    int options, compile_data *cd, const pcre_uint32 *p)
3626  {  {
3627    BOOL utf = (options & PCRE_UTF8) != 0;
3628  int n8 = 0;  int n8 = 0;
3629  if (p[0] > 0)  if (p[0] > 0)
3630    n8 += add_to_class(classbits, uchardptr, options, cd, 0, p[0] - 1);    n8 += add_to_class(classbits, uchardptr, options, cd, 0, p[0] - 1);
3631  while (p[0] < NOTACHAR)  while (p[0] < NOTACHAR)
3632    {    {
3633    while (p[1] == p[0] + 1) p++;    while (p[1] == p[0] + 1) p++;
3634    n8 += add_to_class(classbits, uchardptr, options, cd, p[0] + 1,    n8 += add_to_class(classbits, uchardptr, options, cd, p[0] + 1,
3635      (p[1] == NOTACHAR)? 0x10ffff : p[1] - 1);      (p[1] == NOTACHAR) ? (utf ? 0x10ffffu : 0xffffffffu) : p[1] - 1);
3636    p++;    p++;
3637    }    }
3638  return n8;  return n8;
# Line 3657  int options = *optionsptr; Line 3684  int options = *optionsptr;
3684  int after_manual_callout = 0;  int after_manual_callout = 0;
3685  int length_prevgroup = 0;  int length_prevgroup = 0;
3686  register int c;  register int c;
3687    int escape;
3688  register pcre_uchar *code = *codeptr;  register pcre_uchar *code = *codeptr;
3689  pcre_uchar *last_code = code;  pcre_uchar *last_code = code;
3690  pcre_uchar *orig_code = code;  pcre_uchar *orig_code = code;
# Line 3676  must not do this for other options (e.g. Line 3704  must not do this for other options (e.g.
3704  dynamically as we process the pattern. */  dynamically as we process the pattern. */
3705    
3706  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3707  /* PCRE_UTF16 has the same value as PCRE_UTF8. */  /* PCRE_UTF[16|32] have the same value as PCRE_UTF8. */
3708  BOOL utf = (options & PCRE_UTF8) != 0;  BOOL utf = (options & PCRE_UTF8) != 0;
3709  pcre_uchar utf_chars[6];  pcre_uchar utf_chars[6];
3710  #else  #else
3711  BOOL utf = FALSE;  BOOL utf = FALSE;
3712  #endif  #endif
3713    
3714  /* Helper variables for OP_XCLASS opcode (for characters > 255). */  /* Helper variables for OP_XCLASS opcode (for characters > 255). We define
3715    class_uchardata always so that it can be passed to add_to_class() always,
3716    though it will not be used in non-UTF 8-bit cases. This avoids having to supply
3717    alternative calls for the different cases. */
3718    
3719    pcre_uchar *class_uchardata;
3720  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
3721  BOOL xclass;  BOOL xclass;
 pcre_uchar *class_uchardata;  
3722  pcre_uchar *class_uchardata_base;  pcre_uchar *class_uchardata_base;
3723  #endif  #endif
3724    
# Line 3741  for (;; ptr++) Line 3772  for (;; ptr++)
3772    int terminator;    int terminator;
3773    int mclength;    int mclength;
3774    int tempbracount;    int tempbracount;
3775      int ec; // FIXMEchpe pcre_uint32
3776    pcre_uchar mcbuffer[8];    pcre_uchar mcbuffer[8];
3777    
3778    /* Get next character in the pattern */    /* Get next character in the pattern */
# Line 4058  for (;; ptr++) Line 4090  for (;; ptr++)
4090        {        {
4091        const pcre_uchar *oldptr;        const pcre_uchar *oldptr;
4092    
4093  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4094        if (utf && HAS_EXTRALEN(c))        if (utf && HAS_EXTRALEN(c))
4095          {                           /* Braces are required because the */          {                           /* Braces are required because the */
4096          GETCHARLEN(c, ptr, ptr);    /* macro generates multiple statements */          GETCHARLEN(c, ptr, ptr);    /* macro generates multiple statements */
# Line 4133  for (;; ptr++) Line 4165  for (;; ptr++)
4165          alpha. This relies on the fact that the class table starts with          alpha. This relies on the fact that the class table starts with
4166          alpha, lower, upper as the first 3 entries. */          alpha, lower, upper as the first 3 entries. */
4167    
4168          if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)          if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)
4169            posix_class = 0;            posix_class = 0;
4170    
4171          /* 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 4210  for (;; ptr++) Line 4242  for (;; ptr++)
4242    
4243        if (c == CHAR_BACKSLASH)        if (c == CHAR_BACKSLASH)
4244          {          {
4245          c = check_escape(&ptr, errorcodeptr, cd->bracount, options, TRUE);          escape = check_escape(&ptr, &ec, errorcodeptr, cd->bracount, options, TRUE);
4246    
4247          if (*errorcodeptr != 0) goto FAILED;          if (*errorcodeptr != 0) goto FAILED;
4248    
4249          if (-c == ESC_b) c = CHAR_BS;    /* \b is backspace in a class */          if (escape == 0)
4250          else if (-c == ESC_N)            /* \N is not supported in a class */            c = ec;
4251            else if (escape == ESC_b) c = CHAR_BS; /* \b is backspace in a class */
4252            else if (escape == ESC_N)            /* \N is not supported in a class */
4253            {            {
4254            *errorcodeptr = ERR71;            *errorcodeptr = ERR71;
4255            goto FAILED;            goto FAILED;
4256            }            }
4257          else if (-c == ESC_Q)            /* Handle start of quoted string */          else if (escape == ESC_Q)            /* Handle start of quoted string */
4258            {            {
4259            if (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)            if (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)
4260              {              {
# Line 4228  for (;; ptr++) Line 4263  for (;; ptr++)
4263            else inescq = TRUE;            else inescq = TRUE;
4264            continue;            continue;
4265            }            }
4266          else if (-c == ESC_E) continue;  /* Ignore orphan \E */          else if (escape == ESC_E) continue;  /* Ignore orphan \E */
4267    
4268          if (c < 0)          else
4269            {            {
4270            register const pcre_uint8 *cbits = cd->cbits;            register const pcre_uint8 *cbits = cd->cbits;
4271            /* Every class contains at least two < 256 characters. */            /* Every class contains at least two < 256 characters. */
# Line 4238  for (;; ptr++) Line 4273  for (;; ptr++)
4273            /* Every class contains at least two characters. */            /* Every class contains at least two characters. */
4274            class_one_char += 2;            class_one_char += 2;
4275    
4276            switch (-c)            switch (escape)
4277              {              {
4278  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
4279              case ESC_du:     /* These are the values given for \d etc */              case ESC_du:     /* These are the values given for \d etc */
# Line 4248  for (;; ptr++) Line 4283  for (;; ptr++)
4283              case ESC_su:     /* of the default ASCII testing. */              case ESC_su:     /* of the default ASCII testing. */
4284              case ESC_SU:              case ESC_SU:
4285              nestptr = ptr;              nestptr = ptr;
4286              ptr = substitutes[-c - ESC_DU] - 1;  /* Just before substitute */              ptr = substitutes[escape - ESC_DU] - 1;  /* Just before substitute */
4287              class_has_8bitchar--;                /* Undo! */              class_has_8bitchar--;                /* Undo! */
4288              continue;              continue;
4289  #endif  #endif
# Line 4317  for (;; ptr++) Line 4352  for (;; ptr++)
4352                int pdata;                int pdata;
4353                int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr);                int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr);
4354                if (ptype < 0) goto FAILED;                if (ptype < 0) goto FAILED;
4355                *class_uchardata++ = ((-c == ESC_p) != negated)?                *class_uchardata++ = ((escape == ESC_p) != negated)?
4356                  XCL_PROP : XCL_NOTPROP;                  XCL_PROP : XCL_NOTPROP;
4357                *class_uchardata++ = ptype;                *class_uchardata++ = ptype;
4358                *class_uchardata++ = pdata;                *class_uchardata++ = pdata;
# Line 4345  for (;; ptr++) Line 4380  for (;; ptr++)
4380          /* Fall through if the escape just defined a single character (c >= 0).          /* Fall through if the escape just defined a single character (c >= 0).
4381          This may be greater than 256. */          This may be greater than 256. */
4382    
4383            escape = 0;
4384    
4385          }   /* End of backslash handling */          }   /* End of backslash handling */
4386    
4387        /* A character may be followed by '-' to form a range. However, Perl does        /* A character may be followed by '-' to form a range. However, Perl does
# Line 4410  for (;; ptr++) Line 4447  for (;; ptr++)
4447    
4448          if (!inescq && d == CHAR_BACKSLASH)          if (!inescq && d == CHAR_BACKSLASH)
4449            {            {
4450            d = check_escape(&ptr, errorcodeptr, cd->bracount, options, TRUE);            int descape;
4451              descape = check_escape(&ptr, &d, errorcodeptr, cd->bracount, options, TRUE);
4452            if (*errorcodeptr != 0) goto FAILED;            if (*errorcodeptr != 0) goto FAILED;
4453    
4454            /* \b is backspace; any other special means the '-' was literal. */            /* \b is backspace; any other special means the '-' was literal. */
4455    
4456            if (d < 0)            if (descape > 0)
4457              {              {
4458              if (d == -ESC_b) d = CHAR_BS; else              if (descape == ESC_b) d = CHAR_BS; else
4459                {                {
4460                ptr = oldptr;                ptr = oldptr;
4461                goto CLASS_SINGLE_CHARACTER;  /* A few lines below */                goto CLASS_SINGLE_CHARACTER;  /* A few lines below */
# Line 4476  for (;; ptr++) Line 4514  for (;; ptr++)
4514    
4515          if (negate_class)          if (negate_class)
4516            {            {
4517    #ifdef SUPPORT_UCP
4518                // FIXMEchpe pcreuint32?
4519              int d;
4520    #endif
4521            if (firstchar == REQ_UNSET) firstchar = REQ_NONE;            if (firstchar == REQ_UNSET) firstchar = REQ_NONE;
4522            zerofirstchar = firstchar;            zerofirstchar = firstchar;
4523            *code++ = ((options & PCRE_CASELESS) != 0)? OP_NOTI: OP_NOT;  
4524  #ifdef SUPPORT_UTF            /* For caseless UTF-8 mode when UCP support is available, check
4525            if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)            whether this character has more than one other case. If so, generate
4526              code += PRIV(ord2utf)(c, code);            a special OP_NOTPROP item instead of OP_NOTI. */
4527            else  
4528    #ifdef SUPPORT_UCP
4529              if (utf && (options & PCRE_CASELESS) != 0 &&
4530                  (d = UCD_CASESET(c)) != 0)
4531                {
4532                *code++ = OP_NOTPROP;
4533                *code++ = PT_CLIST;
4534                *code++ = d;
4535                }
4536              else
4537  #endif  #endif
4538              *code++ = c;            /* Char has only one other case, or UCP not available */
4539            goto NOT_CHAR;  
4540                {
4541                *code++ = ((options & PCRE_CASELESS) != 0)? OP_NOTI: OP_NOT;
4542    #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4543                if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)
4544                  code += PRIV(ord2utf)(c, code);
4545                else
4546    #endif
4547                  *code++ = c;
4548                }
4549    
4550              /* We are finished with this character class */
4551    
4552              goto END_CLASS;
4553            }            }
4554    
4555          /* For a single, positive character, get the value into mcbuffer, and          /* For a single, positive character, get the value into mcbuffer, and
4556          then we can handle this with the normal one-character code. */          then we can handle this with the normal one-character code. */
4557    
4558  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4559          if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)          if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)
4560            mclength = PRIV(ord2utf)(c, mcbuffer);            mclength = PRIV(ord2utf)(c, mcbuffer);
4561          else          else
# Line 4601  for (;; ptr++) Line 4665  for (;; ptr++)
4665        memcpy(code, classbits, 32);        memcpy(code, classbits, 32);
4666        }        }
4667      code += 32 / sizeof(pcre_uchar);      code += 32 / sizeof(pcre_uchar);
4668      NOT_CHAR:  
4669        END_CLASS:
4670      break;      break;
4671    
4672    
# Line 4725  for (;; ptr++) Line 4790  for (;; ptr++)
4790        hold the length of the character in bytes, plus UTF_LENGTH to flag that        hold the length of the character in bytes, plus UTF_LENGTH to flag that
4791        it's a length rather than a small character. */        it's a length rather than a small character. */
4792    
4793  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4794        if (utf && NOT_FIRSTCHAR(code[-1]))        if (utf && NOT_FIRSTCHAR(code[-1]))
4795          {          {
4796          pcre_uchar *lastchar = code - 1;          pcre_uchar *lastchar = code - 1;
# Line 4861  for (;; ptr++) Line 4926  for (;; ptr++)
4926    
4927          if (repeat_max < 0)          if (repeat_max < 0)
4928            {            {
4929  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4930            if (utf && (c & UTF_LENGTH) != 0)            if (utf && (c & UTF_LENGTH) != 0)
4931              {              {
4932              memcpy(code, utf_chars, IN_UCHARS(c & 7));              memcpy(code, utf_chars, IN_UCHARS(c & 7));
# Line 4886  for (;; ptr++) Line 4951  for (;; ptr++)
4951    
4952          else if (repeat_max != repeat_min)          else if (repeat_max != repeat_min)
4953            {            {
4954  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4955            if (utf && (c & UTF_LENGTH) != 0)            if (utf && (c & UTF_LENGTH) != 0)
4956              {              {
4957              memcpy(code, utf_chars, IN_UCHARS(c & 7));              memcpy(code, utf_chars, IN_UCHARS(c & 7));
# Line 4916  for (;; ptr++) Line 4981  for (;; ptr++)
4981    
4982        /* The character or character type itself comes last in all cases. */        /* The character or character type itself comes last in all cases. */
4983    
4984  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4985        if (utf && (c & UTF_LENGTH) != 0)        if (utf && (c & UTF_LENGTH) != 0)
4986          {          {
4987          memcpy(code, utf_chars, IN_UCHARS(c & 7));          memcpy(code, utf_chars, IN_UCHARS(c & 7));
# Line 5403  for (;; ptr++) Line 5468  for (;; ptr++)
5468        else if (*tempcode == OP_EXACT || *tempcode == OP_NOTEXACT)        else if (*tempcode == OP_EXACT || *tempcode == OP_NOTEXACT)
5469          {          {
5470          tempcode += PRIV(OP_lengths)[*tempcode];          tempcode += PRIV(OP_lengths)[*tempcode];
5471  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
5472          if (utf && HAS_EXTRALEN(tempcode[-1]))          if (utf && HAS_EXTRALEN(tempcode[-1]))
5473            tempcode += GET_EXTRALEN(tempcode[-1]);            tempcode += GET_EXTRALEN(tempcode[-1]);
5474  #endif  #endif
# Line 5501  for (;; ptr++) Line 5566  for (;; ptr++)
5566          arg = ++ptr;          arg = ++ptr;
5567          while (*ptr != 0 && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;          while (*ptr != 0 && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;
5568          arglen = (int)(ptr - arg);          arglen = (int)(ptr - arg);
5569          if (arglen > (int)MAX_MARK)          if ((unsigned int)arglen > MAX_MARK)
5570            {            {
5571            *errorcodeptr = ERR75;            *errorcodeptr = ERR75;
5572            goto FAILED;            goto FAILED;
# Line 6609  for (;; ptr++) Line 6674  for (;; ptr++)
6674    
6675      case CHAR_BACKSLASH:      case CHAR_BACKSLASH:
6676      tempptr = ptr;      tempptr = ptr;
6677      c = check_escape(&ptr, errorcodeptr, cd->bracount, options, FALSE);      escape = check_escape(&ptr, &ec, errorcodeptr, cd->bracount, options, FALSE);
6678    
6679      if (*errorcodeptr != 0) goto FAILED;      if (*errorcodeptr != 0) goto FAILED;
6680    
6681      if (c < 0)      if (escape == 0)
6682          c = ec;
6683        else
6684        {        {
6685        if (-c == ESC_Q)            /* Handle start of quoted string */        if (escape == ESC_Q)            /* Handle start of quoted string */
6686          {          {
6687          if (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)          if (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)
6688            ptr += 2;               /* avoid empty string */            ptr += 2;               /* avoid empty string */
# Line 6622  for (;; ptr++) Line 6690  for (;; ptr++)
6690          continue;          continue;
6691          }          }
6692    
6693        if (-c == ESC_E) continue;  /* Perl ignores an orphan \E */        if (escape == ESC_E) continue;  /* Perl ignores an orphan \E */
6694    
6695        /* For metasequences that actually match a character, we disable the        /* For metasequences that actually match a character, we disable the
6696        setting of a first character if it hasn't already been set. */        setting of a first character if it hasn't already been set. */
6697    
6698        if (firstchar == REQ_UNSET && -c > ESC_b && -c < ESC_Z)        if (firstchar == REQ_UNSET && escape > ESC_b && escape < ESC_Z)
6699          firstchar = REQ_NONE;          firstchar = REQ_NONE;
6700    
6701        /* Set values to reset to if this is followed by a zero repeat. */        /* Set values to reset to if this is followed by a zero repeat. */
# Line 6637  for (;; ptr++) Line 6705  for (;; ptr++)
6705    
6706        /* \g<name> or \g'name' is a subroutine call by name and \g<n> or \g'n'        /* \g<name> or \g'name' is a subroutine call by name and \g<n> or \g'n'
6707        is a subroutine call by number (Oniguruma syntax). In fact, the value        is a subroutine call by number (Oniguruma syntax). In fact, the value
6708        -ESC_g is returned only for these cases. So we don't need to check for <        ESC_g is returned only for these cases. So we don't need to check for <
6709        or ' if the value is -ESC_g. For the Perl syntax \g{n} the value is        or ' if the value is ESC_g. For the Perl syntax \g{n} the value is
6710        -ESC_REF+n, and for the Perl syntax \g{name} the result is -ESC_k (as        ESC_REF+n, and for the Perl syntax \g{name} the result is ESC_k (as
6711        that is a synonym for a named back reference). */        that is a synonym for a named back reference). */
6712    
6713        if (-c == ESC_g)        if (escape == ESC_g)
6714          {          {
6715          const pcre_uchar *p;          const pcre_uchar *p;
6716          save_hwm = cd->hwm;   /* Normally this is set when '(' is read */          save_hwm = cd->hwm;   /* Normally this is set when '(' is read */
# Line 6698  for (;; ptr++) Line 6766  for (;; ptr++)
6766        /* \k<name> or \k'name' is a back reference by name (Perl syntax).        /* \k<name> or \k'name' is a back reference by name (Perl syntax).
6767        We also support \k{name} (.NET syntax).  */        We also support \k{name} (.NET syntax).  */
6768    
6769        if (-c == ESC_k)        if (escape == ESC_k)
6770          {          {
6771          if ((ptr[1] != CHAR_LESS_THAN_SIGN &&          if ((ptr[1] != CHAR_LESS_THAN_SIGN &&
6772            ptr[1] != CHAR_APOSTROPHE && ptr[1] != CHAR_LEFT_CURLY_BRACKET))            ptr[1] != CHAR_APOSTROPHE && ptr[1] != CHAR_LEFT_CURLY_BRACKET))
# Line 6717  for (;; ptr++) Line 6785  for (;; ptr++)
6785        not set to cope with cases like (?=(\w+))\1: which would otherwise set        not set to cope with cases like (?=(\w+))\1: which would otherwise set
6786        ':' later. */        ':' later. */
6787    
6788        if (-c >= ESC_REF)        if (escape >= ESC_REF)
6789          {          {
6790          open_capitem *oc;          open_capitem *oc;
6791          recno = -c - ESC_REF;          recno = escape - ESC_REF;
6792    
6793          HANDLE_REFERENCE:    /* Come here from named backref handling */          HANDLE_REFERENCE:    /* Come here from named backref handling */
6794          if (firstchar == REQ_UNSET) firstchar = REQ_NONE;          if (firstchar == REQ_UNSET) firstchar = REQ_NONE;
# Line 6747  for (;; ptr++) Line 6815  for (;; ptr++)
6815        /* So are Unicode property matches, if supported. */        /* So are Unicode property matches, if supported. */
6816    
6817  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
6818        else if (-c == ESC_P || -c == ESC_p)        else if (escape == ESC_P || escape == ESC_p)
6819          {          {
6820          BOOL negated;          BOOL negated;
6821          int pdata;          int pdata;
6822          int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr);          int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr);
6823          if (ptype < 0) goto FAILED;          if (ptype < 0) goto FAILED;
6824          previous = code;          previous = code;
6825          *code++ = ((-c == ESC_p) != negated)? OP_PROP : OP_NOTPROP;          *code++ = ((escape == ESC_p) != negated)? OP_PROP : OP_NOTPROP;
6826          *code++ = ptype;          *code++ = ptype;
6827          *code++ = pdata;          *code++ = pdata;
6828          }          }
# Line 6763  for (;; ptr++) Line 6831  for (;; ptr++)
6831        /* If Unicode properties are not supported, \X, \P, and \p are not        /* If Unicode properties are not supported, \X, \P, and \p are not
6832        allowed. */        allowed. */
6833    
6834        else if (-c == ESC_X || -c == ESC_P || -c == ESC_p)        else if (escape == ESC_X || escape == ESC_P || escape == ESC_p)
6835          {          {
6836          *errorcodeptr = ERR45;          *errorcodeptr = ERR45;
6837          goto FAILED;          goto FAILED;
# Line 6778  for (;; ptr++) Line 6846  for (;; ptr++)
6846    
6847        else        else
6848          {          {
6849          if ((-c == ESC_b || -c == ESC_B) && cd->max_lookbehind == 0)          if ((escape == ESC_b || escape == ESC_B) && cd->max_lookbehind == 0)
6850            cd->max_lookbehind = 1;            cd->max_lookbehind = 1;
6851  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
6852          if (-c >= ESC_DU && -c <= ESC_wu)          if (escape >= ESC_DU && escape <= ESC_wu)
6853            {            {
6854            nestptr = ptr + 1;                   /* Where to resume */            nestptr = ptr + 1;                   /* Where to resume */
6855            ptr = substitutes[-c - ESC_DU] - 1;  /* Just before substitute */            ptr = substitutes[escape - ESC_DU] - 1;  /* Just before substitute */
6856            }            }
6857          else          else
6858  #endif  #endif
# Line 6792  for (;; ptr++) Line 6860  for (;; ptr++)
6860          so that it works in DFA mode and in lookbehinds. */          so that it works in DFA mode and in lookbehinds. */
6861    
6862            {            {
6863            previous = (-c > ESC_b && -c < ESC_Z)? code : NULL;            previous = (escape > ESC_b && escape < ESC_Z)? code : NULL;
6864            *code++ = (!utf && c == -ESC_C)? OP_ALLANY : -c;            *code++ = (!utf && escape == ESC_C)? OP_ALLANY : escape;
6865            }            }
6866          }          }
6867        continue;        continue;
# Line 6803  for (;; ptr++) Line 6871  for (;; ptr++)
6871      a value > 127. We set its representation in the length/buffer, and then      a value > 127. We set its representation in the length/buffer, and then
6872      handle it as a data character. */      handle it as a data character. */
6873    
6874  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
6875      if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)      if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)
6876        mclength = PRIV(ord2utf)(c, mcbuffer);        mclength = PRIV(ord2utf)(c, mcbuffer);
6877      else      else
# Line 6826  for (;; ptr++) Line 6894  for (;; ptr++)
6894      mclength = 1;      mclength = 1;
6895      mcbuffer[0] = c;      mcbuffer[0] = c;
6896    
6897  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
6898      if (utf && HAS_EXTRALEN(c))      if (utf && HAS_EXTRALEN(c))
6899        ACROSSCHAR(TRUE, ptr[1], mcbuffer[mclength++] = *(++ptr));        ACROSSCHAR(TRUE, ptr[1], mcbuffer[mclength++] = *(++ptr));
6900  #endif  #endif
# Line 6836  for (;; ptr++) Line 6904  for (;; ptr++)
6904    
6905      ONE_CHAR:      ONE_CHAR:
6906      previous = code;      previous = code;
6907    
6908        /* For caseless UTF-8 mode when UCP support is available, check whether
6909        this character has more than one other case. If so, generate a special
6910        OP_PROP item instead of OP_CHARI. */
6911    
6912    #ifdef SUPPORT_UCP
6913        if (utf && (options & PCRE_CASELESS) != 0)
6914          {
6915          GETCHAR(c, mcbuffer);
6916          if ((c = UCD_CASESET(c)) != 0)
6917            {
6918            *code++ = OP_PROP;
6919            *code++ = PT_CLIST;
6920            *code++ = c;
6921            if (firstchar == REQ_UNSET) firstchar = zerofirstchar = REQ_NONE;
6922            break;
6923            }
6924          }
6925    #endif
6926    
6927        /* Caseful matches, or not one of the multicase characters. */
6928    
6929      *code++ = ((options & PCRE_CASELESS) != 0)? OP_CHARI : OP_CHAR;      *code++ = ((options & PCRE_CASELESS) != 0)? OP_CHARI : OP_CHAR;
6930      for (c = 0; c < mclength; c++) *code++ = mcbuffer[c];      for (c = 0; c < mclength; c++) *code++ = mcbuffer[c];
6931    
# Line 7535  Returns:        pointer to compiled data Line 7625  Returns:        pointer to compiled data
7625                  with errorptr and erroroffset set                  with errorptr and erroroffset set
7626  */  */
7627    
7628  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
7629  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION
7630  pcre_compile(const char *pattern, int options, const char **errorptr,  pcre_compile(const char *pattern, int options, const char **errorptr,
7631    int *erroroffset, const unsigned char *tables)    int *erroroffset, const unsigned char *tables)
7632  #else  #elif defined COMPILE_PCRE16
7633  PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION
7634  pcre16_compile(PCRE_SPTR16 pattern, int options, const char **errorptr,  pcre16_compile(PCRE_SPTR16 pattern, int options, const char **errorptr,
7635    int *erroroffset, const unsigned char *tables)    int *erroroffset, const unsigned char *tables)
7636    #elif defined COMPILE_PCRE32
7637    PCRE_EXP_DEFN pcre32 * PCRE_CALL_CONVENTION
7638    pcre32_compile(PCRE_SPTR32 pattern, int options, const char **errorptr,
7639      int *erroroffset, const unsigned char *tables)
7640  #endif  #endif
7641  {  {
7642  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
7643  return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, tables);  return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
7644  #else  #elif defined COMPILE_PCRE16
7645  return pcre16_compile2(pattern, options, NULL, errorptr, erroroffset, tables);  return pcre16_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
7646    #elif defined COMPILE_PCRE32
7647    return pcre32_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
7648  #endif  #endif
7649  }  }
7650    
7651    
7652  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
7653  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION
7654  pcre_compile2(const char *pattern, int options, int *errorcodeptr,  pcre_compile2(const char *pattern, int options, int *errorcodeptr,
7655    const char **errorptr, int *erroroffset, const unsigned char *tables)    const char **errorptr, int *erroroffset, const unsigned char *tables)
7656  #else  #elif defined COMPILE_PCRE16
7657  PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION
7658  pcre16_compile2(PCRE_SPTR16 pattern, int options, int *errorcodeptr,  pcre16_compile2(PCRE_SPTR16 pattern, int options, int *errorcodeptr,
7659    const char **errorptr, int *erroroffset, const unsigned char *tables)    const char **errorptr, int *erroroffset, const unsigned char *tables)
7660    #elif defined COMPILE_PCRE32
7661    PCRE_EXP_DEFN pcre32 * PCRE_CALL_CONVENTION
7662    pcre32_compile2(PCRE_SPTR32 pattern, int options, int *errorcodeptr,
7663      const char **errorptr, int *erroroffset, const unsigned char *tables)
7664  #endif  #endif
7665  {  {
7666  REAL_PCRE *re;  REAL_PCRE *re;
# Line 7646  while (ptr[skipatstart] == CHAR_LEFT_PAR Line 7746  while (ptr[skipatstart] == CHAR_LEFT_PAR
7746    if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF_RIGHTPAR, 6) == 0)    if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF_RIGHTPAR, 6) == 0)
7747      { skipatstart += 8; options |= PCRE_UTF16; continue; }      { skipatstart += 8; options |= PCRE_UTF16; continue; }
7748  #endif  #endif
7749    #ifdef COMPILE_PCRE32
7750      if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF_RIGHTPAR, 6) == 0)
7751        { skipatstart += 8; options |= PCRE_UTF32; continue; }
7752    #endif
7753    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)
7754      { skipatstart += 6; options |= PCRE_UCP; continue; }      { skipatstart += 6; options |= PCRE_UCP; continue; }
7755    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 7674  while (ptr[skipatstart] == CHAR_LEFT_PAR Line 7778  while (ptr[skipatstart] == CHAR_LEFT_PAR
7778    else break;    else break;
7779    }    }
7780    
7781  /* PCRE_UTF16 has the same value as PCRE_UTF8. */  /* PCRE_UTF(16|32) have the same value as PCRE_UTF8. */
7782  utf = (options & PCRE_UTF8) != 0;  utf = (options & PCRE_UTF8) != 0;
7783    
7784  /* Can't support UTF unless PCRE has been compiled to include the code. The  /* Can't support UTF unless PCRE has been compiled to include the code. The
# Line 7686  not used here. */ Line 7790  not used here. */
7790  if (utf && (options & PCRE_NO_UTF8_CHECK) == 0 &&  if (utf && (options & PCRE_NO_UTF8_CHECK) == 0 &&
7791       (errorcode = PRIV(valid_utf)((PCRE_PUCHAR)pattern, -1, erroroffset)) != 0)       (errorcode = PRIV(valid_utf)((PCRE_PUCHAR)pattern, -1, erroroffset)) != 0)
7792    {    {
7793  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
7794    errorcode = ERR44;    errorcode = ERR44;
7795  #else  #elif defined COMPILE_PCRE16
7796    errorcode = ERR74;    errorcode = ERR74;
7797    #elif defined COMPILE_PCRE32
7798      errorcode = ERR77;
7799  #endif  #endif
7800    goto PCRE_EARLY_ERROR_RETURN2;    goto PCRE_EARLY_ERROR_RETURN2;
7801    }    }
# Line 7853  re->name_count = cd->names_found; Line 7959  re->name_count = cd->names_found;
7959  re->ref_count = 0;  re->ref_count = 0;
7960  re->tables = (tables == PRIV(default_tables))? NULL : tables;  re->tables = (tables == PRIV(default_tables))? NULL : tables;
7961  re->nullpad = NULL;  re->nullpad = NULL;
7962    #ifdef COMPILE_PCRE32
7963    re->dummy1 = re->dummy2 = 0;
7964    #endif
7965    
7966  /* The starting points of the name/number translation table and of the code are  /* The starting points of the name/number translation table and of the code are
7967  passed around in the compile data block. The start/end pattern and initial  passed around in the compile data block. The start/end pattern and initial
# Line 8015  if ((re->options & PCRE_ANCHORED) == 0) Line 8124  if ((re->options & PCRE_ANCHORED) == 0)
8124        firstchar = find_firstassertedchar(codestart, FALSE);        firstchar = find_firstassertedchar(codestart, FALSE);
8125      if (firstchar >= 0)   /* Remove caseless flag for non-caseable chars */      if (firstchar >= 0)   /* Remove caseless flag for non-caseable chars */
8126        {        {
8127  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
8128        re->first_char = firstchar & 0xff;        re->first_char = firstchar & 0xff;
8129  #else  #elif defined COMPILE_PCRE16
 #ifdef COMPILE_PCRE16  
8130        re->first_char = firstchar & 0xffff;        re->first_char = firstchar & 0xffff;
8131  #endif  #elif defined COMPILE_PCRE32
8132          re->first_char = firstchar & ~REQ_MASK;
8133  #endif  #endif
8134        if ((firstchar & REQ_CASELESS) != 0)        if ((firstchar & REQ_CASELESS) != 0)
8135          {          {
# Line 8057  bytes. */ Line 8166  bytes. */
8166  if (reqchar >= 0 &&  if (reqchar >= 0 &&
8167       ((re->options & PCRE_ANCHORED) == 0 || (reqchar & REQ_VARY) != 0))       ((re->options & PCRE_ANCHORED) == 0 || (reqchar & REQ_VARY) != 0))
8168    {    {
8169  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
8170    re->req_char = reqchar & 0xff;    re->req_char = reqchar & 0xff;
8171  #else  #elif defined COMPILE_PCRE16
 #ifdef COMPILE_PCRE16  
8172    re->req_char = reqchar & 0xffff;    re->req_char = reqchar & 0xffff;
8173  #endif  #elif defined COMPILE_PCRE32
8174      re->req_char = reqchar & ~REQ_MASK;
8175  #endif  #endif
8176    if ((reqchar & REQ_CASELESS) != 0)    if ((reqchar & REQ_CASELESS) != 0)
8177      {      {
# Line 8114  if ((re->flags & PCRE_REQCHSET) != 0) Line 8223  if ((re->flags & PCRE_REQCHSET) != 0)
8223      else printf("Req char = \\x%02x%s\n", ch, caseless);      else printf("Req char = \\x%02x%s\n", ch, caseless);
8224    }    }
8225    
8226  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
8227  pcre_printint((pcre *)re, stdout, TRUE);  pcre_printint((pcre *)re, stdout, TRUE);
8228  #else  #elif defined COMPILE_PCRE16
8229  pcre16_printint((pcre *)re, stdout, TRUE);  pcre16_printint((pcre *)re, stdout, TRUE);
8230    #elif defined COMPILE_PCRE32
8231    pcre32_printint((pcre *)re, stdout, TRUE);
8232  #endif  #endif
8233    
8234  /* This check is done here in the debugging case so that the code that  /* This check is done here in the debugging case so that the code that
# Line 8133  if (code - codestart > length) Line 8244  if (code - codestart > length)
8244    }    }
8245  #endif   /* PCRE_DEBUG */  #endif   /* PCRE_DEBUG */
8246    
8247  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
8248  return (pcre *)re;  return (pcre *)re;
8249  #else  #elif defined COMPILE_PCRE16
8250  return (pcre16 *)re;  return (pcre16 *)re;
8251    #elif defined COMPILE_PCRE32
8252    return (pcre32 *)re;
8253  #endif  #endif
8254  }  }
8255    

Legend:
Removed from v.1045  
changed lines
  Added in v.1059

  ViewVC Help
Powered by ViewVC 1.1.5