/[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 556 by ph10, Tue Oct 26 11:06:44 2010 UTC
# Line 1110  Arguments: Line 1110  Arguments:
1110    name         name to seek, or NULL if seeking a numbered subpattern    name         name to seek, or NULL if seeking a numbered subpattern
1111    lorn         name length, or subpattern number if name is NULL    lorn         name length, or subpattern number if name is NULL
1112    xmode        TRUE if we are in /x mode    xmode        TRUE if we are in /x mode
1113      utf8         TRUE if we are in UTF-8 mode
1114    count        pointer to the current capturing subpattern number (updated)    count        pointer to the current capturing subpattern number (updated)
1115    
1116  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 1118  Returns:       the number of the named s
1118    
1119  static int  static int
1120  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,
1121    BOOL xmode, int *count)    BOOL xmode, BOOL utf8, int *count)
1122  {  {
1123  uschar *ptr = *ptrptr;  uschar *ptr = *ptrptr;
1124  int start_count = *count;  int start_count = *count;
# Line 1278  for (; *ptr != 0; ptr++) Line 1279  for (; *ptr != 0; ptr++)
1279    
1280    if (xmode && *ptr == CHAR_NUMBER_SIGN)    if (xmode && *ptr == CHAR_NUMBER_SIGN)
1281      {      {
1282      while (*(++ptr) != 0 && *ptr != CHAR_NL) {};      ptr++;
1283        while (*ptr != 0)
1284          {
1285          if (IS_NEWLINE(ptr)) { ptr += cd->nllen - 1; break; }
1286          ptr++;
1287    #ifdef SUPPORT_UTF8
1288          if (utf8) while ((*ptr & 0xc0) == 0x80) ptr++;
1289    #endif
1290          }
1291      if (*ptr == 0) goto FAIL_EXIT;      if (*ptr == 0) goto FAIL_EXIT;
1292      continue;      continue;
1293      }      }
# Line 1287  for (; *ptr != 0; ptr++) Line 1296  for (; *ptr != 0; ptr++)
1296    
1297    if (*ptr == CHAR_LEFT_PARENTHESIS)    if (*ptr == CHAR_LEFT_PARENTHESIS)
1298      {      {
1299      int rc = find_parens_sub(&ptr, cd, name, lorn, xmode, count);      int rc = find_parens_sub(&ptr, cd, name, lorn, xmode, utf8, count);
1300      if (rc > 0) return rc;      if (rc > 0) return rc;
1301      if (*ptr == 0) goto FAIL_EXIT;      if (*ptr == 0) goto FAIL_EXIT;
1302      }      }
# Line 1333  Arguments: Line 1342  Arguments:
1342    name         name to seek, or NULL if seeking a numbered subpattern    name         name to seek, or NULL if seeking a numbered subpattern
1343    lorn         name length, or subpattern number if name is NULL    lorn         name length, or subpattern number if name is NULL
1344    xmode        TRUE if we are in /x mode    xmode        TRUE if we are in /x mode
1345      utf8         TRUE if we are in UTF-8 mode
1346    
1347  Returns:       the number of the found subpattern, or -1 if not found  Returns:       the number of the found subpattern, or -1 if not found
1348  */  */
1349    
1350  static int  static int
1351  find_parens(compile_data *cd, const uschar *name, int lorn, BOOL xmode)  find_parens(compile_data *cd, const uschar *name, int lorn, BOOL xmode,
1352      BOOL utf8)
1353  {  {
1354  uschar *ptr = (uschar *)cd->start_pattern;  uschar *ptr = (uschar *)cd->start_pattern;
1355  int count = 0;  int count = 0;
# Line 1351  matching closing parens. That is why we Line 1362  matching closing parens. That is why we
1362    
1363  for (;;)  for (;;)
1364    {    {
1365    rc = find_parens_sub(&ptr, cd, name, lorn, xmode, &count);    rc = find_parens_sub(&ptr, cd, name, lorn, xmode, utf8, &count);
1366    if (rc > 0 || *ptr++ == 0) break;    if (rc > 0 || *ptr++ == 0) break;
1367    }    }
1368    
# Line 2515  if ((options & PCRE_EXTENDED) != 0) Line 2526  if ((options & PCRE_EXTENDED) != 0)
2526      while ((cd->ctypes[*ptr] & ctype_space) != 0) ptr++;      while ((cd->ctypes[*ptr] & ctype_space) != 0) ptr++;
2527      if (*ptr == CHAR_NUMBER_SIGN)      if (*ptr == CHAR_NUMBER_SIGN)
2528        {        {
2529        while (*(++ptr) != 0)        ptr++;
2530          while (*ptr != 0)
2531            {
2532          if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }          if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }
2533            ptr++;
2534    #ifdef SUPPORT_UTF8
2535            if (utf8) while ((*ptr & 0xc0) == 0x80) ptr++;
2536    #endif
2537            }
2538        }        }
2539      else break;      else break;
2540      }      }
# Line 2552  if ((options & PCRE_EXTENDED) != 0) Line 2570  if ((options & PCRE_EXTENDED) != 0)
2570      while ((cd->ctypes[*ptr] & ctype_space) != 0) ptr++;      while ((cd->ctypes[*ptr] & ctype_space) != 0) ptr++;
2571      if (*ptr == CHAR_NUMBER_SIGN)      if (*ptr == CHAR_NUMBER_SIGN)
2572        {        {
2573        while (*(++ptr) != 0)        ptr++;
2574          while (*ptr != 0)
2575            {
2576          if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }          if (IS_NEWLINE(ptr)) { ptr += cd->nllen; break; }
2577            ptr++;
2578    #ifdef SUPPORT_UTF8
2579            if (utf8) while ((*ptr & 0xc0) == 0x80) ptr++;
2580    #endif
2581            }
2582        }        }
2583      else break;      else break;
2584      }      }
# Line 3126  for (;; ptr++) Line 3151  for (;; ptr++)
3151      if ((cd->ctypes[c] & ctype_space) != 0) continue;      if ((cd->ctypes[c] & ctype_space) != 0) continue;
3152      if (c == CHAR_NUMBER_SIGN)      if (c == CHAR_NUMBER_SIGN)
3153        {        {
3154        while (*(++ptr) != 0)        ptr++;
3155          while (*ptr != 0)
3156          {          {
3157          if (IS_NEWLINE(ptr)) { ptr += cd->nllen - 1; break; }          if (IS_NEWLINE(ptr)) { ptr += cd->nllen - 1; break; }
3158            ptr++;
3159    #ifdef SUPPORT_UTF8
3160            if (utf8) while ((*ptr & 0xc0) == 0x80) ptr++;
3161    #endif
3162          }          }
3163        if (*ptr != 0) continue;        if (*ptr != 0) continue;
3164    
# Line 5036  for (;; ptr++) Line 5066  for (;; ptr++)
5066          /* Search the pattern for a forward reference */          /* Search the pattern for a forward reference */
5067    
5068          else if ((i = find_parens(cd, name, namelen,          else if ((i = find_parens(cd, name, namelen,
5069                          (options & PCRE_EXTENDED) != 0)) > 0)                          (options & PCRE_EXTENDED) != 0, utf8)) > 0)
5070            {            {
5071            PUT2(code, 2+LINK_SIZE, i);            PUT2(code, 2+LINK_SIZE, i);
5072            code[1+LINK_SIZE]++;            code[1+LINK_SIZE]++;
# Line 5382  for (;; ptr++) Line 5412  for (;; ptr++)
5412              }              }
5413            else if ((recno =                /* Forward back reference */            else if ((recno =                /* Forward back reference */
5414                      find_parens(cd, name, namelen,                      find_parens(cd, name, namelen,
5415                        (options & PCRE_EXTENDED) != 0)) <= 0)                        (options & PCRE_EXTENDED) != 0, utf8)) <= 0)
5416              {              {
5417              *errorcodeptr = ERR15;              *errorcodeptr = ERR15;
5418              goto FAILED;              goto FAILED;
# Line 5493  for (;; ptr++) Line 5523  for (;; ptr++)
5523              if (called == NULL)              if (called == NULL)
5524                {                {
5525                if (find_parens(cd, NULL, recno,                if (find_parens(cd, NULL, recno,
5526                      (options & PCRE_EXTENDED) != 0) < 0)                      (options & PCRE_EXTENDED) != 0, utf8) < 0)
5527                  {                  {
5528                  *errorcodeptr = ERR15;                  *errorcodeptr = ERR15;
5529                  goto FAILED;                  goto FAILED;

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

  ViewVC Help
Powered by ViewVC 1.1.5