This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PATCH: [perl 125825] {n}+ possessive quantifier broken
authorKarl Williamson <khw@cpan.org>
Mon, 24 Aug 2015 18:50:47 +0000 (12:50 -0600)
committerKarl Williamson <khw@cpan.org>
Mon, 24 Aug 2015 19:43:29 +0000 (13:43 -0600)
I was unaware of this construct when I wrote the commit that broke it,
and there were no tests for it.  Now there are.

pod/perldelta.pod
regcomp.c
t/re/re_tests
t/re/reg_mesg.t

index 9f66925..c91c981 100644 (file)
@@ -350,6 +350,13 @@ files in F<ext/> and F<lib/> are best summarized in L</Modules and Pragmata>.
 C<qr/(?[ () ])/> no longer segfaults, giving a syntax error message instead.
 [perl #125805]
 
+=item *
+
+Regular expression possesive quantifier v5.20 regression now fixed.
+C<qr/>I<PAT>C<{>I<min>,I<max>C<}+>C</> is supposed to behave identically
+to C<qr/(?E<gt>>I<PAT>C<{>I<min>,I<max>C<})/>.  Since v5.20, this didn't
+work if I<min> and I<max> were equal.  [perl #125825]
+
 =back
 
 =head1 Known Problems
index 91e1603..982fdd1 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -10894,9 +10894,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
                 ret = reg_node(pRExC_state, OPFAIL);
                 return ret;
             }
-            else if (min == max
-                     && RExC_parse < RExC_end
-                     && (*RExC_parse == '?' || *RExC_parse == '+'))
+            else if (min == max && RExC_parse < RExC_end && *RExC_parse == '?')
             {
                 if (PASS2) {
                     ckWARN2reg(RExC_parse + 1,
index 6674a2a..9d5fa73 100644 (file)
@@ -1924,5 +1924,7 @@ A+(*PRUNE)BC(?{}) AAABC   y       $&      AAABC
 /w\zxy?\z/i    \x{100}a\x{80}a n       -       -
 /w\z\R\z/i     \x{100}a\x{80}a n       -       -
 
+/(a+){1}+a/    aaa     n       -       -               # [perl #125825]
+
 # Keep these lines at the end of the file
 # vim: softtabstop=0 noexpandtab
index d9d9d74..dd82949 100644 (file)
@@ -504,7 +504,6 @@ my @warning = (
                     'Useless (?c) - use /gc modifier {#} m/(?ogc{#})\x{100}/',
                   ],
     '/a{1,1}?\x{100}/' => 'Useless use of greediness modifier \'?\' {#} m/a{1,1}?{#}\x{100}/',
-    '/b{3}  +\x{100}/x' => 'Useless use of greediness modifier \'+\' {#} m/b{3}  +{#}\x{100}/',
     "/(?[ [ % - % ] ])/" => "",
     "/(?[ [ : - \\x$colon_hex ] ])\\x{100}/" => "\": - \\x$colon_hex \" is more clearly written simply as \":\" {#} m/(?[ [ : - \\x$colon_hex {#}] ])\\x{100}/",
     "/(?[ [ \\x$colon_hex - : ] ])\\x{100}/" => "\"\\x$colon_hex\ - : \" is more clearly written simply as \":\" {#} m/(?[ [ \\x$colon_hex - : {#}] ])\\x{100}/",