In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/84d2fa142c064fe21af5121174d51b764b9d9c69?hp=b074547015307bfbdc79cc38e4fa950923593d93>
- Log ----------------------------------------------------------------- commit 84d2fa142c064fe21af5121174d51b764b9d9c69 Author: [email protected] <[email protected]> Date: Mon Jul 6 15:45:12 2009 +0100 Regex fails when string is too long This looks to be a simple oversight. All tests pass here. Hugo Signed-off-by: H.Merijn Brand <[email protected]> ----------------------------------------------------------------------- Summary of changes: regexec.c | 5 +++-- t/op/pat.t | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/regexec.c b/regexec.c index 93fadab..f3c9540 100644 --- a/regexec.c +++ b/regexec.c @@ -4411,7 +4411,7 @@ NULL case CURLYM: /* /A{m,n}B/ where A is fixed-length */ /* This is an optimisation of CURLYX that enables us to push - * only a single backtracking state, no matter now many matches + * only a single backtracking state, no matter how many matches * there are in {m,n}. It relies on the pattern being constant * length, with no parens to influence future backrefs */ @@ -4574,7 +4574,8 @@ NULL case CURLYM_B_fail: /* just failed to match a B */ REGCP_UNWIND(ST.cp); if (ST.minmod) { - if (ST.count == ARG2(ST.me) /* max */) + I32 max = ARG2(ST.me); + if (max != REG_INFTY && ST.count == max) sayNO; goto curlym_do_A; /* try to match a further A */ } diff --git a/t/op/pat.t b/t/op/pat.t index 62ca4b2..aa6299f 100644 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -13,7 +13,7 @@ sub run_tests; $| = 1; -my $EXPECTED_TESTS = 4061; # Update this when adding/deleting tests. +my $EXPECTED_TESTS = 4065; # Update this when adding/deleting tests. BEGIN { chdir 't' if -d 't'; @@ -4346,6 +4346,21 @@ sub run_tests { iseq($str, "\$1 = undef, \$2 = undef, \$3 = undef, \$4 = undef, \$5 = undef, \$^R = undef"); } } + + { + local $BugId = 65372; # minimal CURLYM limited to 32767 matches + my @pat = ( + qr{a(x|y)*b}, # CURLYM + qr{a(x|y)*?b}, # .. with minmod + qr{a([wx]|[yz])*b}, # .. and without tries + qr{a([wx]|[yz])*?b}, + ); + my $len = 32768; + my $s = join '', 'a', 'x' x $len, 'b'; + for my $pat (@pat) { + ok($s =~ $pat, $pat); + } + } # # This should be the last test. # -- Perl5 Master Repository
