In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/c37d14f947f7998211b0455e453160fb7e15b22e?hp=1a2d1f10228c7338d13ca19cb6e492b159fa70f0>
- Log ----------------------------------------------------------------- commit c37d14f947f7998211b0455e453160fb7e15b22e Author: Karl Williamson <[email protected]> Date: Mon Jun 10 20:07:14 2013 -0600 Quantifier follows nothing in regex This changes the code so that any '?' immediately (subject to /x rules) following a {0} quantifier is absorbed immediately as part of that quantifier. This allows the optimization to NOTHING to work for non-greedy matches. Thanks to Yves Orton for doing most of the leg work on this ----------------------------------------------------------------------- Summary of changes: regcomp.c | 6 ++++++ t/re/re_tests | 4 ++++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/regcomp.c b/regcomp.c index a9eebd7..a837306 100644 --- a/regcomp.c +++ b/regcomp.c @@ -9699,6 +9699,12 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth) RExC_emit = orig_emit; } 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 == '?') { + nextchar(pRExC_state); + } return ret; } diff --git a/t/re/re_tests b/t/re/re_tests index a317904..ae28e14 100644 --- a/t/re/re_tests +++ b/t/re/re_tests @@ -1740,4 +1740,8 @@ m?^xy\?$? xy? y $& xy? # patterns ^(\x{100}|a)(??{ qr/.?\xF7/d}) a_\xF7 y - - +# [perl #118375] +/(a|(bc)){0,0}?xyz/ xyz y $& xyz +/( a | ( bc ) ) {0,0} ? xyz/x xyz y $& xyz + # vim: softtabstop=0 noexpandtab -- Perl5 Master Repository
