In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/b75763d608047188e76fcf5249a427b3ad13e87a?hp=d7bfa5540b75a5472143ac2ff07153f261b4b075>
- Log ----------------------------------------------------------------- commit b75763d608047188e76fcf5249a427b3ad13e87a Author: Yves Orton <[email protected]> Date: Wed Jun 12 21:03:50 2013 +0200 do not warn when optimizing away /x{0,0}?+/ and /x{0,0}+/ In c37d14f947f7998211b0455e453160fb7e15b22e Karl fixed an issue reported in [perl #118375] "5.18 regex regression Quantifier follows nothing in regex" but he fixed only the non-greedy modifier mentioned in the ticket, and did not include support for the other quantifier modifiers like the non-greedy possessive (stupid but not illegal), and the possessive (useful) modifiers. Hopefully this covers them all. Note that because Karl already included support for m/x {0,0} ?/x I have done so as well for the new cases. I do not necessarily endorse the idea that it is legal or should be tested for. I am inclined to think that '{0,0}?+' should be indivisible even under /x. ----------------------------------------------------------------------- Summary of changes: regcomp.c | 13 ++++++++++--- t/re/re_tests | 6 ++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/regcomp.c b/regcomp.c index a837306..3426112 100644 --- a/regcomp.c +++ b/regcomp.c @@ -9700,9 +9700,16 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth) } ret = reg_node(pRExC_state, NOTHING); - /* But the quantifier includes any '?' (the non-greedy - * modifier) after the {}, [perl #118375] */ - if (RExC_parse < RExC_end && *RExC_parse == '?') { + /* But the quantifier includes any '?', the non-greedy + * modifier, after the {}, [perl #118375] + * Likewise the '+', the possessive modifier, and + * they can be combined too, '?+' is the possessive + * non-greedy modifier. + */ + if (RExC_parse < RExC_end && *RExC_parse == '?' ) { + nextchar(pRExC_state); + } + if (RExC_parse < RExC_end && *RExC_parse == '+' ) { nextchar(pRExC_state); } return ret; diff --git a/t/re/re_tests b/t/re/re_tests index ae28e14..45018df 100644 --- a/t/re/re_tests +++ b/t/re/re_tests @@ -1744,4 +1744,10 @@ m?^xy\?$? xy? y $& xy? /(a|(bc)){0,0}?xyz/ xyz y $& xyz /( a | ( bc ) ) {0,0} ? xyz/x xyz y $& xyz +/(a|(bc)){0,0}+xyz/ xyz y $& xyz +/( a | ( bc ) ) {0,0} + xyz/x xyz y $& xyz + +/(a|(bc)){0,0}?xyz/ xyz y $& xyz +/( a | ( bc ) ) {0,0} ? + xyz/x xyz y $& xyz + # vim: softtabstop=0 noexpandtab -- Perl5 Master Repository
