develooper Front page | perl.perl5.porters | Postings from July 2018

Re: [perl #133352] Ancient Regex Regression

Thread Previous | Thread Next
From:
David Nicol
Date:
July 17, 2018 16:58
Subject:
Re: [perl #133352] Ancient Regex Regression
Message ID:
CAFwScO8Httr7MQgT9b+_Psj429S74ANbRcQv1fUhkqKUsnnnow@mail.gmail.com
This is a good test case for the bug:

On the other hand, my patch does allow this example to match:

     print "matched\n" if "ABCDA" =~ /^ (?: (.)B | CD )* \1 $/x;

Without my patch, this matches instead:

     print "matched\n" if "ABCDC" =~ /^ (?: (.)B | CD )* \1 $/x;



The bug appears to be the result of an optimization of describing the
capture buffer with an offset -- essentially a dynamic substring expression
-- rather than copying the captured string into it.
Were the capture buffer to be copied into, it would get 'A'  (the character
before the B) rather than 'C ' (the first character in the match) and the
behavior would be the same as what the other regex engines do.

Is that what the patch changes?



-- 
"At this point, given the limited available data, certainty about only a
very small number of things can be achieved." -- Plato, and others

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About