In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/17e8b60cd2a564ab6f4bed82ccda0c92a424ae9f?hp=f603091d864eb38dabe995c559f17edd4ea9e2d6>

- Log -----------------------------------------------------------------
commit 17e8b60cd2a564ab6f4bed82ccda0c92a424ae9f
Author: Father Chrysostomos <[email protected]>
Date:   Tue Nov 30 05:01:25 2010 -0800

    Use ' to avoid interpolation

M       t/op/attrs.t

commit 779bcb7d68c0d77839c133a5b8429f43e63a961f
Author: Nick Cleaton <[email protected]>
Date:   Mon Nov 29 22:26:43 2010 -0800

    [perl #79152] super-linear cache can prevent a valid match
    
    The super-linear cache in regexec.c can prevent a valid match
    from being detected. For example:
    
    print "yay\n" if 'xayxay' =~ /(q1|.)*(q2|.)*(x(a|bc)*y){2,}/;
    
    This should match, but it doesn't because the cache fails to
    distinguish between matching the final xay to x(a|bc)*y as the
    first instance of the {2,} and matching it in the same position
    as the second instance.
    
    This seems to do the trick.

M       regcomp.c
M       t/re/re_tests
-----------------------------------------------------------------------

Summary of changes:
 regcomp.c     |   17 ++++++++++-------
 t/op/attrs.t  |    2 +-
 t/re/re_tests |    5 +++++
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/regcomp.c b/regcomp.c
index 4092d79..4b69bf7 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -3246,13 +3246,16 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode 
**scanp,
                    f |= SCF_DO_STCLASS_AND;
                    f &= ~SCF_DO_STCLASS_OR;
                }
-               /* These are the cases when once a subexpression
-                  fails at a particular position, it cannot succeed
-                  even after backtracking at the enclosing scope.
-
-                  XXXX what if minimal match and we are at the
-                       initial run of {n,m}? */
-               if ((mincount != maxcount - 1) && (maxcount != REG_INFTY))
+               /* Exclude from super-linear cache processing any {n,m}
+                  regops for which the combination of input pos and regex
+                  pos is not enough information to determine if a match
+                  will be possible.
+
+                  For example, in the regex /foo(bar\s*){4,8}baz/ with the
+                  regex pos at the \s*, the prospects for a match depend not
+                  only on the input position but also on how many (bar\s*)
+                  repeats into the {4,8} we are. */
+               if ((mincount > 1) || (maxcount > 1 && maxcount != REG_INFTY))
                    f &= ~SCF_WHILEM_VISITED_POS;
 
                /* This will finish on WHILEM, setting scan, or on NULL: */
diff --git a/t/op/attrs.t b/t/op/attrs.t
index b7809a8..fe77043 100644
--- a/t/op/attrs.t
+++ b/t/op/attrs.t
@@ -310,7 +310,7 @@ foreach my $test (@tests) {
      "Calling closure proto with (no) args";
   eval { () = &$proto };             # used to crash in pp_leavesub
   like $@, qr/^Closure prototype called/,
-     "Calling closure proto with no @_ that returns a lexical";
+     'Calling closure proto with no @_ that returns a lexical';
 }
 
 done_testing();
diff --git a/t/re/re_tests b/t/re/re_tests
index 66a47cc..02da1e1 100644
--- a/t/re/re_tests
+++ b/t/re/re_tests
@@ -1482,5 +1482,10 @@ abc\N{def        -       c       -       \\N{NAME} must 
be resolved by the lexer
 [\0005]        5\000   y       $&      5
 [\_]   _       y       $&      _
 
+# RT #79152
+(q1|.)*(q2|.)*(x(a|bc)*y){2,}  xayxay  y       $&      xayxay
+(q1|.)*(q2|.)*(x(a|bc)*y){2,3} xayxay  y       $&      xayxay
+(q1|z)*(q2|z)*z{15}-.*?(x(a|bc)*y){2,3}Z       zzzzzzzzzzzzzzzz-xayxayxayxayZ  
y       $&      zzzzzzzzzzzzzzzz-xayxayxayxayZ
+
 (?:(?:)foo|bar|zot|rt78356)    foo     y       $&      foo
 # vim: softtabstop=0 noexpandtab

--
Perl5 Master Repository

Reply via email to