Skip to content

Commit 9a7bb2f

Browse files
committed
PATCH: [perl 125825] {n}+ possessive quantifier broken
I was unaware of this construct when I wrote the commit that broke it, and there were no tests for it. Now there are.
1 parent e7bc593 commit 9a7bb2f

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

pod/perldelta.pod

+7
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,13 @@ files in F<ext/> and F<lib/> are best summarized in L</Modules and Pragmata>.
350350
C<qr/(?[ () ])/> no longer segfaults, giving a syntax error message instead.
351351
[perl #125805]
352352

353+
=item *
354+
355+
Regular expression possesive quantifier v5.20 regression now fixed.
356+
C<qr/>I<PAT>C<{>I<min>,I<max>C<}+>C</> is supposed to behave identically
357+
to C<qr/(?E<gt>>I<PAT>C<{>I<min>,I<max>C<})/>. Since v5.20, this didn't
358+
work if I<min> and I<max> were equal. [perl #125825]
359+
353360
=back
354361

355362
=head1 Known Problems

regcomp.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -10894,9 +10894,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
1089410894
ret = reg_node(pRExC_state, OPFAIL);
1089510895
return ret;
1089610896
}
10897-
else if (min == max
10898-
&& RExC_parse < RExC_end
10899-
&& (*RExC_parse == '?' || *RExC_parse == '+'))
10897+
else if (min == max && RExC_parse < RExC_end && *RExC_parse == '?')
1090010898
{
1090110899
if (PASS2) {
1090210900
ckWARN2reg(RExC_parse + 1,

t/re/re_tests

+2
Original file line numberDiff line numberDiff line change
@@ -1924,5 +1924,7 @@ A+(*PRUNE)BC(?{}) AAABC y $& AAABC
19241924
/w\zxy?\z/i \x{100}a\x{80}a n - -
19251925
/w\z\R\z/i \x{100}a\x{80}a n - -
19261926

1927+
/(a+){1}+a/ aaa n - - # [perl #125825]
1928+
19271929
# Keep these lines at the end of the file
19281930
# vim: softtabstop=0 noexpandtab

t/re/reg_mesg.t

-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@ my @warning = (
504504
'Useless (?c) - use /gc modifier {#} m/(?ogc{#})\x{100}/',
505505
],
506506
'/a{1,1}?\x{100}/' => 'Useless use of greediness modifier \'?\' {#} m/a{1,1}?{#}\x{100}/',
507-
'/b{3} +\x{100}/x' => 'Useless use of greediness modifier \'+\' {#} m/b{3} +{#}\x{100}/',
508507
"/(?[ [ % - % ] ])/" => "",
509508
"/(?[ [ : - \\x$colon_hex ] ])\\x{100}/" => "\": - \\x$colon_hex \" is more clearly written simply as \":\" {#} m/(?[ [ : - \\x$colon_hex {#}] ])\\x{100}/",
510509
"/(?[ [ \\x$colon_hex - : ] ])\\x{100}/" => "\"\\x$colon_hex\ - : \" is more clearly written simply as \":\" {#} m/(?[ [ \\x$colon_hex - : {#}] ])\\x{100}/",

0 commit comments

Comments
 (0)