/[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 994 by ph10, Tue Jul 10 14:29:26 2012 UTC revision 1056 by chpe, Tue Oct 16 15:53:41 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 68  COMPILE_PCREx macro will already be appr Line 68  COMPILE_PCREx macro will already be appr
68    
69  /* Macro for setting individual bits in class bitmaps. */  /* Macro for setting individual bits in class bitmaps. */
70    
71  #define SETBIT(a,b) a[b/8] |= (1 << (b%8))  #define SETBIT(a,b) a[(b)/8] |= (1 << ((b)&7))
72    
73  /* Maximum length value to check against when making sure that the integer that  /* Maximum length value to check against when making sure that the integer that
74  holds the compiled pattern length does not overflow. We make it a bit less than  holds the compiled pattern length does not overflow. We make it a bit less than
# Line 77  to check them every time. */ Line 77  to check them every time. */
77    
78  #define OFLOW_MAX (INT_MAX - 20)  #define OFLOW_MAX (INT_MAX - 20)
79    
80    /* Definitions to allow mutual recursion */
81    
82    static int
83      add_list_to_class(pcre_uint8 *, pcre_uchar **, int, compile_data *,
84        const pcre_uint32 *, unsigned int);
85    
86    static BOOL
87      compile_regex(int, pcre_uchar **, const pcre_uchar **, int *, BOOL, BOOL,
88        int, int, int *, int *, branch_chain *, compile_data *, int *);
89    
90    
91    
92  /*************************************************  /*************************************************
93  *      Code parameters and static tables         *  *      Code parameters and static tables         *
# Line 112  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 492  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 631  static const pcre_uint8 ebcdic_chartab[] Line 644  static const pcre_uint8 ebcdic_chartab[]
644  #endif  #endif
645    
646    
 /* Definition to allow mutual recursion */  
   
 static BOOL  
   compile_regex(int, pcre_uchar **, const pcre_uchar **, int *, BOOL, BOOL, int, int,  
     int *, int *, branch_chain *, compile_data *, int *);  
   
647    
648    
649  /*************************************************  /*************************************************
# Line 789  else if ((i = escapes[c - CHAR_0]) != 0) Line 796  else if ((i = escapes[c - CHAR_0]) != 0)
796    
797  #else           /* EBCDIC coding */  #else           /* EBCDIC coding */
798  /* Not alphanumeric */  /* Not alphanumeric */
799  else if (c < 'a' || (!MAX_255(c) || (ebcdic_chartab[c] & 0x0E) == 0)) {}  else if (c < CHAR_a || (!MAX_255(c) || (ebcdic_chartab[c] & 0x0E) == 0)) {}
800  else if ((i = escapes[c - 0x48]) != 0)  c = i;  else if ((i = escapes[c - 0x48]) != 0)  c = i;
801  #endif  #endif
802    
# Line 833  else Line 840  else
840  #endif  #endif
841            }            }
842    
843  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
844          if (c > (utf ? 0x10ffff : 0xff))          if (c > (utf ? 0x10ffff : 0xff))
845  #else  #elif defined COMPILE_PCRE16
 #ifdef COMPILE_PCRE16  
846          if (c > (utf ? 0x10ffff : 0xffff))          if (c > (utf ? 0x10ffff : 0xffff))
847  #endif  #elif defined COMPILE_PCRE32
848            if (utf && c > 0x10ffff)
849  #endif  #endif
850            {            {
851            *errorcodeptr = ERR76;            *errorcodeptr = ERR76;
# Line 1064  else Line 1071  else
1071          c = (c << 4) + cc - ((cc >= CHAR_0)? CHAR_0 : (CHAR_A - 10));          c = (c << 4) + cc - ((cc >= CHAR_0)? CHAR_0 : (CHAR_A - 10));
1072  #endif  #endif
1073    
1074  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
1075          if (c > (utf ? 0x10ffff : 0xff)) { c = -1; break; }          if (c > (utf ? 0x10ffff : 0xff)) { c = -1; break; }
1076  #else  #elif defined COMPILE_PCRE16
 #ifdef COMPILE_PCRE16  
1077          if (c > (utf ? 0x10ffff : 0xffff)) { c = -1; break; }          if (c > (utf ? 0x10ffff : 0xffff)) { c = -1; break; }
1078  #endif  #elif defined COMPILE_PCRE32
1079            if (utf && c > 0x10ffff) { c = -1; break; }
1080  #endif  #endif
1081          }          }
1082    
# Line 1362  Arguments: Line 1369  Arguments:
1369    name         name to seek, or NULL if seeking a numbered subpattern    name         name to seek, or NULL if seeking a numbered subpattern
1370    lorn         name length, or subpattern number if name is NULL    lorn         name length, or subpattern number if name is NULL
1371    xmode        TRUE if we are in /x mode    xmode        TRUE if we are in /x mode
1372    utf          TRUE if we are in UTF-8 / UTF-16 mode    utf          TRUE if we are in UTF-8 / UTF-16 / UTF-32 mode
1373    count        pointer to the current capturing subpattern number (updated)    count        pointer to the current capturing subpattern number (updated)
1374    
1375  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 1596  Arguments: Line 1603  Arguments:
1603    name         name to seek, or NULL if seeking a numbered subpattern    name         name to seek, or NULL if seeking a numbered subpattern
1604    lorn         name length, or subpattern number if name is NULL    lorn         name length, or subpattern number if name is NULL
1605    xmode        TRUE if we are in /x mode    xmode        TRUE if we are in /x mode
1606    utf          TRUE if we are in UTF-8 / UTF-16 mode    utf          TRUE if we are in UTF-8 / UTF-16 / UTF-32 mode
1607    
1608  Returns:       the number of the found subpattern, or -1 if not found  Returns:       the number of the found subpattern, or -1 if not found
1609  */  */
# Line 1699  and doing the check at the end; a flag s Line 1706  and doing the check at the end; a flag s
1706    
1707  Arguments:  Arguments:
1708    code     points to the start of the pattern (the bracket)    code     points to the start of the pattern (the bracket)
1709    utf      TRUE in UTF-8 / UTF-16 mode    utf      TRUE in UTF-8 / UTF-16 / UTF-32 mode
1710    atend    TRUE if called when the pattern is complete    atend    TRUE if called when the pattern is complete
1711    cd       the "compile data" structure    cd       the "compile data" structure
1712    
# Line 1833  for (;;) Line 1840  for (;;)
1840      case OP_NOTI:      case OP_NOTI:
1841      branchlength++;      branchlength++;
1842      cc += 2;      cc += 2;
1843  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
1844      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1845  #endif  #endif
1846      break;      break;
# Line 1847  for (;;) Line 1854  for (;;)
1854      case OP_NOTEXACTI:      case OP_NOTEXACTI:
1855      branchlength += GET2(cc,1);      branchlength += GET2(cc,1);
1856      cc += 2 + IMM2_SIZE;      cc += 2 + IMM2_SIZE;
1857  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
1858      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1859  #endif  #endif
1860      break;      break;
1861    
1862      case OP_TYPEEXACT:      case OP_TYPEEXACT:
1863      branchlength += GET2(cc,1);      branchlength += GET2(cc,1);
1864      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)
1865          cc += 2;
1866      cc += 1 + IMM2_SIZE + 1;      cc += 1 + IMM2_SIZE + 1;
1867      break;      break;
1868    
# Line 1889  for (;;) Line 1897  for (;;)
1897    
1898      /* Check a class for variable quantification */      /* Check a class for variable quantification */
1899    
1900  #if defined SUPPORT_UTF || defined COMPILE_PCRE16  #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1901      case OP_XCLASS:      case OP_XCLASS:
1902      cc += GET(cc, 1) - PRIV(OP_lengths)[OP_CLASS];      cc += GET(cc, 1) - PRIV(OP_lengths)[OP_CLASS];
1903      /* Fall through */      /* Fall through */
# Line 2028  length. Line 2036  length.
2036    
2037  Arguments:  Arguments:
2038    code        points to start of expression    code        points to start of expression
2039    utf         TRUE in UTF-8 / UTF-16 mode    utf         TRUE in UTF-8 / UTF-16 / UTF-32 mode
2040    number      the required bracket number or negative to find a lookbehind    number      the required bracket number or negative to find a lookbehind
2041    
2042  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 2092  for (;;) Line 2100  for (;;)
2100        case OP_TYPEMINUPTO:        case OP_TYPEMINUPTO:
2101        case OP_TYPEEXACT:        case OP_TYPEEXACT:
2102        case OP_TYPEPOSUPTO:        case OP_TYPEPOSUPTO:
2103        if (code[1 + IMM2_SIZE] == OP_PROP        if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
2104          || code[1 + IMM2_SIZE] == OP_NOTPROP) code += 2;          code += 2;
2105        break;        break;
2106    
2107        case OP_MARK:        case OP_MARK:
# Line 2115  for (;;) Line 2123  for (;;)
2123    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
2124    arrange to skip the extra bytes. */    arrange to skip the extra bytes. */
2125    
2126  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
2127      if (utf) switch(c)      if (utf) switch(c)
2128        {        {
2129        case OP_CHAR:        case OP_CHAR:
# Line 2167  instance of OP_RECURSE. Line 2175  instance of OP_RECURSE.
2175    
2176  Arguments:  Arguments:
2177    code        points to start of expression    code        points to start of expression
2178    utf         TRUE in UTF-8 / UTF-16 mode    utf         TRUE in UTF-8 / UTF-16 / UTF-32 mode
2179    
2180  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
2181  */  */
# Line 2212  for (;;) Line 2220  for (;;)
2220        case OP_TYPEUPTO:        case OP_TYPEUPTO:
2221        case OP_TYPEMINUPTO:        case OP_TYPEMINUPTO:
2222        case OP_TYPEEXACT:        case OP_TYPEEXACT:
2223        if (code[1 + IMM2_SIZE] == OP_PROP        if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
2224          || code[1 + IMM2_SIZE] == OP_NOTPROP) code += 2;          code += 2;
2225        break;        break;
2226    
2227        case OP_MARK:        case OP_MARK:
# Line 2235  for (;;) Line 2243  for (;;)
2243      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
2244      to arrange to skip the extra bytes. */      to arrange to skip the extra bytes. */
2245    
2246  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
2247      if (utf) switch(c)      if (utf) switch(c)
2248        {        {
2249        case OP_CHAR:        case OP_CHAR:
# Line 2321  bracket whose current branch will alread Line 2329  bracket whose current branch will alread
2329  Arguments:  Arguments:
2330    code        points to start of search    code        points to start of search
2331    endcode     points to where to stop    endcode     points to where to stop
2332    utf         TRUE if in UTF-8 / UTF-16 mode    utf         TRUE if in UTF-8 / UTF-16 / UTF-32 mode
2333    cd          contains pointers to tables etc.    cd          contains pointers to tables etc.
2334    
2335  Returns:      TRUE if what is matched could be empty  Returns:      TRUE if what is matched could be empty
# Line 2538  for (code = first_significant_code(code Line 2546  for (code = first_significant_code(code
2546      case OP_TYPEUPTO:      case OP_TYPEUPTO:
2547      case OP_TYPEMINUPTO:      case OP_TYPEMINUPTO:
2548      case OP_TYPEPOSUPTO:      case OP_TYPEPOSUPTO:
2549      if (code[1 + IMM2_SIZE] == OP_PROP      if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
2550        || code[1 + IMM2_SIZE] == OP_NOTPROP) code += 2;        code += 2;
2551      break;      break;
2552    
2553      /* End of branch */      /* End of branch */
# Line 2554  for (code = first_significant_code(code Line 2562  for (code = first_significant_code(code
2562      /* In UTF-8 mode, STAR, MINSTAR, POSSTAR, QUERY, MINQUERY, POSQUERY, UPTO,      /* In UTF-8 mode, STAR, MINSTAR, POSSTAR, QUERY, MINQUERY, POSQUERY, UPTO,
2563      MINUPTO, and POSUPTO may be followed by a multibyte character */      MINUPTO, and POSUPTO may be followed by a multibyte character */
2564    
2565  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
2566      case OP_STAR:      case OP_STAR:
2567      case OP_STARI:      case OP_STARI:
2568      case OP_MINSTAR:      case OP_MINSTAR:
# Line 2620  Arguments: Line 2628  Arguments:
2628    code        points to start of the recursion    code        points to start of the recursion
2629    endcode     points to where to stop (current RECURSE item)    endcode     points to where to stop (current RECURSE item)
2630    bcptr       points to the chain of current (unclosed) branch starts    bcptr       points to the chain of current (unclosed) branch starts
2631    utf         TRUE if in UTF-8 / UTF-16 mode    utf         TRUE if in UTF-8 / UTF-16 / UTF-32 mode
2632    cd          pointers to tables etc    cd          pointers to tables etc
2633    
2634  Returns:      TRUE if what is matched could be empty  Returns:      TRUE if what is matched could be empty
# Line 2767  value in the reference (which is a group Line 2775  value in the reference (which is a group
2775  Arguments:  Arguments:
2776    group      points to the start of the group    group      points to the start of the group
2777    adjust     the amount by which the group is to be moved    adjust     the amount by which the group is to be moved
2778    utf        TRUE in UTF-8 / UTF-16 mode    utf        TRUE in UTF-8 / UTF-16 / UTF-32 mode
2779    cd         contains pointers to tables etc.    cd         contains pointers to tables etc.
2780    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
2781    
# Line 2871  PUT(previous_callout, 2 + LINK_SIZE, len Line 2879  PUT(previous_callout, 2 + LINK_SIZE, len
2879  *************************************************/  *************************************************/
2880    
2881  /* 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
2882  with UCP support. It searches up the characters, looking for internal ranges of  with UCP support. It searches up the characters, looking for ranges of
2883  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
2884  start address.  start address. A character with multiple other cases is returned on its own
2885    with a special return value.
2886    
2887  Arguments:  Arguments:
2888    cptr        points to starting character value; updated    cptr        points to starting character value; updated
# Line 2881  Arguments: Line 2890  Arguments:
2890    ocptr       where to put start of othercase range    ocptr       where to put start of othercase range
2891    odptr       where to put end of othercase range    odptr       where to put end of othercase range
2892    
2893  Yield:        TRUE when range returned; FALSE when no more  Yield:        -1 when no more
2894                   0 when a range is returned
2895                  >0 the CASESET offset for char with multiple other cases
2896                    in this case, ocptr contains the original
2897  */  */
2898    
2899  static BOOL  static int
2900  get_othercase_range(unsigned int *cptr, unsigned int d, unsigned int *ocptr,  get_othercase_range(unsigned int *cptr, unsigned int d, unsigned int *ocptr,
2901    unsigned int *odptr)    unsigned int *odptr)
2902  {  {
2903  unsigned int c, othercase, next;  unsigned int c, othercase, next;
2904    int co;
2905    
2906    /* Find the first character that has an other case. If it has multiple other
2907    cases, return its case offset value. */
2908    
2909  for (c = *cptr; c <= d; c++)  for (c = *cptr; c <= d; c++)
2910    { if ((othercase = UCD_OTHERCASE(c)) != c) break; }    {
2911      if ((co = UCD_CASESET(c)) != 0)
2912        {
2913        *ocptr = c++;   /* Character that has the set */
2914        *cptr = c;      /* Rest of input range */
2915        return co;
2916        }
2917      if ((othercase = UCD_OTHERCASE(c)) != c) break;
2918      }
2919    
2920  if (c > d) return FALSE;  if (c > d) return -1;  /* Reached end of range */
2921    
2922  *ocptr = othercase;  *ocptr = othercase;
2923  next = othercase + 1;  next = othercase + 1;
# Line 2904  for (++c; c <= d; c++) Line 2928  for (++c; c <= d; c++)
2928    next++;    next++;
2929    }    }
2930    
2931  *odptr = next - 1;  *odptr = next - 1;     /* End of othercase range */
2932  *cptr = c;  *cptr = c;             /* Rest of input range */
2933    return 0;
 return TRUE;  
2934  }  }
2935    
2936    
# Line 2931  Returns:       TRUE if auto-possessifyin Line 2954  Returns:       TRUE if auto-possessifyin
2954  static BOOL  static BOOL
2955  check_char_prop(int c, int ptype, int pdata, BOOL negated)  check_char_prop(int c, int ptype, int pdata, BOOL negated)
2956  {  {
2957    #ifdef SUPPORT_UCP
2958    const pcre_uint32 *p;
2959    #endif
2960    
2961  const ucd_record *prop = GET_UCD(c);  const ucd_record *prop = GET_UCD(c);
2962    
2963  switch(ptype)  switch(ptype)
2964    {    {
2965    case PT_LAMP:    case PT_LAMP:
# Line 2969  switch(ptype) Line 2997  switch(ptype)
2997    return (PRIV(ucp_gentype)[prop->chartype] == ucp_L ||    return (PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
2998            PRIV(ucp_gentype)[prop->chartype] == ucp_N ||            PRIV(ucp_gentype)[prop->chartype] == ucp_N ||
2999            c == CHAR_UNDERSCORE) == negated;            c == CHAR_UNDERSCORE) == negated;
3000    
3001    #ifdef SUPPORT_UCP
3002      case PT_CLIST:
3003      p = PRIV(ucd_caseless_sets) + prop->caseset;
3004      for (;;)
3005        {
3006        if ((unsigned int)c < *p) return !negated;
3007        if ((unsigned int)c == *p++) return negated;
3008        }
3009      break;  /* Control never reaches here */
3010    #endif
3011    }    }
3012    
3013  return FALSE;  return FALSE;
3014  }  }
3015  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
# Line 2986  sense to automatically possessify the re Line 3026  sense to automatically possessify the re
3026    
3027  Arguments:  Arguments:
3028    previous      pointer to the repeated opcode    previous      pointer to the repeated opcode
3029    utf           TRUE in UTF-8 / UTF-16 mode    utf           TRUE in UTF-8 / UTF-16 / UTF-32 mode
3030    ptr           next character in pattern    ptr           next character in pattern
3031    options       options bits    options       options bits
3032    cd            contains pointers to tables etc.    cd            contains pointers to tables etc.
# Line 2998  static BOOL Line 3038  static BOOL
3038  check_auto_possessive(const pcre_uchar *previous, BOOL utf,  check_auto_possessive(const pcre_uchar *previous, BOOL utf,
3039    const pcre_uchar *ptr, int options, compile_data *cd)    const pcre_uchar *ptr, int options, compile_data *cd)
3040  {  {
3041  pcre_int32 c, next;  pcre_int32 c = NOTACHAR;
3042    pcre_int32 next;
3043  int op_code = *previous++;  int op_code = *previous++;
3044    
3045  /* Skip whitespace and comments in extended mode */  /* Skip whitespace and comments in extended mode */
# Line 3072  if (*ptr == CHAR_ASTERISK || *ptr == CHA Line 3113  if (*ptr == CHAR_ASTERISK || *ptr == CHA
3113    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)
3114      return FALSE;      return FALSE;
3115    
3116  /* 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. */  
3117    
3118  if (next >= 0) switch(op_code)  if (op_code == OP_CHAR || op_code == OP_CHARI ||
3119        op_code == OP_NOT || op_code == OP_NOTI)
3120    {    {
   case OP_CHAR:  
3121  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3122    GETCHARTEST(c, previous);    GETCHARTEST(c, previous);
3123  #else  #else
3124    c = *previous;    c = *previous;
3125  #endif  #endif
3126    return c != next;    }
3127    
3128    /* 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
3129    Unicode property support, we can use it to test the other case of  the next item is a character. */
   high-valued characters. */  
3130    
3131    case OP_CHARI:  if (next >= 0)
3132  #ifdef SUPPORT_UTF    {
3133    GETCHARTEST(c, previous);    /* For a caseless UTF match, the next character may have more than one other
3134  #else    case, which maps to the special PT_CLIST property. Check this first. */
3135    c = *previous;  
 #endif  
   if (c == next) return FALSE;  
 #ifdef SUPPORT_UTF  
   if (utf)  
     {  
     unsigned int othercase;  
     if (next < 128) othercase = cd->fcc[next]; else  
3136  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3137      othercase = UCD_OTHERCASE((unsigned int)next);    if (utf && (unsigned int)c != NOTACHAR && (options & PCRE_CASELESS) != 0)
3138  #else      {
3139      othercase = NOTACHAR;      int ocs = UCD_CASESET(next);
3140  #endif      if (ocs > 0) return check_char_prop(c, PT_CLIST, ocs, op_code >= OP_NOT);
     return (unsigned int)c != othercase;  
3141      }      }
   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;  
3142  #endif  #endif
   return c == next;  
3143    
3144    case OP_NOTI:    switch(op_code)
3145        {
3146        case OP_CHAR:
3147        return c != next;
3148    
3149        /* For CHARI (caseless character) we must check the other case. If we have
3150        Unicode property support, we can use it to test the other case of
3151        high-valued characters. We know that next can have only one other case,
3152        because multi-other-case characters are dealt with above. */
3153    
3154        case OP_CHARI:
3155        if (c == next) return FALSE;
3156  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3157    GETCHARTEST(c, previous);      if (utf)
3158          {
3159          unsigned int othercase;
3160          if (next < 128) othercase = cd->fcc[next]; else
3161    #ifdef SUPPORT_UCP
3162          othercase = UCD_OTHERCASE((unsigned int)next);
3163  #else  #else
3164    c = *previous;        othercase = NOTACHAR;
3165  #endif  #endif
3166    if (c == next) return TRUE;        return (unsigned int)c != othercase;
3167          }
3168        else
3169    #endif  /* SUPPORT_UTF */
3170        return (c != TABLE_GET((unsigned int)next, cd->fcc, next));  /* Not UTF */
3171    
3172        case OP_NOT:
3173        return c == next;
3174    
3175        case OP_NOTI:
3176        if (c == next) return TRUE;
3177  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3178    if (utf)      if (utf)
3179      {        {
3180      unsigned int othercase;        unsigned int othercase;
3181      if (next < 128) othercase = cd->fcc[next]; else        if (next < 128) othercase = cd->fcc[next]; else
3182  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3183      othercase = UCD_OTHERCASE((unsigned int)next);        othercase = UCD_OTHERCASE((unsigned int)next);
3184  #else  #else
3185      othercase = NOTACHAR;        othercase = NOTACHAR;
3186  #endif  #endif
3187      return (unsigned int)c == othercase;        return (unsigned int)c == othercase;
3188      }        }
3189    else      else
3190  #endif  /* SUPPORT_UTF */  #endif  /* SUPPORT_UTF */
3191    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 */
3192    
3193    /* 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.
3194    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. */
3195    
3196    case OP_DIGIT:      case OP_DIGIT:
3197    return next > 255 || (cd->ctypes[next] & ctype_digit) == 0;      return next > 255 || (cd->ctypes[next] & ctype_digit) == 0;
3198    
3199    case OP_NOT_DIGIT:      case OP_NOT_DIGIT:
3200    return next <= 255 && (cd->ctypes[next] & ctype_digit) != 0;      return next <= 255 && (cd->ctypes[next] & ctype_digit) != 0;
3201    
3202    case OP_WHITESPACE:      case OP_WHITESPACE:
3203    return next > 255 || (cd->ctypes[next] & ctype_space) == 0;      return next > 255 || (cd->ctypes[next] & ctype_space) == 0;
3204    
3205    case OP_NOT_WHITESPACE:      case OP_NOT_WHITESPACE:
3206    return next <= 255 && (cd->ctypes[next] & ctype_space) != 0;      return next <= 255 && (cd->ctypes[next] & ctype_space) != 0;
3207    
3208    case OP_WORDCHAR:      case OP_WORDCHAR:
3209    return next > 255 || (cd->ctypes[next] & ctype_word) == 0;      return next > 255 || (cd->ctypes[next] & ctype_word) == 0;
3210    
3211    case OP_NOT_WORDCHAR:      case OP_NOT_WORDCHAR:
3212    return next <= 255 && (cd->ctypes[next] & ctype_word) != 0;      return next <= 255 && (cd->ctypes[next] & ctype_word) != 0;
3213    
3214    case OP_HSPACE:      case OP_HSPACE:
3215    case OP_NOT_HSPACE:      case OP_NOT_HSPACE:
3216    switch(next)      switch(next)
3217      {        {
3218      case 0x09:        HSPACE_CASES:
3219      case 0x20:        return op_code == OP_NOT_HSPACE;
     case 0xa0:  
     case 0x1680:  
     case 0x180e:  
     case 0x2000:  
     case 0x2001:  
     case 0x2002:  
     case 0x2003:  
     case 0x2004:  
     case 0x2005:  
     case 0x2006:  
     case 0x2007:  
     case 0x2008:  
     case 0x2009:  
     case 0x200A:  
     case 0x202f:  
     case 0x205f:  
     case 0x3000:  
     return op_code == OP_NOT_HSPACE;  
     default:  
     return op_code != OP_NOT_HSPACE;  
     }  
3220    
3221    case OP_ANYNL:        default:
3222    case OP_VSPACE:        return op_code != OP_NOT_HSPACE;
3223    case OP_NOT_VSPACE:        }
3224    switch(next)  
3225      {      case OP_ANYNL:
3226      case 0x0a:      case OP_VSPACE:
3227      case 0x0b:      case OP_NOT_VSPACE:
3228      case 0x0c:      switch(next)
3229      case 0x0d:        {
3230      case 0x85:        VSPACE_CASES:
3231      case 0x2028:        return op_code == OP_NOT_VSPACE;
3232      case 0x2029:  
3233      return op_code == OP_NOT_VSPACE;        default:
3234      default:        return op_code != OP_NOT_VSPACE;
3235      return op_code != OP_NOT_VSPACE;        }
     }  
3236    
3237  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3238    case OP_PROP:      case OP_PROP:
3239    return check_char_prop(next, previous[0], previous[1], FALSE);      return check_char_prop(next, previous[0], previous[1], FALSE);
3240    
3241    case OP_NOTPROP:      case OP_NOTPROP:
3242    return check_char_prop(next, previous[0], previous[1], TRUE);      return check_char_prop(next, previous[0], previous[1], TRUE);
3243  #endif  #endif
3244    
3245    default:      default:
3246    return FALSE;      return FALSE;
3247        }
3248    }    }
3249    
   
3250  /* 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
3251  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
3252  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 3232  switch(op_code) Line 3257  switch(op_code)
3257    {    {
3258    case OP_CHAR:    case OP_CHAR:
3259    case OP_CHARI:    case OP_CHARI:
 #ifdef SUPPORT_UTF  
   GETCHARTEST(c, previous);  
 #else  
   c = *previous;  
 #endif  
3260    switch(-next)    switch(-next)
3261      {      {
3262      case ESC_d:      case ESC_d:
# Line 3261  switch(op_code) Line 3281  switch(op_code)
3281      case ESC_H:      case ESC_H:
3282      switch(c)      switch(c)
3283        {        {
3284        case 0x09:        HSPACE_CASES:
       case 0x20:  
       case 0xa0:  
       case 0x1680:  
       case 0x180e:  
       case 0x2000:  
       case 0x2001:  
       case 0x2002:  
       case 0x2003:  
       case 0x2004:  
       case 0x2005:  
       case 0x2006:  
       case 0x2007:  
       case 0x2008:  
       case 0x2009:  
       case 0x200A:  
       case 0x202f:  
       case 0x205f:  
       case 0x3000:  
3285        return -next != ESC_h;        return -next != ESC_h;
3286    
3287        default:        default:
3288        return -next == ESC_h;        return -next == ESC_h;
3289        }        }
# Line 3289  switch(op_code) Line 3292  switch(op_code)
3292      case ESC_V:      case ESC_V:
3293      switch(c)      switch(c)
3294        {        {
3295        case 0x0a:        VSPACE_CASES:
       case 0x0b:  
       case 0x0c:  
       case 0x0d:  
       case 0x85:  
       case 0x2028:  
       case 0x2029:  
3296        return -next != ESC_v;        return -next != ESC_v;
3297    
3298        default:        default:
3299        return -next == ESC_v;        return -next == ESC_v;
3300        }        }
# Line 3401  switch(op_code) Line 3399  switch(op_code)
3399    
3400    
3401  /*************************************************  /*************************************************
3402    *        Add a character or range to a class     *
3403    *************************************************/
3404    
3405    /* This function packages up the logic of adding a character or range of
3406    characters to a class. The character values in the arguments will be within the
3407    valid values for the current mode (8-bit, 16-bit, UTF, etc). This function is
3408    mutually recursive with the function immediately below.
3409    
3410    Arguments:
3411      classbits     the bit map for characters < 256
3412      uchardptr     points to the pointer for extra data
3413      options       the options word
3414      cd            contains pointers to tables etc.
3415      start         start of range character
3416      end           end of range character
3417    
3418    Returns:        the number of < 256 characters added
3419                    the pointer to extra data is updated
3420    */
3421    
3422    static int
3423    add_to_class(pcre_uint8 *classbits, pcre_uchar **uchardptr, int options,
3424      compile_data *cd, pcre_uint32 start, pcre_uint32 end)
3425    {
3426    pcre_uint32 c;
3427    int n8 = 0;
3428    
3429    /* If caseless matching is required, scan the range and process alternate
3430    cases. In Unicode, there are 8-bit characters that have alternate cases that
3431    are greater than 255 and vice-versa. Sometimes we can just extend the original
3432    range. */
3433    
3434    if ((options & PCRE_CASELESS) != 0)
3435      {
3436    #ifdef SUPPORT_UCP
3437      if ((options & PCRE_UTF8) != 0)
3438        {
3439        int rc;
3440        pcre_uint32 oc, od;
3441    
3442        options &= ~PCRE_CASELESS;   /* Remove for recursive calls */
3443        c = start;
3444    
3445        while ((rc = get_othercase_range(&c, end, &oc, &od)) >= 0)
3446          {
3447          /* Handle a single character that has more than one other case. */
3448    
3449          if (rc > 0) n8 += add_list_to_class(classbits, uchardptr, options, cd,
3450            PRIV(ucd_caseless_sets) + rc, oc);
3451    
3452          /* Do nothing if the other case range is within the original range. */
3453    
3454          else if (oc >= start && od <= end) continue;
3455    
3456          /* Extend the original range if there is overlap, noting that if oc < c, we
3457          can't have od > end because a subrange is always shorter than the basic
3458          range. Otherwise, use a recursive call to add the additional range. */
3459    
3460          else if (oc < start && od >= start - 1) start = oc; /* Extend downwards */
3461          else if (od > end && oc <= end + 1) end = od;       /* Extend upwards */
3462          else n8 += add_to_class(classbits, uchardptr, options, cd, oc, od);
3463          }
3464        }
3465      else
3466    #endif  /* SUPPORT_UCP */
3467    
3468      /* Not UTF-mode, or no UCP */
3469    
3470      for (c = start; c <= end && c < 256; c++)
3471        {
3472        SETBIT(classbits, cd->fcc[c]);
3473        n8++;
3474        }
3475      }
3476    
3477    /* Now handle the original range. Adjust the final value according to the bit
3478    length - this means that the same lists of (e.g.) horizontal spaces can be used
3479    in all cases. */
3480    
3481    #if defined COMPILE_PCRE8
3482    #ifdef SUPPORT_UTF
3483      if ((options & PCRE_UTF8) == 0)
3484    #endif
3485      if (end > 0xff) end = 0xff;
3486    
3487    #elif defined COMPILE_PCRE16
3488    #ifdef SUPPORT_UTF
3489      if ((options & PCRE_UTF16) == 0)
3490    #endif
3491      if (end > 0xffff) end = 0xffff;
3492    
3493    #endif /* COMPILE_PCRE[8|16] */
3494    
3495    /* If all characters are less than 256, use the bit map. Otherwise use extra
3496    data. */
3497    
3498    if (end < 0x100)
3499      {
3500      for (c = start; c <= end; c++)
3501        {
3502        n8++;
3503        SETBIT(classbits, c);
3504        }
3505      }
3506    
3507    else
3508      {
3509      pcre_uchar *uchardata = *uchardptr;
3510    
3511    #ifdef SUPPORT_UTF
3512      if ((options & PCRE_UTF8) != 0)  /* All UTFs use the same flag bit */
3513        {
3514        if (start < end)
3515          {
3516          *uchardata++ = XCL_RANGE;
3517          uchardata += PRIV(ord2utf)(start, uchardata);
3518          uchardata += PRIV(ord2utf)(end, uchardata);
3519          }
3520        else if (start == end)
3521          {
3522          *uchardata++ = XCL_SINGLE;
3523          uchardata += PRIV(ord2utf)(start, uchardata);
3524          }
3525        }
3526      else
3527    #endif  /* SUPPORT_UTF */
3528    
3529      /* Without UTF support, character values are constrained by the bit length,
3530      and can only be > 256 for 16-bit and 32-bit libraries. */
3531    
3532    #ifdef COMPILE_PCRE8
3533        {}
3534    #else
3535      if (start < end)
3536        {
3537        *uchardata++ = XCL_RANGE;
3538        *uchardata++ = start;
3539        *uchardata++ = end;
3540        }
3541      else if (start == end)
3542        {
3543        *uchardata++ = XCL_SINGLE;
3544        *uchardata++ = start;
3545        }
3546    #endif
3547    
3548      *uchardptr = uchardata;   /* Updata extra data pointer */
3549      }
3550    
3551    return n8;    /* Number of 8-bit characters */
3552    }
3553    
3554    
3555    
3556    
3557    /*************************************************
3558    *        Add a list of characters to a class     *
3559    *************************************************/
3560    
3561    /* This function is used for adding a list of case-equivalent characters to a
3562    class, and also for adding a list of horizontal or vertical whitespace. If the
3563    list is in order (which it should be), ranges of characters are detected and
3564    handled appropriately. This function is mutually recursive with the function
3565    above.
3566    
3567    Arguments:
3568      classbits     the bit map for characters < 256
3569      uchardptr     points to the pointer for extra data
3570      options       the options word
3571      cd            contains pointers to tables etc.
3572      p             points to row of 32-bit values, terminated by NOTACHAR
3573      except        character to omit; this is used when adding lists of
3574                      case-equivalent characters to avoid including the one we
3575                      already know about
3576    
3577    Returns:        the number of < 256 characters added
3578                    the pointer to extra data is updated
3579    */
3580    
3581    static int
3582    add_list_to_class(pcre_uint8 *classbits, pcre_uchar **uchardptr, int options,
3583      compile_data *cd, const pcre_uint32 *p, unsigned int except)
3584    {
3585    int n8 = 0;
3586    while (p[0] < NOTACHAR)
3587      {
3588      int n = 0;
3589      if (p[0] != except)
3590        {
3591        while(p[n+1] == p[0] + n + 1) n++;
3592        n8 += add_to_class(classbits, uchardptr, options, cd, p[0], p[n]);
3593        }
3594      p += n + 1;
3595      }
3596    return n8;
3597    }
3598    
3599    
3600    
3601    /*************************************************
3602    *    Add characters not in a list to a class     *
3603    *************************************************/
3604    
3605    /* This function is used for adding the complement of a list of horizontal or
3606    vertical whitespace to a class. The list must be in order.
3607    
3608    Arguments:
3609      classbits     the bit map for characters < 256
3610      uchardptr     points to the pointer for extra data
3611      options       the options word
3612      cd            contains pointers to tables etc.
3613      p             points to row of 32-bit values, terminated by NOTACHAR
3614    
3615    Returns:        the number of < 256 characters added
3616                    the pointer to extra data is updated
3617    */
3618    
3619    static int
3620    add_not_list_to_class(pcre_uint8 *classbits, pcre_uchar **uchardptr,
3621      int options, compile_data *cd, const pcre_uint32 *p)
3622    {
3623    BOOL utf = (options & PCRE_UTF8) != 0;
3624    int n8 = 0;
3625    if (p[0] > 0)
3626      n8 += add_to_class(classbits, uchardptr, options, cd, 0, p[0] - 1);
3627    while (p[0] < NOTACHAR)
3628      {
3629      while (p[1] == p[0] + 1) p++;
3630      n8 += add_to_class(classbits, uchardptr, options, cd, p[0] + 1,
3631        (p[1] == NOTACHAR) ? (utf ? 0x10ffffu : 0xffffffffu) : p[1] - 1);
3632      p++;
3633      }
3634    return n8;
3635    }
3636    
3637    
3638    
3639    /*************************************************
3640  *           Compile one branch                   *  *           Compile one branch                   *
3641  *************************************************/  *************************************************/
3642    
# Line 3463  must not do this for other options (e.g. Line 3699  must not do this for other options (e.g.
3699  dynamically as we process the pattern. */  dynamically as we process the pattern. */
3700    
3701  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3702  /* PCRE_UTF16 has the same value as PCRE_UTF8. */  /* PCRE_UTF(16|32) have the same value as PCRE_UTF8. */
3703  BOOL utf = (options & PCRE_UTF8) != 0;  BOOL utf = (options & PCRE_UTF8) != 0;
3704  pcre_uchar utf_chars[6];  pcre_uchar utf_chars[6];
3705  #else  #else
3706  BOOL utf = FALSE;  BOOL utf = FALSE;
3707  #endif  #endif
3708    
3709  /* Helper variables for OP_XCLASS opcode (for characters > 255). */  /* Helper variables for OP_XCLASS opcode (for characters > 255). We define
3710    class_uchardata always so that it can be passed to add_to_class() always,
3711    though it will not be used in non-UTF 8-bit cases. This avoids having to supply
3712    alternative calls for the different cases. */
3713    
3714    pcre_uchar *class_uchardata;
3715  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
3716  BOOL xclass;  BOOL xclass;
 pcre_uchar *class_uchardata;  
3717  pcre_uchar *class_uchardata_base;  pcre_uchar *class_uchardata_base;
3718  #endif  #endif
3719    
# Line 3518  for (;; ptr++) Line 3757  for (;; ptr++)
3757    BOOL is_recurse;    BOOL is_recurse;
3758    BOOL reset_bracount;    BOOL reset_bracount;
3759    int class_has_8bitchar;    int class_has_8bitchar;
3760    int class_single_char;    int class_one_char;
3761    int newoptions;    int newoptions;
3762    int recno;    int recno;
3763    int refsign;    int refsign;
# Line 3816  for (;; ptr++) Line 4055  for (;; ptr++)
4055    
4056      should_flip_negation = FALSE;      should_flip_negation = FALSE;
4057    
4058      /* For optimization purposes, we track some properties of the class.      /* For optimization purposes, we track some properties of the class:
4059      class_has_8bitchar will be non-zero, if the class contains at least one      class_has_8bitchar will be non-zero if the class contains at least one <
4060      < 256 character. class_single_char will be 1 if the class contains only      256 character; class_one_char will be 1 if the class contains just one
4061      a single character. */      character. */
4062    
4063      class_has_8bitchar = 0;      class_has_8bitchar = 0;
4064      class_single_char = 0;      class_one_char = 0;
4065    
4066      /* Initialize the 32-char bit map to all zeros. We build the map in a      /* Initialize the 32-char bit map to all zeros. We build the map in a
4067      temporary bit of memory, in case the class contains only 1 character (less      temporary bit of memory, in case the class contains fewer than two
4068      than 256), because in that case the compiled code doesn't use the bit map.      8-bit characters because in that case the compiled code doesn't use the bit
4069      */      map. */
4070    
4071      memset(classbits, 0, 32 * sizeof(pcre_uint8));      memset(classbits, 0, 32 * sizeof(pcre_uint8));
4072    
4073  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
4074      xclass = FALSE;                           /* No chars >= 256 */      xclass = FALSE;
4075      class_uchardata = code + LINK_SIZE + 2;   /* For UTF-8 items */      class_uchardata = code + LINK_SIZE + 2;   /* For XCLASS items */
4076      class_uchardata_base = class_uchardata;   /* For resetting in pass 1 */      class_uchardata_base = class_uchardata;   /* Save the start */
4077  #endif  #endif
4078    
4079      /* Process characters until ] is reached. By writing this as a "do" it      /* Process characters until ] is reached. By writing this as a "do" it
# Line 3845  for (;; ptr++) Line 4084  for (;; ptr++)
4084        {        {
4085        const pcre_uchar *oldptr;        const pcre_uchar *oldptr;
4086    
4087  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4088        if (utf && HAS_EXTRALEN(c))        if (utf && HAS_EXTRALEN(c))
4089          {                           /* Braces are required because the */          {                           /* Braces are required because the */
4090          GETCHARLEN(c, ptr, ptr);    /* macro generates multiple statements */          GETCHARLEN(c, ptr, ptr);    /* macro generates multiple statements */
# Line 3856  for (;; ptr++) Line 4095  for (;; ptr++)
4095        /* In the pre-compile phase, accumulate the length of any extra        /* In the pre-compile phase, accumulate the length of any extra
4096        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
4097        contain a zillion > 255 characters no longer overwrite the work space        contain a zillion > 255 characters no longer overwrite the work space
4098        (which is on the stack). */        (which is on the stack). We have to remember that there was XCLASS data,
4099          however. */
4100    
4101        if (lengthptr != NULL)        if (lengthptr != NULL && class_uchardata > class_uchardata_base)
4102          {          {
4103            xclass = TRUE;
4104          *lengthptr += class_uchardata - class_uchardata_base;          *lengthptr += class_uchardata - class_uchardata_base;
4105          class_uchardata = class_uchardata_base;          class_uchardata = class_uchardata_base;
4106          }          }
# Line 3918  for (;; ptr++) Line 4159  for (;; ptr++)
4159          alpha. This relies on the fact that the class table starts with          alpha. This relies on the fact that the class table starts with
4160          alpha, lower, upper as the first 3 entries. */          alpha, lower, upper as the first 3 entries. */
4161    
4162          if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)          if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)
4163            posix_class = 0;            posix_class = 0;
4164    
4165          /* 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 3961  for (;; ptr++) Line 4202  for (;; ptr++)
4202              for (c = 0; c < 32; c++) pbits[c] &= ~cbits[c + taboffset];              for (c = 0; c < 32; c++) pbits[c] &= ~cbits[c + taboffset];
4203            }            }
4204    
4205          /* Not see if we need to remove any special characters. An option          /* Now see if we need to remove any special characters. An option
4206          value of 1 removes vertical space and 2 removes underscore. */          value of 1 removes vertical space and 2 removes underscore. */
4207    
4208          if (tabopt < 0) tabopt = -tabopt;          if (tabopt < 0) tabopt = -tabopt;
# Line 3977  for (;; ptr++) Line 4218  for (;; ptr++)
4218            for (c = 0; c < 32; c++) classbits[c] |= pbits[c];            for (c = 0; c < 32; c++) classbits[c] |= pbits[c];
4219    
4220          ptr = tempptr + 1;          ptr = tempptr + 1;
4221          /* Every class contains at least one < 256 characters. */          /* Every class contains at least one < 256 character. */
4222          class_has_8bitchar = 1;          class_has_8bitchar = 1;
4223          /* Every class contains at least two characters. */          /* Every class contains at least two characters. */
4224          class_single_char = 2;          class_one_char = 2;
4225          continue;    /* End of POSIX syntax handling */          continue;    /* End of POSIX syntax handling */
4226          }          }
4227    
# Line 3988  for (;; ptr++) Line 4229  for (;; ptr++)
4229        of the specials, which just set a flag. The sequence \b is a special        of the specials, which just set a flag. The sequence \b is a special
4230        case. Inside a class (and only there) it is treated as backspace. We        case. Inside a class (and only there) it is treated as backspace. We
4231        assume that other escapes have more than one character in them, so        assume that other escapes have more than one character in them, so
4232        speculatively set both class_has_8bitchar and class_single_char bigger        speculatively set both class_has_8bitchar and class_one_char bigger
4233        than one. Unrecognized escapes fall through and are either treated        than one. Unrecognized escapes fall through and are either treated
4234        as literal characters (by default), or are faulted if        as literal characters (by default), or are faulted if
4235        PCRE_EXTRA is set. */        PCRE_EXTRA is set. */
# Line 4021  for (;; ptr++) Line 4262  for (;; ptr++)
4262            /* Every class contains at least two < 256 characters. */            /* Every class contains at least two < 256 characters. */
4263            class_has_8bitchar++;            class_has_8bitchar++;
4264            /* Every class contains at least two characters. */            /* Every class contains at least two characters. */
4265            class_single_char += 2;            class_one_char += 2;
4266    
4267            switch (-c)            switch (-c)
4268              {              {
# Line 4057  for (;; ptr++) Line 4298  for (;; ptr++)
4298    
4299              /* Perl 5.004 onwards omits VT from \s, but we must preserve it              /* Perl 5.004 onwards omits VT from \s, but we must preserve it
4300              if it was previously set by something earlier in the character              if it was previously set by something earlier in the character
4301              class. */              class. Luckily, the value of CHAR_VT is 0x0b in both ASCII and
4302                EBCDIC, so we lazily just adjust the appropriate bit. */
4303    
4304              case ESC_s:              case ESC_s:
4305              classbits[0] |= cbits[cbit_space];              classbits[0] |= cbits[cbit_space];
# Line 4070  for (;; ptr++) Line 4312  for (;; ptr++)
4312              for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_space];              for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_space];
4313              classbits[1] |= 0x08;    /* Perl 5.004 onwards omits VT from \s */              classbits[1] |= 0x08;    /* Perl 5.004 onwards omits VT from \s */
4314              continue;              continue;
4315    
4316                /* The rest apply in both UCP and non-UCP cases. */
4317    
4318              case ESC_h:              case ESC_h:
4319              SETBIT(classbits, 0x09); /* VT */              (void)add_list_to_class(classbits, &class_uchardata, options, cd,
4320              SETBIT(classbits, 0x20); /* SPACE */                PRIV(hspace_list), NOTACHAR);
             SETBIT(classbits, 0xa0); /* NSBP */  
 #ifndef COMPILE_PCRE8  
             xclass = TRUE;  
             *class_uchardata++ = XCL_SINGLE;  
             *class_uchardata++ = 0x1680;  
             *class_uchardata++ = XCL_SINGLE;  
             *class_uchardata++ = 0x180e;  
             *class_uchardata++ = XCL_RANGE;  
             *class_uchardata++ = 0x2000;  
             *class_uchardata++ = 0x200a;  
             *class_uchardata++ = XCL_SINGLE;  
             *class_uchardata++ = 0x202f;  
             *class_uchardata++ = XCL_SINGLE;  
             *class_uchardata++ = 0x205f;  
             *class_uchardata++ = XCL_SINGLE;  
             *class_uchardata++ = 0x3000;  
 #elif defined SUPPORT_UTF  
             if (utf)  
               {  
               xclass = TRUE;  
               *class_uchardata++ = XCL_SINGLE;  
               class_uchardata += PRIV(ord2utf)(0x1680, class_uchardata);  
               *class_uchardata++ = XCL_SINGLE;  
               class_uchardata += PRIV(ord2utf)(0x180e, class_uchardata);  
               *class_uchardata++ = XCL_RANGE;  
               class_uchardata += PRIV(ord2utf)(0x2000, class_uchardata);  
               class_uchardata += PRIV(ord2utf)(0x200a, class_uchardata);  
               *class_uchardata++ = XCL_SINGLE;  
               class_uchardata += PRIV(ord2utf)(0x202f, class_uchardata);  
               *class_uchardata++ = XCL_SINGLE;  
               class_uchardata += PRIV(ord2utf)(0x205f, class_uchardata);  
               *class_uchardata++ = XCL_SINGLE;  
               class_uchardata += PRIV(ord2utf)(0x3000, class_uchardata);  
               }  
 #endif  
4321              continue;              continue;
4322    
4323              case ESC_H:              case ESC_H:
4324              for (c = 0; c < 32; c++)              (void)add_not_list_to_class(classbits, &class_uchardata, options,
4325                {                cd, PRIV(hspace_list));
               int x = 0xff;  
               switch (c)  
                 {  
                 case 0x09/8: x ^= 1 << (0x09%8); break;  
                 case 0x20/8: x ^= 1 << (0x20%8); break;  
                 case 0xa0/8: x ^= 1 << (0xa0%8); break;  
                 default: break;  
                 }  
               classbits[c] |= x;  
               }  
 #ifndef COMPILE_PCRE8  
             xclass = TRUE;  
             *class_uchardata++ = XCL_RANGE;  
             *class_uchardata++ = 0x0100;  
             *class_uchardata++ = 0x167f;  
             *class_uchardata++ = XCL_RANGE;  
             *class_uchardata++ = 0x1681;  
             *class_uchardata++ = 0x180d;  
             *class_uchardata++ = XCL_RANGE;  
             *class_uchardata++ = 0x180f;  
             *class_uchardata++ = 0x1fff;  
             *class_uchardata++ = XCL_RANGE;  
             *class_uchardata++ = 0x200b;  
             *class_uchardata++ = 0x202e;  
             *class_uchardata++ = XCL_RANGE;  
             *class_uchardata++ = 0x2030;  
             *class_uchardata++ = 0x205e;  
             *class_uchardata++ = XCL_RANGE;  
             *class_uchardata++ = 0x2060;  
             *class_uchardata++ = 0x2fff;  
             *class_uchardata++ = XCL_RANGE;  
             *class_uchardata++ = 0x3001;  
 #ifdef SUPPORT_UTF  
             if (utf)  
               class_uchardata += PRIV(ord2utf)(0x10ffff, class_uchardata);  
             else  
 #endif  
               *class_uchardata++ = 0xffff;  
 #elif defined SUPPORT_UTF  
             if (utf)  
               {  
               xclass = TRUE;  
               *class_uchardata++ = XCL_RANGE;  
               class_uchardata += PRIV(ord2utf)(0x0100, class_uchardata);  
               class_uchardata += PRIV(ord2utf)(0x167f, class_uchardata);  
               *class_uchardata++ = XCL_RANGE;  
               class_uchardata += PRIV(ord2utf)(0x1681, class_uchardata);  
               class_uchardata += PRIV(ord2utf)(0x180d, class_uchardata);  
               *class_uchardata++ = XCL_RANGE;  
               class_uchardata += PRIV(ord2utf)(0x180f, class_uchardata);  
               class_uchardata += PRIV(ord2utf)(0x1fff, class_uchardata);  
               *class_uchardata++ = XCL_RANGE;  
               class_uchardata += PRIV(ord2utf)(0x200b, class_uchardata);  
               class_uchardata += PRIV(ord2utf)(0x202e, class_uchardata);  
               *class_uchardata++ = XCL_RANGE;  
               class_uchardata += PRIV(ord2utf)(0x2030, class_uchardata);  
               class_uchardata += PRIV(ord2utf)(0x205e, class_uchardata);  
               *class_uchardata++ = XCL_RANGE;  
               class_uchardata += PRIV(ord2utf)(0x2060, class_uchardata);  
               class_uchardata += PRIV(ord2utf)(0x2fff, class_uchardata);  
               *class_uchardata++ = XCL_RANGE;  
               class_uchardata += PRIV(ord2utf)(0x3001, class_uchardata);  
               class_uchardata += PRIV(ord2utf)(0x10ffff, class_uchardata);  
               }  
 #endif  
4326              continue;              continue;
4327    
4328              case ESC_v:              case ESC_v:
4329              SETBIT(classbits, 0x0a); /* LF */              (void)add_list_to_class(classbits, &class_uchardata, options, cd,
4330              SETBIT(classbits, 0x0b); /* VT */                PRIV(vspace_list), NOTACHAR);
             SETBIT(classbits, 0x0c); /* FF */  
             SETBIT(classbits, 0x0d); /* CR */  
             SETBIT(classbits, 0x85); /* NEL */  
 #ifndef COMPILE_PCRE8  
             xclass = TRUE;  
             *class_uchardata++ = XCL_RANGE;  
             *class_uchardata++ = 0x2028;  
             *class_uchardata++ = 0x2029;  
 #elif defined SUPPORT_UTF  
             if (utf)  
               {  
               xclass = TRUE;  
               *class_uchardata++ = XCL_RANGE;  
               class_uchardata += PRIV(ord2utf)(0x2028, class_uchardata);  
               class_uchardata += PRIV(ord2utf)(0x2029, class_uchardata);  
               }  
 #endif  
4331              continue;              continue;
4332    
4333              case ESC_V:              case ESC_V:
4334              for (c = 0; c < 32; c++)              (void)add_not_list_to_class(classbits, &class_uchardata, options,
4335                {                cd, PRIV(vspace_list));
               int x = 0xff;  
               switch (c)  
                 {  
                 case 0x0a/8: x ^= 1 << (0x0a%8);  
                              x ^= 1 << (0x0b%8);  
                              x ^= 1 << (0x0c%8);  
                              x ^= 1 << (0x0d%8);  
                              break;  
                 case 0x85/8: x ^= 1 << (0x85%8); break;  
                 default: break;  
                 }  
               classbits[c] |= x;  
               }  
   
 #ifndef COMPILE_PCRE8  
             xclass = TRUE;  
             *class_uchardata++ = XCL_RANGE;  
             *class_uchardata++ = 0x0100;  
             *class_uchardata++ = 0x2027;  
             *class_uchardata++ = XCL_RANGE;  
             *class_uchardata++ = 0x202a;  
 #ifdef SUPPORT_UTF  
             if (utf)  
               class_uchardata += PRIV(ord2utf)(0x10ffff, class_uchardata);  
             else  
 #endif  
               *class_uchardata++ = 0xffff;  
 #elif defined SUPPORT_UTF  
             if (utf)  
               {  
               xclass = TRUE;  
               *class_uchardata++ = XCL_RANGE;  
               class_uchardata += PRIV(ord2utf)(0x0100, class_uchardata);  
               class_uchardata += PRIV(ord2utf)(0x2027, class_uchardata);  
               *class_uchardata++ = XCL_RANGE;  
               class_uchardata += PRIV(ord2utf)(0x202a, class_uchardata);  
               class_uchardata += PRIV(ord2utf)(0x10ffff, class_uchardata);  
               }  
 #endif  
4336              continue;              continue;
4337    
4338  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 4255  for (;; ptr++) Line 4343  for (;; ptr++)
4343                int pdata;                int pdata;
4344                int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr);                int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr);
4345                if (ptype < 0) goto FAILED;                if (ptype < 0) goto FAILED;
               xclass = TRUE;  
4346                *class_uchardata++ = ((-c == ESC_p) != negated)?                *class_uchardata++ = ((-c == ESC_p) != negated)?
4347                  XCL_PROP : XCL_NOTPROP;                  XCL_PROP : XCL_NOTPROP;
4348                *class_uchardata++ = ptype;                *class_uchardata++ = ptype;
# Line 4275  for (;; ptr++) Line 4362  for (;; ptr++)
4362                goto FAILED;                goto FAILED;
4363                }                }
4364              class_has_8bitchar--;    /* Undo the speculative increase. */              class_has_8bitchar--;    /* Undo the speculative increase. */
4365              class_single_char -= 2;  /* Undo the speculative increase. */              class_one_char -= 2;     /* Undo the speculative increase. */
4366              c = *ptr;                /* Get the final character and fall through */              c = *ptr;                /* Get the final character and fall through */
4367              break;              break;
4368              }              }
4369            }            }
4370    
4371          /* Fall through if we have a single character (c >= 0). This may be          /* Fall through if the escape just defined a single character (c >= 0).
4372          greater than 256. */          This may be greater than 256. */
4373    
4374          }   /* End of backslash handling */          }   /* End of backslash handling */
4375    
4376        /* A single character may be followed by '-' to form a range. However,        /* A character may be followed by '-' to form a range. However, Perl does
4377        Perl does not permit ']' to be the end of the range. A '-' character        not permit ']' to be the end of the range. A '-' character at the end is
4378        at the end is treated as a literal. Perl ignores orphaned \E sequences        treated as a literal. Perl ignores orphaned \E sequences entirely. The
4379        entirely. The code for handling \Q and \E is messy. */        code for handling \Q and \E is messy. */
4380    
4381        CHECK_RANGE:        CHECK_RANGE:
4382        while (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)        while (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)
# Line 4297  for (;; ptr++) Line 4384  for (;; ptr++)
4384          inescq = FALSE;          inescq = FALSE;
4385          ptr += 2;          ptr += 2;
4386          }          }
   
4387        oldptr = ptr;        oldptr = ptr;
4388    
4389        /* Remember \r or \n */        /* Remember if \r or \n were explicitly used */
4390    
4391        if (c == CHAR_CR || c == CHAR_NL) cd->external_flags |= PCRE_HASCRORLF;        if (c == CHAR_CR || c == CHAR_NL) cd->external_flags |= PCRE_HASCRORLF;
4392    
# Line 4323  for (;; ptr++) Line 4409  for (;; ptr++)
4409            inescq = TRUE;            inescq = TRUE;
4410            break;            break;
4411            }            }
4412    
4413            /* Minus (hyphen) at the end of a class is treated as a literal, so put
4414            back the pointer and jump to handle the character that preceded it. */
4415    
4416          if (*ptr == 0 || (!inescq && *ptr == CHAR_RIGHT_SQUARE_BRACKET))          if (*ptr == 0 || (!inescq && *ptr == CHAR_RIGHT_SQUARE_BRACKET))
4417            {            {
4418            ptr = oldptr;            ptr = oldptr;
4419            goto LONE_SINGLE_CHARACTER;            goto CLASS_SINGLE_CHARACTER;
4420            }            }
4421    
4422            /* Otherwise, we have a potential range; pick up the next character */
4423    
4424  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
4425          if (utf)          if (utf)
# Line 4348  for (;; ptr++) Line 4439  for (;; ptr++)
4439            d = check_escape(&ptr, errorcodeptr, cd->bracount, options, TRUE);            d = check_escape(&ptr, errorcodeptr, cd->bracount, options, TRUE);
4440            if (*errorcodeptr != 0) goto FAILED;            if (*errorcodeptr != 0) goto FAILED;
4441    
4442            /* \b is backspace; any other special means the '-' was literal */            /* \b is backspace; any other special means the '-' was literal. */
4443    
4444            if (d < 0)            if (d < 0)
4445              {              {
4446              if (d == -ESC_b) d = CHAR_BS; else              if (d == -ESC_b) d = CHAR_BS; else
4447                {                {
4448                ptr = oldptr;                ptr = oldptr;
4449                goto LONE_SINGLE_CHARACTER;  /* A few lines below */                goto CLASS_SINGLE_CHARACTER;  /* A few lines below */
4450                }                }
4451              }              }
4452            }            }
4453    
4454          /* Check that the two values are in the correct order. Optimize          /* Check that the two values are in the correct order. Optimize
4455          one-character ranges */          one-character ranges. */
4456    
4457          if (d < c)          if (d < c)
4458            {            {
4459            *errorcodeptr = ERR8;            *errorcodeptr = ERR8;
4460            goto FAILED;            goto FAILED;
4461            }            }
4462            if (d == c) goto CLASS_SINGLE_CHARACTER;  /* A few lines below */
4463    
4464          if (d == c) goto LONE_SINGLE_CHARACTER;  /* A few lines below */          /* We have found a character range, so single character optimizations
4465            cannot be done anymore. Any value greater than 1 indicates that there
4466            is more than one character. */
4467    
4468            class_one_char = 2;
4469    
4470          /* Remember \r or \n */          /* Remember an explicit \r or \n, and add the range to the class. */
4471    
4472          if (d == CHAR_CR || d == CHAR_NL) cd->external_flags |= PCRE_HASCRORLF;          if (d == CHAR_CR || d == CHAR_NL) cd->external_flags |= PCRE_HASCRORLF;
4473    
4474          /* Since we found a character range, single character optimizations          class_has_8bitchar +=
4475          cannot be done anymore. */            add_to_class(classbits, &class_uchardata, options, cd, c, d);
4476          class_single_char = 2;  
   
         /* In UTF-8 mode, if the upper limit is > 255, or > 127 for caseless  
         matching, we have to use an XCLASS with extra data items. Caseless  
         matching for characters > 127 is available only if UCP support is  
         available. */  
   
 #if defined SUPPORT_UTF && !(defined COMPILE_PCRE8)  
         if ((d > 255) || (utf && ((options & PCRE_CASELESS) != 0 && d > 127)))  
 #elif defined  SUPPORT_UTF  
         if (utf && (d > 255 || ((options & PCRE_CASELESS) != 0 && d > 127)))  
 #elif !(defined COMPILE_PCRE8)  
         if (d > 255)  
 #endif  
 #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)  
           {  
           xclass = TRUE;  
   
           /* With UCP support, we can find the other case equivalents of  
           the relevant characters. There may be several ranges. Optimize how  
           they fit with the basic range. */  
   
 #ifdef SUPPORT_UCP  
 #ifndef COMPILE_PCRE8  
           if (utf && (options & PCRE_CASELESS) != 0)  
 #else  
           if ((options & PCRE_CASELESS) != 0)  
 #endif  
             {  
             unsigned int occ, ocd;  
             unsigned int cc = c;  
             unsigned int origd = d;  
             while (get_othercase_range(&cc, origd, &occ, &ocd))  
               {  
               if (occ >= (unsigned int)c &&  
                   ocd <= (unsigned int)d)  
                 continue;                          /* Skip embedded ranges */  
   
               if (occ < (unsigned int)c  &&  
                   ocd >= (unsigned int)c - 1)      /* Extend the basic range */  
                 {                                  /* if there is overlap,   */  
                 c = occ;                           /* noting that if occ < c */  
                 continue;                          /* we can't have ocd > d  */  
                 }                                  /* because a subrange is  */  
               if (ocd > (unsigned int)d &&  
                   occ <= (unsigned int)d + 1)      /* always shorter than    */  
                 {                                  /* the basic range.       */  
                 d = ocd;  
                 continue;  
                 }  
   
               if (occ == ocd)  
                 {  
                 *class_uchardata++ = XCL_SINGLE;  
                 }  
               else  
                 {  
                 *class_uchardata++ = XCL_RANGE;  
                 class_uchardata += PRIV(ord2utf)(occ, class_uchardata);  
                 }  
               class_uchardata += PRIV(ord2utf)(ocd, class_uchardata);  
               }  
             }  
 #endif  /* SUPPORT_UCP */  
   
           /* Now record the original range, possibly modified for UCP caseless  
           overlapping ranges. */  
   
           *class_uchardata++ = XCL_RANGE;  
 #ifdef SUPPORT_UTF  
 #ifndef COMPILE_PCRE8  
           if (utf)  
             {  
             class_uchardata += PRIV(ord2utf)(c, class_uchardata);  
             class_uchardata += PRIV(ord2utf)(d, class_uchardata);  
             }  
           else  
             {  
             *class_uchardata++ = c;  
             *class_uchardata++ = d;  
             }  
 #else  
           class_uchardata += PRIV(ord2utf)(c, class_uchardata);  
           class_uchardata += PRIV(ord2utf)(d, class_uchardata);  
 #endif  
 #else /* SUPPORT_UTF */  
           *class_uchardata++ = c;  
           *class_uchardata++ = d;  
 #endif /* SUPPORT_UTF */  
   
           /* With UCP support, we are done. Without UCP support, there is no  
           caseless matching for UTF characters > 127; we can use the bit map  
           for the smaller ones. As for 16 bit characters without UTF, we  
           can still use  */  
   
 #ifdef SUPPORT_UCP  
 #ifndef COMPILE_PCRE8  
           if (utf)  
 #endif  
             continue;    /* With next character in the class */  
 #endif  /* SUPPORT_UCP */  
   
 #if defined SUPPORT_UTF && !defined(SUPPORT_UCP) && !(defined COMPILE_PCRE8)  
           if (utf)  
             {  
             if ((options & PCRE_CASELESS) == 0 || c > 127) continue;  
             /* Adjust upper limit and fall through to set up the map */  
             d = 127;  
             }  
           else  
             {  
             if (c > 255) continue;  
             /* Adjust upper limit and fall through to set up the map */  
             d = 255;  
             }  
 #elif defined SUPPORT_UTF && !defined(SUPPORT_UCP)  
           if ((options & PCRE_CASELESS) == 0 || c > 127) continue;  
           /* Adjust upper limit and fall through to set up the map */  
           d = 127;  
 #else  
           if (c > 255) continue;  
           /* Adjust upper limit and fall through to set up the map */  
           d = 255;  
 #endif  /* SUPPORT_UTF && !SUPPORT_UCP && !COMPILE_PCRE8 */  
           }  
 #endif  /* SUPPORT_UTF || !COMPILE_PCRE8 */  
   
         /* We use the bit map for 8 bit mode, or when the characters fall  
         partially or entirely to [0-255] ([0-127] for UCP) ranges. */  
   
         class_has_8bitchar = 1;  
   
         /* We can save a bit of time by skipping this in the pre-compile. */  
   
         if (lengthptr == NULL) for (; c <= d; c++)  
           {  
           classbits[c/8] |= (1 << (c&7));  
           if ((options & PCRE_CASELESS) != 0)  
             {  
             int uc = cd->fcc[c]; /* flip case */  
             classbits[uc/8] |= (1 << (uc&7));  
             }  
           }  
   
4477          continue;   /* Go get the next char in the class */          continue;   /* Go get the next char in the class */
4478          }          }
4479    
4480        /* Handle a lone single character - we can get here for a normal        /* Handle a single character - we can get here for a normal non-escape
4481        non-escape char, or after \ that introduces a single character or for an        char, or after \ that introduces a single character or for an apparent
4482        apparent range that isn't. */        range that isn't. Only the value 1 matters for class_one_char, so don't
4483          increase it if it is already 2 or more ... just in case there's a class
4484          with a zillion characters in it. */
4485    
4486          CLASS_SINGLE_CHARACTER:
4487          if (class_one_char < 2) class_one_char++;
4488    
4489          /* If class_one_char is 1, we have the first single character in the
4490          class, and there have been no prior ranges, or XCLASS items generated by
4491          escapes. If this is the final character in the class, we can optimize by
4492          turning the item into a 1-character OP_CHAR[I] if it's positive, or
4493          OP_NOT[I] if it's negative. In the positive case, it can cause firstchar
4494          to be set. Otherwise, there can be no first char if this item is first,
4495          whatever repeat count may follow. In the case of reqchar, save the
4496          previous value for reinstating. */
4497    
4498        LONE_SINGLE_CHARACTER:        if (class_one_char == 1 && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
   
       /* Only the value of 1 matters for class_single_char. */  
   
       if (class_single_char < 2) class_single_char++;  
   
       /* If class_charcount is 1, we saw precisely one character. As long as  
       there was no use of \p or \P, in other words, no use of any XCLASS  
       features, we can optimize.  
   
       The optimization throws away the bit map. We turn the item into a  
       1-character OP_CHAR[I] if it's positive, or OP_NOT[I] if it's negative.  
       In the positive case, it can cause firstchar to be set. Otherwise, there  
       can be no first char if this item is first, whatever repeat count may  
       follow. In the case of reqchar, save the previous value for reinstating. */  
   
       if (class_single_char == 1 && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)  
4499          {          {
4500          ptr++;          ptr++;
4501          zeroreqchar = reqchar;          zeroreqchar = reqchar;
4502    
4503          if (negate_class)          if (negate_class)
4504            {            {
4505    #ifdef SUPPORT_UCP
4506                // FIXMEchpe pcreuint32?
4507              int d;
4508    #endif
4509            if (firstchar == REQ_UNSET) firstchar = REQ_NONE;            if (firstchar == REQ_UNSET) firstchar = REQ_NONE;
4510            zerofirstchar = firstchar;            zerofirstchar = firstchar;
4511            *code++ = ((options & PCRE_CASELESS) != 0)? OP_NOTI: OP_NOT;  
4512  #ifdef SUPPORT_UTF            /* For caseless UTF-8 mode when UCP support is available, check
4513            if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)            whether this character has more than one other case. If so, generate
4514              code += PRIV(ord2utf)(c, code);            a special OP_NOTPROP item instead of OP_NOTI. */
4515            else  
4516    #ifdef SUPPORT_UCP
4517              if (utf && (options & PCRE_CASELESS) != 0 &&
4518                  (d = UCD_CASESET(c)) != 0)
4519                {
4520                *code++ = OP_NOTPROP;
4521                *code++ = PT_CLIST;
4522                *code++ = d;
4523                }
4524              else
4525  #endif  #endif
4526              *code++ = c;            /* Char has only one other case, or UCP not available */
4527            goto NOT_CHAR;  
4528                {
4529                *code++ = ((options & PCRE_CASELESS) != 0)? OP_NOTI: OP_NOT;
4530    #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4531                if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)
4532                  code += PRIV(ord2utf)(c, code);
4533                else
4534    #endif
4535                  *code++ = c;
4536                }
4537    
4538              /* We are finished with this character class */
4539    
4540              goto END_CLASS;
4541            }            }
4542    
4543          /* For a single, positive character, get the value into mcbuffer, and          /* For a single, positive character, get the value into mcbuffer, and
4544          then we can handle this with the normal one-character code. */          then we can handle this with the normal one-character code. */
4545    
4546  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4547          if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)          if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)
4548            mclength = PRIV(ord2utf)(c, mcbuffer);            mclength = PRIV(ord2utf)(c, mcbuffer);
4549          else          else
# Line 4577  for (;; ptr++) Line 4554  for (;; ptr++)
4554            }            }
4555          goto ONE_CHAR;          goto ONE_CHAR;
4556          }       /* End of 1-char optimization */          }       /* End of 1-char optimization */
4557    
4558        /* Handle a character that cannot go in the bit map. */        /* There is more than one character in the class, or an XCLASS item
4559          has been generated. Add this character to the class. */
4560  #if defined SUPPORT_UTF && !(defined COMPILE_PCRE8)  
4561        if ((c > 255) || (utf && ((options & PCRE_CASELESS) != 0 && c > 127)))        class_has_8bitchar +=
4562  #elif defined SUPPORT_UTF          add_to_class(classbits, &class_uchardata, options, cd, c, c);
       if (utf && (c > 255 || ((options & PCRE_CASELESS) != 0 && c > 127)))  
 #elif !(defined COMPILE_PCRE8)  
       if (c > 255)  
 #endif  
   
 #if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)  
         {  
         xclass = TRUE;  
         *class_uchardata++ = XCL_SINGLE;  
 #ifdef SUPPORT_UTF  
 #ifndef COMPILE_PCRE8  
         /* In non 8 bit mode, we can get here even if we are not in UTF mode. */  
         if (!utf)  
           *class_uchardata++ = c;  
         else  
 #endif  
           class_uchardata += PRIV(ord2utf)(c, class_uchardata);  
 #else /* SUPPORT_UTF */  
         *class_uchardata++ = c;  
 #endif /* SUPPORT_UTF */  
   
 #ifdef SUPPORT_UCP  
 #ifdef COMPILE_PCRE8  
         if ((options & PCRE_CASELESS) != 0)  
 #else  
         /* In non 8 bit mode, we can get here even if we are not in UTF mode. */  
         if (utf && (options & PCRE_CASELESS) != 0)  
 #endif  
           {  
           unsigned int othercase;  
           if ((int)(othercase = UCD_OTHERCASE(c)) != c)  
             {  
             *class_uchardata++ = XCL_SINGLE;  
             class_uchardata += PRIV(ord2utf)(othercase, class_uchardata);  
             }  
           }  
 #endif  /* SUPPORT_UCP */  
   
         }  
       else  
 #endif  /* SUPPORT_UTF || COMPILE_PCRE16 */  
   
       /* Handle a single-byte character */  
         {  
         class_has_8bitchar = 1;  
         classbits[c/8] |= (1 << (c&7));  
         if ((options & PCRE_CASELESS) != 0)  
           {  
           c = cd->fcc[c]; /* flip case */  
           classbits[c/8] |= (1 << (c&7));  
           }  
         }  
4563        }        }
4564    
4565      /* Loop until ']' reached. This "while" is the end of the "do" far above.      /* Loop until ']' reached. This "while" is the end of the "do" far above.
# Line 4654  for (;; ptr++) Line 4579  for (;; ptr++)
4579        goto FAILED;        goto FAILED;
4580        }        }
4581    
4582        /* We will need an XCLASS if data has been placed in class_uchardata. In
4583        the second phase this is a sufficient test. However, in the pre-compile
4584        phase, class_uchardata gets emptied to prevent workspace overflow, so it
4585        only if the very last character in the class needs XCLASS will it contain
4586        anything at this point. For this reason, xclass gets set TRUE above when
4587        uchar_classdata is emptied, and that's why this code is the way it is here
4588        instead of just doing a test on class_uchardata below. */
4589    
4590    #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
4591        if (class_uchardata > class_uchardata_base) xclass = TRUE;
4592    #endif
4593    
4594      /* If this is the first thing in the branch, there can be no first char      /* If this is the first thing in the branch, there can be no first char
4595      setting, whatever the repeat count. Any reqchar setting must remain      setting, whatever the repeat count. Any reqchar setting must remain
4596      unchanged after any kind of repeat. */      unchanged after any kind of repeat. */
# Line 4716  for (;; ptr++) Line 4653  for (;; ptr++)
4653        memcpy(code, classbits, 32);        memcpy(code, classbits, 32);
4654        }        }
4655      code += 32 / sizeof(pcre_uchar);      code += 32 / sizeof(pcre_uchar);
4656      NOT_CHAR:  
4657        END_CLASS:
4658      break;      break;
4659    
4660    
# Line 4840  for (;; ptr++) Line 4778  for (;; ptr++)
4778        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
4779        it's a length rather than a small character. */        it's a length rather than a small character. */
4780    
4781  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4782        if (utf && NOT_FIRSTCHAR(code[-1]))        if (utf && NOT_FIRSTCHAR(code[-1]))
4783          {          {
4784          pcre_uchar *lastchar = code - 1;          pcre_uchar *lastchar = code - 1;
# Line 4976  for (;; ptr++) Line 4914  for (;; ptr++)
4914    
4915          if (repeat_max < 0)          if (repeat_max < 0)
4916            {            {
4917  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4918            if (utf && (c & UTF_LENGTH) != 0)            if (utf && (c & UTF_LENGTH) != 0)
4919              {              {
4920              memcpy(code, utf_chars, IN_UCHARS(c & 7));              memcpy(code, utf_chars, IN_UCHARS(c & 7));
# Line 5001  for (;; ptr++) Line 4939  for (;; ptr++)
4939    
4940          else if (repeat_max != repeat_min)          else if (repeat_max != repeat_min)
4941            {            {
4942  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4943            if (utf && (c & UTF_LENGTH) != 0)            if (utf && (c & UTF_LENGTH) != 0)
4944              {              {
4945              memcpy(code, utf_chars, IN_UCHARS(c & 7));              memcpy(code, utf_chars, IN_UCHARS(c & 7));
# Line 5031  for (;; ptr++) Line 4969  for (;; ptr++)
4969    
4970        /* The character or character type itself comes last in all cases. */        /* The character or character type itself comes last in all cases. */
4971    
4972  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4973        if (utf && (c & UTF_LENGTH) != 0)        if (utf && (c & UTF_LENGTH) != 0)
4974          {          {
4975          memcpy(code, utf_chars, IN_UCHARS(c & 7));          memcpy(code, utf_chars, IN_UCHARS(c & 7));
# Line 5518  for (;; ptr++) Line 5456  for (;; ptr++)
5456        else if (*tempcode == OP_EXACT || *tempcode == OP_NOTEXACT)        else if (*tempcode == OP_EXACT || *tempcode == OP_NOTEXACT)
5457          {          {
5458          tempcode += PRIV(OP_lengths)[*tempcode];          tempcode += PRIV(OP_lengths)[*tempcode];
5459  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
5460          if (utf && HAS_EXTRALEN(tempcode[-1]))          if (utf && HAS_EXTRALEN(tempcode[-1]))
5461            tempcode += GET_EXTRALEN(tempcode[-1]);            tempcode += GET_EXTRALEN(tempcode[-1]);
5462  #endif  #endif
# Line 5616  for (;; ptr++) Line 5554  for (;; ptr++)
5554          arg = ++ptr;          arg = ++ptr;
5555          while (*ptr != 0 && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;          while (*ptr != 0 && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;
5556          arglen = (int)(ptr - arg);          arglen = (int)(ptr - arg);
5557          if (arglen > (int)MAX_MARK)          if ((unsigned int)arglen > MAX_MARK)
5558            {            {
5559            *errorcodeptr = ERR75;            *errorcodeptr = ERR75;
5560            goto FAILED;            goto FAILED;
# Line 6918  for (;; ptr++) Line 6856  for (;; ptr++)
6856      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
6857      handle it as a data character. */      handle it as a data character. */
6858    
6859  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
6860      if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)      if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)
6861        mclength = PRIV(ord2utf)(c, mcbuffer);        mclength = PRIV(ord2utf)(c, mcbuffer);
6862      else      else
# Line 6941  for (;; ptr++) Line 6879  for (;; ptr++)
6879      mclength = 1;      mclength = 1;
6880      mcbuffer[0] = c;      mcbuffer[0] = c;
6881    
6882  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
6883      if (utf && HAS_EXTRALEN(c))      if (utf && HAS_EXTRALEN(c))
6884        ACROSSCHAR(TRUE, ptr[1], mcbuffer[mclength++] = *(++ptr));        ACROSSCHAR(TRUE, ptr[1], mcbuffer[mclength++] = *(++ptr));
6885  #endif  #endif
# Line 6951  for (;; ptr++) Line 6889  for (;; ptr++)
6889    
6890      ONE_CHAR:      ONE_CHAR:
6891      previous = code;      previous = code;
6892    
6893        /* For caseless UTF-8 mode when UCP support is available, check whether
6894        this character has more than one other case. If so, generate a special
6895        OP_PROP item instead of OP_CHARI. */
6896    
6897    #ifdef SUPPORT_UCP
6898        if (utf && (options & PCRE_CASELESS) != 0)
6899          {
6900          GETCHAR(c, mcbuffer);
6901          if ((c = UCD_CASESET(c)) != 0)
6902            {
6903            *code++ = OP_PROP;
6904            *code++ = PT_CLIST;
6905            *code++ = c;
6906            if (firstchar == REQ_UNSET) firstchar = zerofirstchar = REQ_NONE;
6907            break;
6908            }
6909          }
6910    #endif
6911    
6912        /* Caseful matches, or not one of the multicase characters. */
6913    
6914      *code++ = ((options & PCRE_CASELESS) != 0)? OP_CHARI : OP_CHAR;      *code++ = ((options & PCRE_CASELESS) != 0)? OP_CHARI : OP_CHAR;
6915      for (c = 0; c < mclength; c++) *code++ = mcbuffer[c];      for (c = 0; c < mclength; c++) *code++ = mcbuffer[c];
6916    
# Line 7650  Returns:        pointer to compiled data Line 7610  Returns:        pointer to compiled data
7610                  with errorptr and erroroffset set                  with errorptr and erroroffset set
7611  */  */
7612    
7613  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
7614  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION
7615  pcre_compile(const char *pattern, int options, const char **errorptr,  pcre_compile(const char *pattern, int options, const char **errorptr,
7616    int *erroroffset, const unsigned char *tables)    int *erroroffset, const unsigned char *tables)
7617  #else  #elif defined COMPILE_PCRE16
7618  PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION
7619  pcre16_compile(PCRE_SPTR16 pattern, int options, const char **errorptr,  pcre16_compile(PCRE_SPTR16 pattern, int options, const char **errorptr,
7620    int *erroroffset, const unsigned char *tables)    int *erroroffset, const unsigned char *tables)
7621    #elif defined COMPILE_PCRE32
7622    PCRE_EXP_DEFN pcre32 * PCRE_CALL_CONVENTION
7623    pcre32_compile(PCRE_SPTR32 pattern, int options, const char **errorptr,
7624      int *erroroffset, const unsigned char *tables)
7625  #endif  #endif
7626  {  {
7627  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
7628  return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, tables);  return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
7629  #else  #elif defined COMPILE_PCRE16
7630  return pcre16_compile2(pattern, options, NULL, errorptr, erroroffset, tables);  return pcre16_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
7631    #elif defined COMPILE_PCRE32
7632    return pcre32_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
7633  #endif  #endif
7634  }  }
7635    
7636    
7637  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
7638  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION
7639  pcre_compile2(const char *pattern, int options, int *errorcodeptr,  pcre_compile2(const char *pattern, int options, int *errorcodeptr,
7640    const char **errorptr, int *erroroffset, const unsigned char *tables)    const char **errorptr, int *erroroffset, const unsigned char *tables)
7641  #else  #elif defined COMPILE_PCRE16
7642  PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION
7643  pcre16_compile2(PCRE_SPTR16 pattern, int options, int *errorcodeptr,  pcre16_compile2(PCRE_SPTR16 pattern, int options, int *errorcodeptr,
7644    const char **errorptr, int *erroroffset, const unsigned char *tables)    const char **errorptr, int *erroroffset, const unsigned char *tables)
7645    #elif defined COMPILE_PCRE32
7646    PCRE_EXP_DEFN pcre32 * PCRE_CALL_CONVENTION
7647    pcre32_compile2(PCRE_SPTR32 pattern, int options, int *errorcodeptr,
7648      const char **errorptr, int *erroroffset, const unsigned char *tables)
7649  #endif  #endif
7650  {  {
7651  REAL_PCRE *re;  REAL_PCRE *re;
# Line 7761  while (ptr[skipatstart] == CHAR_LEFT_PAR Line 7731  while (ptr[skipatstart] == CHAR_LEFT_PAR
7731    if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF_RIGHTPAR, 6) == 0)    if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF_RIGHTPAR, 6) == 0)
7732      { skipatstart += 8; options |= PCRE_UTF16; continue; }      { skipatstart += 8; options |= PCRE_UTF16; continue; }
7733  #endif  #endif
7734    #ifdef COMPILE_PCRE32
7735      if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF_RIGHTPAR, 6) == 0)
7736        { skipatstart += 8; options |= PCRE_UTF32; continue; }
7737    #endif
7738    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)
7739      { skipatstart += 6; options |= PCRE_UCP; continue; }      { skipatstart += 6; options |= PCRE_UCP; continue; }
7740    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 7789  while (ptr[skipatstart] == CHAR_LEFT_PAR Line 7763  while (ptr[skipatstart] == CHAR_LEFT_PAR
7763    else break;    else break;
7764    }    }
7765    
7766  /* PCRE_UTF16 has the same value as PCRE_UTF8. */  /* PCRE_UTF(16|32) have the same value as PCRE_UTF8. */
7767  utf = (options & PCRE_UTF8) != 0;  utf = (options & PCRE_UTF8) != 0;
7768    
7769  /* 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 7801  not used here. */ Line 7775  not used here. */
7775  if (utf && (options & PCRE_NO_UTF8_CHECK) == 0 &&  if (utf && (options & PCRE_NO_UTF8_CHECK) == 0 &&
7776       (errorcode = PRIV(valid_utf)((PCRE_PUCHAR)pattern, -1, erroroffset)) != 0)       (errorcode = PRIV(valid_utf)((PCRE_PUCHAR)pattern, -1, erroroffset)) != 0)
7777    {    {
7778  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
7779    errorcode = ERR44;    errorcode = ERR44;
7780  #else  #elif defined COMPILE_PCRE16
7781    errorcode = ERR74;    errorcode = ERR74;
7782    #elif defined COMPILE_PCRE32
7783      errorcode = ERR77;
7784  #endif  #endif
7785    goto PCRE_EARLY_ERROR_RETURN2;    goto PCRE_EARLY_ERROR_RETURN2;
7786    }    }
# Line 7968  re->name_count = cd->names_found; Line 7944  re->name_count = cd->names_found;
7944  re->ref_count = 0;  re->ref_count = 0;
7945  re->tables = (tables == PRIV(default_tables))? NULL : tables;  re->tables = (tables == PRIV(default_tables))? NULL : tables;
7946  re->nullpad = NULL;  re->nullpad = NULL;
7947    #ifdef COMPILE_PCRE32
7948    re->dummy1 = re->dummy2 = 0;
7949    #endif
7950    
7951  /* 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
7952  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 8130  if ((re->options & PCRE_ANCHORED) == 0) Line 8109  if ((re->options & PCRE_ANCHORED) == 0)
8109        firstchar = find_firstassertedchar(codestart, FALSE);        firstchar = find_firstassertedchar(codestart, FALSE);
8110      if (firstchar >= 0)   /* Remove caseless flag for non-caseable chars */      if (firstchar >= 0)   /* Remove caseless flag for non-caseable chars */
8111        {        {
8112  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
8113        re->first_char = firstchar & 0xff;        re->first_char = firstchar & 0xff;
8114  #else  #elif defined COMPILE_PCRE16
 #ifdef COMPILE_PCRE16  
8115        re->first_char = firstchar & 0xffff;        re->first_char = firstchar & 0xffff;
8116  #endif  #elif defined COMPILE_PCRE32
8117          re->first_char = firstchar & ~REQ_MASK;
8118  #endif  #endif
8119        if ((firstchar & REQ_CASELESS) != 0)        if ((firstchar & REQ_CASELESS) != 0)
8120          {          {
# Line 8172  bytes. */ Line 8151  bytes. */
8151  if (reqchar >= 0 &&  if (reqchar >= 0 &&
8152       ((re->options & PCRE_ANCHORED) == 0 || (reqchar & REQ_VARY) != 0))       ((re->options & PCRE_ANCHORED) == 0 || (reqchar & REQ_VARY) != 0))
8153    {    {
8154  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
8155    re->req_char = reqchar & 0xff;    re->req_char = reqchar & 0xff;
8156  #else  #elif defined COMPILE_PCRE16
 #ifdef COMPILE_PCRE16  
8157    re->req_char = reqchar & 0xffff;    re->req_char = reqchar & 0xffff;
8158  #endif  #elif defined COMPILE_PCRE32
8159      re->req_char = reqchar & ~REQ_MASK;
8160  #endif  #endif
8161    if ((reqchar & REQ_CASELESS) != 0)    if ((reqchar & REQ_CASELESS) != 0)
8162      {      {
# Line 8229  if ((re->flags & PCRE_REQCHSET) != 0) Line 8208  if ((re->flags & PCRE_REQCHSET) != 0)
8208      else printf("Req char = \\x%02x%s\n", ch, caseless);      else printf("Req char = \\x%02x%s\n", ch, caseless);
8209    }    }
8210    
8211  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
8212  pcre_printint((pcre *)re, stdout, TRUE);  pcre_printint((pcre *)re, stdout, TRUE);
8213  #else  #elif defined COMPILE_PCRE16
8214  pcre16_printint((pcre *)re, stdout, TRUE);  pcre16_printint((pcre *)re, stdout, TRUE);
8215    #elif defined COMPILE_PCRE32
8216    pcre32_printint((pcre *)re, stdout, TRUE);
8217  #endif  #endif
8218    
8219  /* 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 8248  if (code - codestart > length) Line 8229  if (code - codestart > length)
8229    }    }
8230  #endif   /* PCRE_DEBUG */  #endif   /* PCRE_DEBUG */
8231    
8232  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
8233  return (pcre *)re;  return (pcre *)re;
8234  #else  #elif defined COMPILE_PCRE16
8235  return (pcre16 *)re;  return (pcre16 *)re;
8236    #elif defined COMPILE_PCRE32
8237    return (pcre32 *)re;
8238  #endif  #endif
8239  }  }
8240    

Legend:
Removed from v.994  
changed lines
  Added in v.1056

  ViewVC Help
Powered by ViewVC 1.1.5