/[pcre]/code/branches/pcre16/pcre_compile.c
ViewVC logotype

Diff of /code/branches/pcre16/pcre_compile.c

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

revision 635 by ph10, Sat Jul 23 16:19:50 2011 UTC revision 637 by ph10, Sun Jul 24 17:44:12 2011 UTC
# Line 393  static const char error_texts[] = Line 393  static const char error_texts[] =
393    "internal error: previously-checked referenced subpattern not found\0"    "internal error: previously-checked referenced subpattern not found\0"
394    "DEFINE group contains more than one branch\0"    "DEFINE group contains more than one branch\0"
395    /* 55 */    /* 55 */
396    "repeating a DEFINE group is not allowed\0"    "repeating a DEFINE group is not allowed\0"  /** DEAD **/
397    "inconsistent NEWLINE options\0"    "inconsistent NEWLINE options\0"
398    "\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number\0"    "\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number\0"
399    "a numbered reference must not be zero\0"    "a numbered reference must not be zero\0"
# Line 4210  for (;; ptr++) Line 4210  for (;; ptr++)
4210      op_type = 0;                    /* Default single-char op codes */      op_type = 0;                    /* Default single-char op codes */
4211      possessive_quantifier = FALSE;  /* Default not possessive quantifier */      possessive_quantifier = FALSE;  /* Default not possessive quantifier */
4212    
4213      /* Save start of previous item, in case we have to move it up to make space      /* Save start of previous item, in case we have to move it up in order to
4214      for an inserted OP_ONCE for the additional '+' extension. */      insert something before it. */
4215    
4216      tempcode = previous;      tempcode = previous;
4217    
# Line 4554  for (;; ptr++) Line 4554  for (;; ptr++)
4554        }        }
4555    
4556      /* If previous was a bracket group, we may have to replicate it in certain      /* If previous was a bracket group, we may have to replicate it in certain
4557      cases. Note that at this point we can encounter only the "basic" BRA and      cases. Note that at this point we can encounter only the "basic" bracket
4558      KET opcodes, as this is the place where they get converted into the more      opcodes such as BRA and CBRA, as this is the place where they get converted
4559      special varieties. */      into the more special varieties such as BRAPOS and SBRA. A test for >=
4560        OP_ASSERT and <= OP_COND includes ASSERT, ASSERT_NOT, ASSERTBACK,
4561        ASSERTBACK_NOT, ONCE, BRA, CBRA, and COND. Originally, PCRE did not allow
4562        repetition of assertions, but now it does, for Perl compatibility. */
4563    
4564      else if (*previous == OP_BRA  || *previous == OP_CBRA ||      else if (*previous >= OP_ASSERT && *previous <= OP_COND)
              *previous == OP_ONCE || *previous == OP_COND)  
4565        {        {
4566        register int i;        register int i;
4567        int len = (int)(code - previous);        int len = (int)(code - previous);
4568        uschar *bralink = NULL;        uschar *bralink = NULL;
4569        uschar *brazeroptr = NULL;        uschar *brazeroptr = NULL;
4570    
4571        /* Repeating a DEFINE group is pointless */        /* Repeating a DEFINE group is pointless, but Perl allows the syntax, so
4572          we just ignore the repeat. */
4573    
4574        if (*previous == OP_COND && previous[LINK_SIZE+1] == OP_DEF)        if (*previous == OP_COND && previous[LINK_SIZE+1] == OP_DEF)
4575          {          goto END_REPEAT;
4576          *errorcodeptr = ERR55;  
4577          goto FAILED;        /* There is no sense in actually repeating assertions. The only potential
4578          }        use of repetition is in cases when the assertion is optional. Therefore,
4579          if the minimum is greater than zero, just ignore the repeat. If the
4580          maximum is not not zero or one, set it to 1. */
4581    
4582          if (*previous < OP_ONCE)    /* Assertion */
4583            {
4584            if (repeat_min > 0) goto END_REPEAT;
4585            if (repeat_max < 0 || repeat_max > 1) repeat_max = 1;
4586            }
4587    
4588        /* The case of a zero minimum is special because of the need to stick        /* The case of a zero minimum is special because of the need to stick
4589        OP_BRAZERO in front of it, and because the group appears once in the        OP_BRAZERO in front of it, and because the group appears once in the
# Line 4592  for (;; ptr++) Line 4603  for (;; ptr++)
4603          **   goto END_REPEAT;          **   goto END_REPEAT;
4604          **   }          **   }
4605    
4606          However, that fails when a group is referenced as a subroutine from          However, that fails when a group or a subgroup within it is referenced
4607          elsewhere in the pattern, so now we stick in OP_SKIPZERO in front of it          as a subroutine from elsewhere in the pattern, so now we stick in
4608          so that it is skipped on execution. As we don't have a list of which          OP_SKIPZERO in front of it so that it is skipped on execution. As we
4609          groups are referenced, we cannot do this selectively.          don't have a list of which groups are referenced, we cannot do this
4610            selectively.
4611    
4612          If the maximum is 1 or unlimited, we just have to stick in the BRAZERO          If the maximum is 1 or unlimited, we just have to stick in the BRAZERO
4613          and do no more at this point. However, we do need to adjust any          and do no more at this point. However, we do need to adjust any
# Line 5860  for (;; ptr++) Line 5872  for (;; ptr++)
5872        skipbytes = 2;        skipbytes = 2;
5873        }        }
5874    
5875      /* Process nested bracketed regex. Assertions may not be repeated, but      /* Process nested bracketed regex. Assertions used not to be repeatable,
5876      other kinds can be. All their opcodes are >= OP_ONCE. We copy code into a      but this was changed for Perl compatibility, so all kinds can now be
5877      non-register variable (tempcode) in order to be able to pass its address      repeated. We copy code into a non-register variable (tempcode) in order to
5878      because some compilers complain otherwise. */      be able to pass its address because some compilers complain otherwise. */
5879    
5880      previous = (bravalue >= OP_ONCE)? code : NULL;      previous = code;                   /* For handling repetition */
5881      *code = bravalue;      *code = bravalue;
5882      tempcode = code;      tempcode = code;
5883      tempreqvary = cd->req_varyopt;     /* Save value before bracket */      tempreqvary = cd->req_varyopt;     /* Save value before bracket */

Legend:
Removed from v.635  
changed lines
  Added in v.637

  ViewVC Help
Powered by ViewVC 1.1.5