/[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 670 by ph10, Tue Aug 23 11:16:56 2011 UTC revision 702 by ph10, Tue Sep 20 15:45:06 2011 UTC
# Line 2295  I think. Line 2295  I think.
2295  A user pointed out that PCRE was rejecting [:a[:digit:]] whereas Perl was not.  A user pointed out that PCRE was rejecting [:a[:digit:]] whereas Perl was not.
2296  It seems that the appearance of a nested POSIX class supersedes an apparent  It seems that the appearance of a nested POSIX class supersedes an apparent
2297  external class. For example, [:a[:digit:]b:] matches "a", "b", ":", or  external class. For example, [:a[:digit:]b:] matches "a", "b", ":", or
2298  a digit.  a digit.
2299    
2300  In Perl, unescaped square brackets may also appear as part of class names. For  In Perl, unescaped square brackets may also appear as part of class names. For
2301  example, [:a[:abc]b:] gives unknown POSIX class "[:abc]b:]". However, for  example, [:a[:abc]b:] gives unknown POSIX class "[:abc]b:]". However, for
2302  [:a[:abc]b][b:] it gives unknown POSIX class "[:abc]b][b:]", which does not  [:a[:abc]b][b:] it gives unknown POSIX class "[:abc]b][b:]", which does not
2303  seem right at all. PCRE does not allow closing square brackets in POSIX class  seem right at all. PCRE does not allow closing square brackets in POSIX class
2304  names.  names.
2305    
2306  Arguments:  Arguments:
# Line 2319  for (++ptr; *ptr != 0; ptr++) Line 2319  for (++ptr; *ptr != 0; ptr++)
2319    {    {
2320    if (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)    if (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
2321      ptr++;      ptr++;
2322    else if (*ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;    else if (*ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;
2323    else    else
2324      {      {
2325      if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)      if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
# Line 5045  for (;; ptr++) Line 5045  for (;; ptr++)
5045                PUT2INC(code, 0, oc->number);                PUT2INC(code, 0, oc->number);
5046                }                }
5047              *code++ = (cd->assert_depth > 0)? OP_ASSERT_ACCEPT : OP_ACCEPT;              *code++ = (cd->assert_depth > 0)? OP_ASSERT_ACCEPT : OP_ACCEPT;
5048    
5049                /* Do not set firstbyte after *ACCEPT */
5050                if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;
5051              }              }
5052    
5053            /* Handle other cases with/without an argument */            /* Handle other cases with/without an argument */
# Line 5061  for (;; ptr++) Line 5064  for (;; ptr++)
5064                {                {
5065                PUT(code, 0, code - bcptr->current_branch - 1);                PUT(code, 0, code - bcptr->current_branch - 1);
5066                code += LINK_SIZE;                code += LINK_SIZE;
5067                  cd->external_flags |= PCRE_HASTHEN;
5068                }                }
5069              }              }
5070    
# Line 6323  for (;; ptr++) Line 6327  for (;; ptr++)
6327      byte, set it from this character, but revert to none on a zero repeat.      byte, set it from this character, but revert to none on a zero repeat.
6328      Otherwise, leave the firstbyte value alone, and don't change it on a zero      Otherwise, leave the firstbyte value alone, and don't change it on a zero
6329      repeat. */      repeat. */
6330    
6331      if (firstbyte == REQ_UNSET)      if (firstbyte == REQ_UNSET)
6332        {        {
6333        zerofirstbyte = REQ_NONE;        zerofirstbyte = REQ_NONE;
# Line 6340  for (;; ptr++) Line 6344  for (;; ptr++)
6344        else firstbyte = reqbyte = REQ_NONE;        else firstbyte = reqbyte = REQ_NONE;
6345        }        }
6346    
6347      /* firstbyte was previously set; we can set reqbyte only the length is      /* firstbyte was previously set; we can set reqbyte only if the length is
6348      1 or the matching is caseful. */      1 or the matching is caseful. */
6349    
6350      else      else
# Line 7287  re->top_bracket = cd->bracount; Line 7291  re->top_bracket = cd->bracount;
7291  re->top_backref = cd->top_backref;  re->top_backref = cd->top_backref;
7292  re->flags = cd->external_flags;  re->flags = cd->external_flags;
7293    
7294  if (cd->had_accept) reqbyte = -1;   /* Must disable after (*ACCEPT) */  if (cd->had_accept) reqbyte = REQ_NONE;   /* Must disable after (*ACCEPT) */
7295    
7296  /* If not reached end of pattern on success, there's an excess bracket. */  /* If not reached end of pattern on success, there's an excess bracket. */
7297    

Legend:
Removed from v.670  
changed lines
  Added in v.702

  ViewVC Help
Powered by ViewVC 1.1.5