summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2008-12-27 20:19:31 +0100
committerYves Orton <demerphq@gmail.com>2008-12-27 20:19:31 +0100
commit6962fb1a1ff5ac2ee529f793d9ff033a7525ff4d (patch)
treee14d65ec1639cb2896e436ce0fd1a363cf4c1912
parentb7e5ec797d6492ead4bf7f40925d2bf6a2f5b0df (diff)
downloadperl-6962fb1a1ff5ac2ee529f793d9ff033a7525ff4d.tar.gz
fix bug #57042 - preserve $^R across TRIE matches
-rw-r--r--regexec.c5
-rwxr-xr-xt/op/pat.t22
2 files changed, 23 insertions, 4 deletions
diff --git a/regexec.c b/regexec.c
index 6c0923fc8b..f959121b81 100644
--- a/regexec.c
+++ b/regexec.c
@@ -3003,7 +3003,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
if ( got_wordnum ) {
if ( ! ST.accepted ) {
ENTER;
- /* SAVETMPS; */ /* XXX is this necessary? dmq */
+ SAVETMPS; /* XXX is this necessary? dmq */
bufflen = TRIE_INITAL_ACCEPT_BUFFLEN;
sv_accept_buff=newSV(bufflen *
sizeof(reg_trie_accepted) - 1);
@@ -3222,6 +3222,9 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
}
/* NOTREACHED */
case TRIE_next:
+ /* we dont want to throw this away, see bug 57042*/
+ if (oreplsv != GvSV(PL_replgv))
+ sv_setsv(oreplsv, GvSV(PL_replgv));
FREETMPS;
LEAVE;
sayYES;
diff --git a/t/op/pat.t b/t/op/pat.t
index 040c67150f..aa275bd4f4 100755
--- a/t/op/pat.t
+++ b/t/op/pat.t
@@ -13,7 +13,7 @@ sub run_tests;
$| = 1;
-my $EXPECTED_TESTS = 3864; # Update this when adding/deleting tests.
+my $EXPECTED_TESTS = 3865; # Update this when adding/deleting tests.
BEGIN {
chdir 't' if -d 't';
@@ -2935,7 +2935,7 @@ sub run_tests {
SKIP: {
our @stack = ();
- my @expect = qw (
+ my @expect = qw(
stuff1
stuff2
<stuff1>and<stuff2>
@@ -4083,7 +4083,23 @@ sub run_tests {
utf8::upgrade $s;
ok "aaa" =~ /$s/;
}
-
+ {
+ local $BugId = '57042';
+ local $Message = "Check if tree logic breaks \$^R";
+ my $cond_re = qr/\s*
+ \s* (?:
+ \( \s* A (?{1})
+ | \( \s* B (?{2})
+ )
+ /x;
+ my @res;
+ for my $line ("(A)","(B)") {
+ if ($line =~ m/$cond_re/) {
+ push @res, $^R ? "#$^R" : "UNDEF";
+ }
+ }
+ iseq "@res","#1 #2";
+ }
#
# This should be the last test.
#