From: Dave Mitchell Date: Mon, 18 Jun 2007 15:10:32 +0000 (+0000) Subject: [perl #43159] 5.9.4 regexp capturing wrongly X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=60f65011b186cef6f05a7bafbf688a4b89780a87;p=p5sagit%2Fp5-mst-13.2.git [perl #43159] 5.9.4 regexp capturing wrongly change #28398 accidently made the last branch of an alternation not restore the paren state after failure backtrack. Fix this by removing the last-branch-skips-pushing-a-state optimisation. p4raw-link: @28398 on //depot/perl: 40a824489101168f94fce98aa2824baf40bad402 p4raw-id: //depot/perl@31417 --- diff --git a/regexec.c b/regexec.c index b05a177..a4c5aee 100644 --- a/regexec.c +++ b/regexec.c @@ -4219,12 +4219,6 @@ NULL case BRANCH: /* /(...|A|...)/ */ scan = NEXTOPER(scan); /* scan now points to inner node */ - if ((!next || (OP(next) != BRANCH && OP(next) != BRANCHJ)) - && !has_cutgroup) - { - /* last branch; skip state push and jump direct to node */ - continue; - } ST.lastparen = *PL_reglastparen; ST.next_branch = next; REGCP_SET(ST.cp); diff --git a/t/op/re_tests b/t/op/re_tests index 13f0693..f4dca6e 100644 --- a/t/op/re_tests +++ b/t/op/re_tests @@ -1327,3 +1327,4 @@ foo(\h)bar foo\tbar y $1 \t .*\z foo\n y - - ^(?:(\d)x)?\d$ 1 y ${\(defined($1)?1:0)} 0 +.*?(?:(\w)|(\w))x abx y $1-$2 b-