/[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 552 by ph10, Wed Oct 13 10:15:41 2010 UTC revision 574 by ph10, Sat Nov 20 17:47:27 2010 UTC
# Line 408  static const char error_texts[] = Line 408  static const char error_texts[] =
408    "different names for subpatterns of the same number are not allowed\0"    "different names for subpatterns of the same number are not allowed\0"
409    "(*MARK) must have an argument\0"    "(*MARK) must have an argument\0"
410    "this version of PCRE is not compiled with PCRE_UCP support\0"    "this version of PCRE is not compiled with PCRE_UCP support\0"
411      "\\c must be followed by an ASCII character\0"
412    ;    ;
413    
414  /* 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 841  else Line 842  else
842      break;      break;
843    
844      /* For \c, a following letter is upper-cased; then the 0x40 bit is flipped.      /* For \c, a following letter is upper-cased; then the 0x40 bit is flipped.
845      This coding is ASCII-specific, but then the whole concept of \cx is      An error is given if the byte following \c is not an ASCII character. This
846        coding is ASCII-specific, but then the whole concept of \cx is
847      ASCII-specific. (However, an EBCDIC equivalent has now been added.) */      ASCII-specific. (However, an EBCDIC equivalent has now been added.) */
848    
849      case CHAR_c:      case CHAR_c:
# Line 851  else Line 853  else
853        *errorcodeptr = ERR2;        *errorcodeptr = ERR2;
854        break;        break;
855        }        }
856    #ifndef EBCDIC    /* ASCII/UTF-8 coding */
857  #ifndef EBCDIC  /* ASCII/UTF-8 coding */      if (c > 127)  /* Excludes all non-ASCII in either mode */
858          {
859          *errorcodeptr = ERR68;
860          break;
861          }
862      if (c >= CHAR_a && c <= CHAR_z) c -= 32;      if (c >= CHAR_a && c <= CHAR_z) c -= 32;
863      c ^= 0x40;      c ^= 0x40;
864  #else           /* EBCDIC coding */  #else             /* EBCDIC coding */
865      if (c >= CHAR_a && c <= CHAR_z) c += 64;      if (c >= CHAR_a && c <= CHAR_z) c += 64;
866      c ^= 0xC0;      c ^= 0xC0;
867  #endif  #endif
# Line 1110  Arguments: Line 1116  Arguments:
1116    name         name to seek, or NULL if seeking a numbered subpattern    name         name to seek, or NULL if seeking a numbered subpattern
1117    lorn         name length, or subpattern number if name is NULL    lorn         name length, or subpattern number if name is NULL
1118    xmode        TRUE if we are in /x mode    xmode        TRUE if we are in /x mode
1119      utf8         TRUE if we are in UTF-8 mode
1120    count        pointer to the current capturing subpattern number (updated)    count        pointer to the current capturing subpattern number (updated)
1121    
1122  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 1117  Returns:       the number of the named s Line 1124  Returns:       the number of the named s
1124    
1125  static int  static int
1126  find_parens_sub(uschar **ptrptr, compile_data *cd, const uschar *name, int lorn,  find_parens_sub(uschar **ptrptr, compile_data *cd, const uschar *name, int lorn,
1127    BOOL xmode, int *count)    BOOL xmode, BOOL utf8, int *count)
1128  {  {
1129  uschar *ptr = *ptrptr;  uschar *ptr = *ptrptr;
1130  int start_count = *count;  int start_count = *count;
# Line 1278  for (; *ptr != 0; ptr++) Line 1285  for (; *ptr != 0; ptr++)
1285    
1286    if (xmode && *ptr == CHAR_NUMBER_SIGN)    if (xmode && *ptr == CHAR_NUMBER_SIGN)
1287      {      {
1288      while (*(++ptr) != 0 && *ptr != CHAR_NL) {};      ptr++;
1289        while (*ptr != 0)
1290          {
1291          if (IS_NEWLINE(ptr)) { ptr += cd->nllen - 1; break; }
1292          ptr++;
1293    #ifdef SUPPORT_UTF8
1294          if (utf8) while ((*ptr & 0xc0) == 0x80) ptr++;
1295    #endif
1296          }
1297      if (*ptr == 0) goto FAIL_EXIT;      if (*ptr == 0) goto FAIL_EXIT;
1298      continue;      continue;
1299      }      }
# Line 1287  for (; *ptr != 0; ptr++) Line 1302  for (; *ptr != 0; ptr++)
1302    
1303    if (*ptr == CHAR_LEFT_PARENTHESIS)    if (*ptr == CHAR_LEFT_PARENTHESIS)
1304      {      {
1305      int rc = find_parens_sub(&ptr, cd, name, lorn, xmode, count);      int rc = find_parens_sub(&ptr, cd, name, lorn, xmode, utf8, count);
1306      if (rc > 0) return rc;      if (rc > 0) return rc;
1307      if (*ptr == 0) goto FAIL_EXIT;      if (*ptr == 0) goto FAIL_EXIT;
1308      }      }
# Line 1333  Arguments: Line 1348  Arguments:
1348    name         name to seek, or NULL if seeking a numbered subpattern    name         name to seek, or NULL if seeking a numbered subpattern
1349    lorn         name length, or subpattern number if name is NULL    lorn         name length, or subpattern number if name is NULL
1350    xmode        TRUE if we are in /x mode    xmode        TRUE if we are in /x mode
1351      utf8         TRUE if we are in UTF-8 mode
1352    
1353  Returns:       the number of the found subpattern, or -1 if not found  Returns:       the number of the found subpattern, or -1 if not found
1354  */  */
1355    
1356  static int  static int
1357  find_parens(compile_data *cd, const uschar *name, int lorn, BOOL xmode)  find_parens(compile_data *cd, const uschar *name, int lorn, BOOL xmode,
1358      BOOL utf8)
1359  {  {
1360  uschar *ptr = (uschar *)cd->start_pattern;  uschar *ptr = (uschar *)cd->start_pattern;
1361  int count = 0;  int count = 0;
# Line 1351  matching closing parens. That is why we Line 1368  matching closing parens. That is why we
1368    
1369  for (;;)  for (;;)
1370    {    {
1371    rc = find_parens_sub(&ptr, cd, name, lorn, xmode, &count);    rc = find_parens_sub(&ptr, cd, name, lorn, xmode, utf8, &count);
1372    if (rc > 0 || *ptr++ == 0) break;    if (rc > 0 || *ptr++ == 0) break;
1373    }    }
1374    
# Line 2515  if ((options & PCRE_EXTENDED) != 0) Line 2532  if ((options & PCRE_EXTENDED) != 0)
2532      while ((cd->ctypes[*ptr] & ctype_space) != 0) ptr++;      while ((cd->ctypes[*ptr] & ctype_space) != 0) ptr++;
2533      if (*ptr == CHAR_NUMBER_SIGN)      if (*ptr == CHAR_NUMBER_SIGN)
2534        {        {
2535        while (*(++ptr) != 0)        ptr++;
2536          while (*ptr != 0)
2537            {
2538          if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }          if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }
2539            ptr++;
2540    #ifdef SUPPORT_UTF8
2541            if (utf8) while ((*ptr & 0xc0) == 0x80) ptr++;
2542    #endif
2543            }
2544        }        }
2545      else break;      else break;
2546      }      }
# Line 2552  if ((options & PCRE_EXTENDED) != 0) Line 2576  if ((options & PCRE_EXTENDED) != 0)
2576      while ((cd->ctypes[*ptr] & ctype_space) != 0) ptr++;      while ((cd->ctypes[*ptr] & ctype_space) != 0) ptr++;
2577      if (*ptr == CHAR_NUMBER_SIGN)      if (*ptr == CHAR_NUMBER_SIGN)
2578        {        {
2579        while (*(++ptr) != 0)        ptr++;
2580          while (*ptr != 0)
2581            {
2582          if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }          if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }
2583            ptr++;
2584    #ifdef SUPPORT_UTF8
2585            if (utf8) while ((*ptr & 0xc0) == 0x80) ptr++;
2586    #endif
2587            }
2588        }        }
2589      else break;      else break;
2590      }      }
# Line 3126  for (;; ptr++) Line 3157  for (;; ptr++)
3157      if ((cd->ctypes[c] & ctype_space) != 0) continue;      if ((cd->ctypes[c] & ctype_space) != 0) continue;
3158      if (c == CHAR_NUMBER_SIGN)      if (c == CHAR_NUMBER_SIGN)
3159        {        {
3160        while (*(++ptr) != 0)        ptr++;
3161          while (*ptr != 0)
3162          {          {
3163          if (IS_NEWLINE(ptr)) { ptr += cd->nllen - 1; break; }          if (IS_NEWLINE(ptr)) { ptr += cd->nllen - 1; break; }
3164            ptr++;
3165    #ifdef SUPPORT_UTF8
3166            if (utf8) while ((*ptr & 0xc0) == 0x80) ptr++;
3167    #endif
3168          }          }
3169        if (*ptr != 0) continue;        if (*ptr != 0) continue;
3170    
# Line 5036  for (;; ptr++) Line 5072  for (;; ptr++)
5072          /* Search the pattern for a forward reference */          /* Search the pattern for a forward reference */
5073    
5074          else if ((i = find_parens(cd, name, namelen,          else if ((i = find_parens(cd, name, namelen,
5075                          (options & PCRE_EXTENDED) != 0)) > 0)                          (options & PCRE_EXTENDED) != 0, utf8)) > 0)
5076            {            {
5077            PUT2(code, 2+LINK_SIZE, i);            PUT2(code, 2+LINK_SIZE, i);
5078            code[1+LINK_SIZE]++;            code[1+LINK_SIZE]++;
# Line 5382  for (;; ptr++) Line 5418  for (;; ptr++)
5418              }              }
5419            else if ((recno =                /* Forward back reference */            else if ((recno =                /* Forward back reference */
5420                      find_parens(cd, name, namelen,                      find_parens(cd, name, namelen,
5421                        (options & PCRE_EXTENDED) != 0)) <= 0)                        (options & PCRE_EXTENDED) != 0, utf8)) <= 0)
5422              {              {
5423              *errorcodeptr = ERR15;              *errorcodeptr = ERR15;
5424              goto FAILED;              goto FAILED;
# Line 5493  for (;; ptr++) Line 5529  for (;; ptr++)
5529              if (called == NULL)              if (called == NULL)
5530                {                {
5531                if (find_parens(cd, NULL, recno,                if (find_parens(cd, NULL, recno,
5532                      (options & PCRE_EXTENDED) != 0) < 0)                      (options & PCRE_EXTENDED) != 0, utf8) < 0)
5533                  {                  {
5534                  *errorcodeptr = ERR15;                  *errorcodeptr = ERR15;
5535                  goto FAILED;                  goto FAILED;

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

  ViewVC Help
Powered by ViewVC 1.1.5