This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Some bugs in Perl regexp (core Perl issues)
authorhv@crypt.org <hv@crypt.org>
Thu, 2 Jul 2009 10:36:08 +0000 (11:36 +0100)
committerCraig A. Berry <craigberry@mac.com>
Thu, 2 Jul 2009 19:39:07 +0000 (14:39 -0500)
commit906cdd2b284d712169319a6934ba68b578748c8f
tree53c17ab5d3bb5c472180311ed0ce4955d14da33e
parent873f5ddf07b431a397f9ee90e6bd4c33b92f0c87
Some bugs in Perl regexp (core Perl issues)

"Hugo van der Sanden via RT" <perlbug-followup@perl.org> wrote:
:This is caused by a failure of the start_class optimization in the case
:of lookahead, as per the attached comment.
:
:In more detail: at the point study_chunk() attempts to deal with the
:start_class discovered for the lookahead chunk, we have
:SCF_DO_STCLASS_OR set, and_withp has the starting value of ANYOF_EOS |
:ANYOF_UNICODE_ALL, and data->start_class has [a] | ANYOF_EOS.
[...]
:In other words, we need to stack an alternation of ANDs and ORs to cope
:with this situation, and we don't have a mechanism to do that except to
:recurse into study_chunk() some more.
:
:A simpler short-term fix is instead to throw up our hands in this
:situation, and just nullify start_class. I'm not sure exactly how to do
:that, but it seems the more likely to be achievable for 5.10.1.

This patch implements the simple fix, and passes all tests including
Abigail's test cases for the bug.

Yves: note that I've preserved the 'was' code in this chunk, introduced
by you in the patch [1], discussed in the thread [2]. As far as I can
see the 3 lines propagating ANYOF_EOS via 'was' (and the copy of those
3 lines a little later) are simply doing the wrong thing - they seem
to be saying "when we combine two start classes using SCF_DO_STCLASS_AND,
claim that end-of-string is valid if the first class says it would be
even though the second says it wouldn't be". Removing those lines doesn't
cause any test failures - can you remember why you introduced those lines,
and maybe add a test case that fails without them?

Hugo

[1] http://perl5.git.perl.org/perl.git/commit/b515a41db88584b4fd1c30cf890c92d3f9697760
[2] http://groups.google.co.uk/group/perl.perl5.porters/browse_thread/thread/436187077ef96918/f11c3268394abf89

Message-Id: <200907021036.n62Aa8rv029500@zen.crypt.org>
rt.perl.org #56690
regcomp.c
t/op/re_tests