fix paren unwinding with CURLYN, CURLYM
authorDavid Mitchell <davem@iabyn.com>
Sat, 16 Jun 2012 12:56:50 +0000 (13:56 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sat, 16 Jun 2012 13:09:41 +0000 (14:09 +0100)
commita8d1f4b493af3113b5d10ade9f824f102b7b040b
treee4b0b9b6fa861981feddc10051da177bef6d026e
parent4109bc0cd01be0ee6d8953b0e2c4f1638369a06e
fix paren unwinding with CURLYN, CURLYM

Historically, CURLYN and CURLYM didn't restore lastparen ($+) nor
invalidate higher numbered paren slots (reg->offs[n].end = -1)
when backtracking.

Recent commit f6033a9d6c91e0c29d5aa5049361a529b5d7cdc4 fixed the lastparen
issue, but then exposed the offs[n].end issue, which had previously been
masked by the too-high lastparen value causing a previous state (such as a
branch) to conveniently wipe out the offending parens on further
backtracking.

Or to put it another way, each backtracker should be expected to clean up
his own mess, not hope that someone previous to him will do it for him.

Fix this by doing the .end = 1 stuff on CURLYN,M failure as well as
BRANCH/TRIE. For consistency, define a new macro to do it.
regexec.c
t/re/re_tests