/[pcre]/code/tags/pcre-8.33/pcre_compile.c
ViewVC logotype

Diff of /code/tags/pcre-8.33/pcre_compile.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1048 by ph10, Fri Sep 28 16:03:14 2012 UTC revision 1055 by chpe, Tue Oct 16 15:53:30 2012 UTC
# Line 53  supporting internal functions that are n Line 53  supporting internal functions that are n
53  #include "pcre_internal.h"  #include "pcre_internal.h"
54    
55    
56  /* When PCRE_DEBUG is defined, we need the pcre(16)_printint() function, which  /* When PCRE_DEBUG is defined, we need the pcre(16|32)_printint() function, which
57  is also used by pcretest. PCRE_DEBUG is not defined when building a production  is also used by pcretest. PCRE_DEBUG is not defined when building a production
58  library. We do not need to select pcre16_printint.c specially, because the  library. We do not need to select pcre16_printint.c specially, because the
59  COMPILE_PCREx macro will already be appropriately set. */  COMPILE_PCREx macro will already be appropriately set. */
# Line 123  overrun before it actually does run off Line 123  overrun before it actually does run off
123    
124  #define REQ_CASELESS   0x10000000l      /* Indicates caselessness */  #define REQ_CASELESS   0x10000000l      /* Indicates caselessness */
125  #define REQ_VARY       0x20000000l      /* Reqchar followed non-literal item */  #define REQ_VARY       0x20000000l      /* Reqchar followed non-literal item */
126    #define REQ_MASK       (REQ_CASELESS | REQ_VARY)
127    
128  /* Repeated character flags. */  /* Repeated character flags. */
129    
# Line 503  static const char error_texts[] = Line 504  static const char error_texts[] =
504    /* 75 */    /* 75 */
505    "name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN)\0"    "name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN)\0"
506    "character value in \\u.... sequence is too large\0"    "character value in \\u.... sequence is too large\0"
507      "invalid UTF-32 string\0"
508    ;    ;
509    
510  /* Table to identify digits and hex digits. This is used when compiling  /* Table to identify digits and hex digits. This is used when compiling
# Line 838  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 1069  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 1367  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 1601  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 1704  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 1838  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 1852  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;
# Line 1895  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 2034  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 2121  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 2173  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 2241  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 2327  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 2560  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 2626  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 2773  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 3024  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 3476  if ((options & PCRE_CASELESS) != 0) Line 3478  if ((options & PCRE_CASELESS) != 0)
3478  length - this means that the same lists of (e.g.) horizontal spaces can be used  length - this means that the same lists of (e.g.) horizontal spaces can be used
3479  in all cases. */  in all cases. */
3480    
3481  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
3482  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3483    if ((options & PCRE_UTF8) == 0)    if ((options & PCRE_UTF8) == 0)
3484  #endif  #endif
3485    if (end > 0xff) end = 0xff;    if (end > 0xff) end = 0xff;
 #endif  
3486    
3487  #ifdef COMPILE_PCRE16  #elif defined COMPILE_PCRE16
3488  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3489    if ((options & PCRE_UTF16) == 0)    if ((options & PCRE_UTF16) == 0)
3490  #endif  #endif
3491    if (end > 0xffff) end = 0xffff;    if (end > 0xffff) end = 0xffff;
3492    
3493    #elif defined COMPILE_PCRE32
3494    #ifdef SUPPORT_UTF
3495      if ((options & PCRE_UTF32) == 0)
3496        if (end > 0xffffu) end = 0xffffu; // FIXMEchpe rebase fix this
3497  #endif  #endif
3498    #endif /* COMPILE_PCRE[8|16|32] */
3499    
3500  /* If all characters are less than 256, use the bit map. Otherwise use extra  /* If all characters are less than 256, use the bit map. Otherwise use extra
3501  data. */  data. */
# Line 3696  must not do this for other options (e.g. Line 3703  must not do this for other options (e.g.
3703  dynamically as we process the pattern. */  dynamically as we process the pattern. */
3704    
3705  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3706  /* PCRE_UTF16 has the same value as PCRE_UTF8. */  /* PCRE_UTF(16|32) have the same value as PCRE_UTF8. */
3707  BOOL utf = (options & PCRE_UTF8) != 0;  BOOL utf = (options & PCRE_UTF8) != 0;
3708  pcre_uchar utf_chars[6];  pcre_uchar utf_chars[6];
3709  #else  #else
# Line 4081  for (;; ptr++) Line 4088  for (;; ptr++)
4088        {        {
4089        const pcre_uchar *oldptr;        const pcre_uchar *oldptr;
4090    
4091  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4092        if (utf && HAS_EXTRALEN(c))        if (utf && HAS_EXTRALEN(c))
4093          {                           /* Braces are required because the */          {                           /* Braces are required because the */
4094          GETCHARLEN(c, ptr, ptr);    /* macro generates multiple statements */          GETCHARLEN(c, ptr, ptr);    /* macro generates multiple statements */
# Line 4500  for (;; ptr++) Line 4507  for (;; ptr++)
4507          if (negate_class)          if (negate_class)
4508            {            {
4509  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
4510                // FIXMEchpe pcreuint32?
4511            int d;            int d;
4512  #endif  #endif
4513            if (firstchar == REQ_UNSET) firstchar = REQ_NONE;            if (firstchar == REQ_UNSET) firstchar = REQ_NONE;
# Line 4523  for (;; ptr++) Line 4531  for (;; ptr++)
4531    
4532              {              {
4533              *code++ = ((options & PCRE_CASELESS) != 0)? OP_NOTI: OP_NOT;              *code++ = ((options & PCRE_CASELESS) != 0)? OP_NOTI: OP_NOT;
4534  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4535              if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)              if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)
4536                code += PRIV(ord2utf)(c, code);                code += PRIV(ord2utf)(c, code);
4537              else              else
# Line 4539  for (;; ptr++) Line 4547  for (;; ptr++)
4547          /* For a single, positive character, get the value into mcbuffer, and          /* For a single, positive character, get the value into mcbuffer, and
4548          then we can handle this with the normal one-character code. */          then we can handle this with the normal one-character code. */
4549    
4550  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4551          if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)          if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)
4552            mclength = PRIV(ord2utf)(c, mcbuffer);            mclength = PRIV(ord2utf)(c, mcbuffer);
4553          else          else
# Line 4774  for (;; ptr++) Line 4782  for (;; ptr++)
4782        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
4783        it's a length rather than a small character. */        it's a length rather than a small character. */
4784    
4785  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4786        if (utf && NOT_FIRSTCHAR(code[-1]))        if (utf && NOT_FIRSTCHAR(code[-1]))
4787          {          {
4788          pcre_uchar *lastchar = code - 1;          pcre_uchar *lastchar = code - 1;
# Line 4910  for (;; ptr++) Line 4918  for (;; ptr++)
4918    
4919          if (repeat_max < 0)          if (repeat_max < 0)
4920            {            {
4921  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4922            if (utf && (c & UTF_LENGTH) != 0)            if (utf && (c & UTF_LENGTH) != 0)
4923              {              {
4924              memcpy(code, utf_chars, IN_UCHARS(c & 7));              memcpy(code, utf_chars, IN_UCHARS(c & 7));
# Line 4935  for (;; ptr++) Line 4943  for (;; ptr++)
4943    
4944          else if (repeat_max != repeat_min)          else if (repeat_max != repeat_min)
4945            {            {
4946  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4947            if (utf && (c & UTF_LENGTH) != 0)            if (utf && (c & UTF_LENGTH) != 0)
4948              {              {
4949              memcpy(code, utf_chars, IN_UCHARS(c & 7));              memcpy(code, utf_chars, IN_UCHARS(c & 7));
# Line 4965  for (;; ptr++) Line 4973  for (;; ptr++)
4973    
4974        /* The character or character type itself comes last in all cases. */        /* The character or character type itself comes last in all cases. */
4975    
4976  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4977        if (utf && (c & UTF_LENGTH) != 0)        if (utf && (c & UTF_LENGTH) != 0)
4978          {          {
4979          memcpy(code, utf_chars, IN_UCHARS(c & 7));          memcpy(code, utf_chars, IN_UCHARS(c & 7));
# Line 5452  for (;; ptr++) Line 5460  for (;; ptr++)
5460        else if (*tempcode == OP_EXACT || *tempcode == OP_NOTEXACT)        else if (*tempcode == OP_EXACT || *tempcode == OP_NOTEXACT)
5461          {          {
5462          tempcode += PRIV(OP_lengths)[*tempcode];          tempcode += PRIV(OP_lengths)[*tempcode];
5463  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
5464          if (utf && HAS_EXTRALEN(tempcode[-1]))          if (utf && HAS_EXTRALEN(tempcode[-1]))
5465            tempcode += GET_EXTRALEN(tempcode[-1]);            tempcode += GET_EXTRALEN(tempcode[-1]);
5466  #endif  #endif
# Line 5550  for (;; ptr++) Line 5558  for (;; ptr++)
5558          arg = ++ptr;          arg = ++ptr;
5559          while (*ptr != 0 && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;          while (*ptr != 0 && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;
5560          arglen = (int)(ptr - arg);          arglen = (int)(ptr - arg);
5561          if (arglen > (int)MAX_MARK)          if ((unsigned int)arglen > MAX_MARK)
5562            {            {
5563            *errorcodeptr = ERR75;            *errorcodeptr = ERR75;
5564            goto FAILED;            goto FAILED;
# Line 6852  for (;; ptr++) Line 6860  for (;; ptr++)
6860      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
6861      handle it as a data character. */      handle it as a data character. */
6862    
6863  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
6864      if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)      if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)
6865        mclength = PRIV(ord2utf)(c, mcbuffer);        mclength = PRIV(ord2utf)(c, mcbuffer);
6866      else      else
# Line 6875  for (;; ptr++) Line 6883  for (;; ptr++)
6883      mclength = 1;      mclength = 1;
6884      mcbuffer[0] = c;      mcbuffer[0] = c;
6885    
6886  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
6887      if (utf && HAS_EXTRALEN(c))      if (utf && HAS_EXTRALEN(c))
6888        ACROSSCHAR(TRUE, ptr[1], mcbuffer[mclength++] = *(++ptr));        ACROSSCHAR(TRUE, ptr[1], mcbuffer[mclength++] = *(++ptr));
6889  #endif  #endif
# Line 7606  Returns:        pointer to compiled data Line 7614  Returns:        pointer to compiled data
7614                  with errorptr and erroroffset set                  with errorptr and erroroffset set
7615  */  */
7616    
7617  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
7618  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION
7619  pcre_compile(const char *pattern, int options, const char **errorptr,  pcre_compile(const char *pattern, int options, const char **errorptr,
7620    int *erroroffset, const unsigned char *tables)    int *erroroffset, const unsigned char *tables)
7621  #else  #elif defined COMPILE_PCRE16
7622  PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION
7623  pcre16_compile(PCRE_SPTR16 pattern, int options, const char **errorptr,  pcre16_compile(PCRE_SPTR16 pattern, int options, const char **errorptr,
7624    int *erroroffset, const unsigned char *tables)    int *erroroffset, const unsigned char *tables)
7625    #elif defined COMPILE_PCRE32
7626    PCRE_EXP_DEFN pcre32 * PCRE_CALL_CONVENTION
7627    pcre32_compile(PCRE_SPTR32 pattern, int options, const char **errorptr,
7628      int *erroroffset, const unsigned char *tables)
7629  #endif  #endif
7630  {  {
7631  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
7632  return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, tables);  return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
7633  #else  #elif defined COMPILE_PCRE16
7634  return pcre16_compile2(pattern, options, NULL, errorptr, erroroffset, tables);  return pcre16_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
7635    #elif defined COMPILE_PCRE32
7636    return pcre32_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
7637  #endif  #endif
7638  }  }
7639    
7640    
7641  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
7642  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION
7643  pcre_compile2(const char *pattern, int options, int *errorcodeptr,  pcre_compile2(const char *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  #else  #elif defined COMPILE_PCRE16
7646  PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION
7647  pcre16_compile2(PCRE_SPTR16 pattern, int options, int *errorcodeptr,  pcre16_compile2(PCRE_SPTR16 pattern, int options, int *errorcodeptr,
7648    const char **errorptr, int *erroroffset, const unsigned char *tables)    const char **errorptr, int *erroroffset, const unsigned char *tables)
7649    #elif defined COMPILE_PCRE32
7650    PCRE_EXP_DEFN pcre32 * PCRE_CALL_CONVENTION
7651    pcre32_compile2(PCRE_SPTR32 pattern, int options, int *errorcodeptr,
7652      const char **errorptr, int *erroroffset, const unsigned char *tables)
7653  #endif  #endif
7654  {  {
7655  REAL_PCRE *re;  REAL_PCRE *re;
# Line 7717  while (ptr[skipatstart] == CHAR_LEFT_PAR Line 7735  while (ptr[skipatstart] == CHAR_LEFT_PAR
7735    if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF_RIGHTPAR, 6) == 0)    if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF_RIGHTPAR, 6) == 0)
7736      { skipatstart += 8; options |= PCRE_UTF16; continue; }      { skipatstart += 8; options |= PCRE_UTF16; continue; }
7737  #endif  #endif
7738    #ifdef COMPILE_PCRE32
7739      if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF_RIGHTPAR, 6) == 0)
7740        { skipatstart += 8; options |= PCRE_UTF32; continue; }
7741    #endif
7742    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)
7743      { skipatstart += 6; options |= PCRE_UCP; continue; }      { skipatstart += 6; options |= PCRE_UCP; continue; }
7744    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 7745  while (ptr[skipatstart] == CHAR_LEFT_PAR Line 7767  while (ptr[skipatstart] == CHAR_LEFT_PAR
7767    else break;    else break;
7768    }    }
7769    
7770  /* PCRE_UTF16 has the same value as PCRE_UTF8. */  /* PCRE_UTF(16|32) have the same value as PCRE_UTF8. */
7771  utf = (options & PCRE_UTF8) != 0;  utf = (options & PCRE_UTF8) != 0;
7772    
7773  /* 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 7757  not used here. */ Line 7779  not used here. */
7779  if (utf && (options & PCRE_NO_UTF8_CHECK) == 0 &&  if (utf && (options & PCRE_NO_UTF8_CHECK) == 0 &&
7780       (errorcode = PRIV(valid_utf)((PCRE_PUCHAR)pattern, -1, erroroffset)) != 0)       (errorcode = PRIV(valid_utf)((PCRE_PUCHAR)pattern, -1, erroroffset)) != 0)
7781    {    {
7782  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
7783    errorcode = ERR44;    errorcode = ERR44;
7784  #else  #elif defined COMPILE_PCRE16
7785    errorcode = ERR74;    errorcode = ERR74;
7786    #elif defined COMPILE_PCRE32
7787      errorcode = ERR77;
7788  #endif  #endif
7789    goto PCRE_EARLY_ERROR_RETURN2;    goto PCRE_EARLY_ERROR_RETURN2;
7790    }    }
# Line 7924  re->name_count = cd->names_found; Line 7948  re->name_count = cd->names_found;
7948  re->ref_count = 0;  re->ref_count = 0;
7949  re->tables = (tables == PRIV(default_tables))? NULL : tables;  re->tables = (tables == PRIV(default_tables))? NULL : tables;
7950  re->nullpad = NULL;  re->nullpad = NULL;
7951    #ifdef COMPILE_PCRE32
7952    re->dummy1 = re->dummy2 = 0;
7953    #endif
7954    
7955  /* 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
7956  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 8086  if ((re->options & PCRE_ANCHORED) == 0) Line 8113  if ((re->options & PCRE_ANCHORED) == 0)
8113        firstchar = find_firstassertedchar(codestart, FALSE);        firstchar = find_firstassertedchar(codestart, FALSE);
8114      if (firstchar >= 0)   /* Remove caseless flag for non-caseable chars */      if (firstchar >= 0)   /* Remove caseless flag for non-caseable chars */
8115        {        {
8116  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
8117        re->first_char = firstchar & 0xff;        re->first_char = firstchar & 0xff;
8118  #else  #elif defined COMPILE_PCRE16
 #ifdef COMPILE_PCRE16  
8119        re->first_char = firstchar & 0xffff;        re->first_char = firstchar & 0xffff;
8120  #endif  #elif defined COMPILE_PCRE32
8121          re->first_char = firstchar & ~REQ_MASK;
8122  #endif  #endif
8123        if ((firstchar & REQ_CASELESS) != 0)        if ((firstchar & REQ_CASELESS) != 0)
8124          {          {
# Line 8128  bytes. */ Line 8155  bytes. */
8155  if (reqchar >= 0 &&  if (reqchar >= 0 &&
8156       ((re->options & PCRE_ANCHORED) == 0 || (reqchar & REQ_VARY) != 0))       ((re->options & PCRE_ANCHORED) == 0 || (reqchar & REQ_VARY) != 0))
8157    {    {
8158  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
8159    re->req_char = reqchar & 0xff;    re->req_char = reqchar & 0xff;
8160  #else  #elif defined COMPILE_PCRE16
 #ifdef COMPILE_PCRE16  
8161    re->req_char = reqchar & 0xffff;    re->req_char = reqchar & 0xffff;
8162  #endif  #elif defined COMPILE_PCRE32
8163      re->req_char = reqchar & ~REQ_MASK;
8164  #endif  #endif
8165    if ((reqchar & REQ_CASELESS) != 0)    if ((reqchar & REQ_CASELESS) != 0)
8166      {      {
# Line 8185  if ((re->flags & PCRE_REQCHSET) != 0) Line 8212  if ((re->flags & PCRE_REQCHSET) != 0)
8212      else printf("Req char = \\x%02x%s\n", ch, caseless);      else printf("Req char = \\x%02x%s\n", ch, caseless);
8213    }    }
8214    
8215  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
8216  pcre_printint((pcre *)re, stdout, TRUE);  pcre_printint((pcre *)re, stdout, TRUE);
8217  #else  #elif defined COMPILE_PCRE16
8218  pcre16_printint((pcre *)re, stdout, TRUE);  pcre16_printint((pcre *)re, stdout, TRUE);
8219    #elif defined COMPILE_PCRE32
8220    pcre32_printint((pcre *)re, stdout, TRUE);
8221  #endif  #endif
8222    
8223  /* 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 8204  if (code - codestart > length) Line 8233  if (code - codestart > length)
8233    }    }
8234  #endif   /* PCRE_DEBUG */  #endif   /* PCRE_DEBUG */
8235    
8236  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
8237  return (pcre *)re;  return (pcre *)re;
8238  #else  #elif defined COMPILE_PCRE16
8239  return (pcre16 *)re;  return (pcre16 *)re;
8240    #elif defined COMPILE_PCRE32
8241    return (pcre32 *)re;
8242  #endif  #endif
8243  }  }
8244    

Legend:
Removed from v.1048  
changed lines
  Added in v.1055

  ViewVC Help
Powered by ViewVC 1.1.5