diff options
author | Yves Orton <demerphq@gmail.com> | 2022-03-30 09:59:47 +0200 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2022-04-08 12:29:21 +0800 |
commit | df12890b5e8c018402acec9b116df5182514fae1 (patch) | |
tree | 04412b033fdb9a1c363798494af120612c0c8c69 /regcomp.c | |
parent | 8ec963d3eca5bc665f5b8d734b102c6a773bc02a (diff) | |
download | perl-df12890b5e8c018402acec9b116df5182514fae1.tar.gz |
regcomp.c: fix substring optimizer for ACCEPT inside of CURLY
ACCEPT essentially overrides quantifiers larger than 1. Eg,
/(A){2}/ has a mincount of 2 and a maxcount of 2, and a minlen
of 2 for "AA". But /(A(*ACCEPT)){2}/ should actually have a
mincount of 1, and a minlen of 1 as it can match 'A'. In the regex
engine proper this doesn't matter, we just do the right thing. But
in the optimizer it matters. This patch sets the mincount to 1 in
such cases whenever the contents contains an ACCEPT.
Thanks for Hugo for asking the questions that lead to this patch.
Diffstat (limited to 'regcomp.c')
-rw-r--r-- | regcomp.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -5681,6 +5681,11 @@ S_study_chunk(pTHX_ : f) , depth+1, mutate_ok); + if (data && data->flags & SCF_SEEN_ACCEPT) { + if (mincount > 1) + mincount = 1; + } + if (flags & SCF_DO_STCLASS) data->start_class = oclass; if (mincount == 0 || minnext == 0) { |