/[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 1392 by ph10, Wed Nov 6 18:00:09 2013 UTC revision 1393 by ph10, Fri Nov 8 16:37:21 2013 UTC
# Line 5737  for (;; ptr++) Line 5737  for (;; ptr++)
5737      opcodes such as BRA and CBRA, as this is the place where they get converted      opcodes such as BRA and CBRA, as this is the place where they get converted
5738      into the more special varieties such as BRAPOS and SBRA. A test for >=      into the more special varieties such as BRAPOS and SBRA. A test for >=
5739      OP_ASSERT and <= OP_COND includes ASSERT, ASSERT_NOT, ASSERTBACK,      OP_ASSERT and <= OP_COND includes ASSERT, ASSERT_NOT, ASSERTBACK,
5740      ASSERTBACK_NOT, ONCE, BRA, CBRA, and COND. Originally, PCRE did not allow      ASSERTBACK_NOT, ONCE, ONCE_NC, BRA, BRAPOS, CBRA, CBRAPOS, and COND.
5741      repetition of assertions, but now it does, for Perl compatibility. */      Originally, PCRE did not allow repetition of assertions, but now it does,
5742        for Perl compatibility. */
5743    
5744      else if (*previous >= OP_ASSERT && *previous <= OP_COND)      else if (*previous >= OP_ASSERT && *previous <= OP_COND)
5745        {        {
# Line 5756  for (;; ptr++) Line 5757  for (;; ptr++)
5757        /* There is no sense in actually repeating assertions. The only potential        /* There is no sense in actually repeating assertions. The only potential
5758        use of repetition is in cases when the assertion is optional. Therefore,        use of repetition is in cases when the assertion is optional. Therefore,
5759        if the minimum is greater than zero, just ignore the repeat. If the        if the minimum is greater than zero, just ignore the repeat. If the
5760        maximum is not not zero or one, set it to 1. */        maximum is not zero or one, set it to 1. */
5761    
5762        if (*previous < OP_ONCE)    /* Assertion */        if (*previous < OP_ONCE)    /* Assertion */
5763          {          {
# Line 6703  for (;; ptr++) Line 6704  for (;; ptr++)
6704          ptr++;          ptr++;
6705          break;          break;
6706    
6707            /* Optimize (?!) to (*FAIL) unless it is quantified - which is a weird
6708            thing to do, but Perl allows all assertions to be quantified, and when
6709            they contain capturing parentheses there may be a potential use for
6710            this feature. Not that that applies to a quantified (?!) but we allow
6711            it for uniformity. */
6712    
6713          /* ------------------------------------------------------------ */          /* ------------------------------------------------------------ */
6714          case CHAR_EXCLAMATION_MARK:            /* Negative lookahead */          case CHAR_EXCLAMATION_MARK:            /* Negative lookahead */
6715          ptr++;          ptr++;
6716          if (*ptr == CHAR_RIGHT_PARENTHESIS)    /* Optimize (?!) */          if (*ptr == CHAR_RIGHT_PARENTHESIS && ptr[1] != CHAR_ASTERISK &&
6717                 ptr[1] != CHAR_PLUS && ptr[1] != CHAR_QUESTION_MARK &&
6718                (ptr[1] != CHAR_LEFT_CURLY_BRACKET || !is_counted_repeat(ptr+2)))
6719            {            {
6720            *code++ = OP_FAIL;            *code++ = OP_FAIL;
6721            previous = NULL;            previous = NULL;

Legend:
Removed from v.1392  
changed lines
  Added in v.1393

  ViewVC Help
Powered by ViewVC 1.1.5