/[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 1060 by chpe, Tue Oct 16 15:53:57 2012 UTC revision 1061 by chpe, Tue Oct 16 15:54:02 2012 UTC
# Line 750  return (*p == CHAR_RIGHT_CURLY_BRACKET); Line 750  return (*p == CHAR_RIGHT_CURLY_BRACKET);
750    
751  /* This function is called when a \ has been encountered. It either returns a  /* This function is called when a \ has been encountered. It either returns a
752  positive value for a simple escape such as \n, or 0 for a data character  positive value for a simple escape such as \n, or 0 for a data character
753  which will be placed in chptr. A backreference to group  which will be placed in chptr. A backreference to group n is returned as
754  n is returned as ESC_REF + n; ESC_REF is the highest ESC_xxx macro. When  negative n. When UTF-8 is enabled, a positive value greater than 255 may
755  UTF-8 is enabled, a positive value greater than 255 may be returned in chptr.  be returned in chptr.
756  On entry,ptr is pointing at the \. On exit, it is on the final character of the  On entry,ptr is pointing at the \. On exit, it is on the final character of the
757  escape sequence.  escape sequence.
758    
# Line 766  Arguments: Line 766  Arguments:
766    
767  Returns:         zero => a data character  Returns:         zero => a data character
768                   positive => a special escape sequence                   positive => a special escape sequence
769                     negative => a back reference
770                   on error, errorcodeptr is set                   on error, errorcodeptr is set
771  */  */
772    
# Line 954  else Line 955  else
955        c = bracount - (c - 1);        c = bracount - (c - 1);
956        }        }
957    
958      escape = ESC_REF + c;      escape = -c;
959      break;      break;
960    
961      /* The handling of escape sequences consisting of a string of digits      /* The handling of escape sequences consisting of a string of digits
# Line 995  else Line 996  else
996          }          }
997        if (c < 10 || c <= bracount)        if (c < 10 || c <= bracount)
998          {          {
999          escape = ESC_REF + c;          escape = -c;
1000          break;          break;
1001          }          }
1002        ptr = oldptr;      /* Put the pointer back and fall through */        ptr = oldptr;      /* Put the pointer back and fall through */
# Line 4459  for (;; ptr++) Line 4460  for (;; ptr++)
4460    
4461            /* \b is backspace; any other special means the '-' was literal. */            /* \b is backspace; any other special means the '-' was literal. */
4462    
4463            if (descape > 0)            if (descape != 0)
4464              {              {
4465              if (descape == ESC_b) d = CHAR_BS; else              if (descape == ESC_b) d = CHAR_BS; else
4466                {                {
# Line 6673  for (;; ptr++) Line 6674  for (;; ptr++)
6674      /* Handle metasequences introduced by \. For ones like \d, the ESC_ values      /* Handle metasequences introduced by \. For ones like \d, the ESC_ values
6675      are arranged to be the negation of the corresponding OP_values in the      are arranged to be the negation of the corresponding OP_values in the
6676      default case when PCRE_UCP is not set. For the back references, the values      default case when PCRE_UCP is not set. For the back references, the values
6677      are ESC_REF plus the reference number. Only back references and those types      are negative the reference number. Only back references and those types
6678      that consume a character may be repeated. We can test for values between      that consume a character may be repeated. We can test for values between
6679      ESC_b and ESC_Z for the latter; this may have to change if any new ones are      ESC_b and ESC_Z for the latter; this may have to change if any new ones are
6680      ever created. */      ever created. */
# Line 6713  for (;; ptr++) Line 6714  for (;; ptr++)
6714        is a subroutine call by number (Oniguruma syntax). In fact, the value        is a subroutine call by number (Oniguruma syntax). In fact, the value
6715        ESC_g is returned only for these cases. So we don't need to check for <        ESC_g is returned only for these cases. So we don't need to check for <
6716        or ' if the value is ESC_g. For the Perl syntax \g{n} the value is        or ' if the value is ESC_g. For the Perl syntax \g{n} the value is
6717        ESC_REF+n, and for the Perl syntax \g{name} the result is ESC_k (as        -n, and for the Perl syntax \g{name} the result is ESC_k (as
6718        that is a synonym for a named back reference). */        that is a synonym for a named back reference). */
6719    
6720        if (escape == ESC_g)        if (escape == ESC_g)
# Line 6791  for (;; ptr++) Line 6792  for (;; ptr++)
6792        not set to cope with cases like (?=(\w+))\1: which would otherwise set        not set to cope with cases like (?=(\w+))\1: which would otherwise set
6793        ':' later. */        ':' later. */
6794    
6795        if (escape >= ESC_REF)        if (escape < 0)
6796          {          {
6797          open_capitem *oc;          open_capitem *oc;
6798          recno = escape - ESC_REF;          recno = -escape;
6799    
6800          HANDLE_REFERENCE:    /* Come here from named backref handling */          HANDLE_REFERENCE:    /* Come here from named backref handling */
6801          if (firstchar == REQ_UNSET) firstchar = REQ_NONE;          if (firstchar == REQ_UNSET) firstchar = REQ_NONE;

Legend:
Removed from v.1060  
changed lines
  Added in v.1061

  ViewVC Help
Powered by ViewVC 1.1.5