summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-07-05 23:59:46 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-07-06 06:47:24 -0700
commitf5df269c5cef57294662d0b1f80a468b91f13643 (patch)
tree6dbf19729739edad3d0ab6589920979cf0ec5685 /t
parent1500bd919ffeae0f3252f8d1bb28b03b043d328e (diff)
downloadperl-f5df269c5cef57294662d0b1f80a468b91f13643.tar.gz
[perl #117917] /(?{ m|...| }) (?{ $1 })/
A regular expression invoked inside a regular expression code block can cause other code blocks in the same outer regular expression to see the wrong values in $1. PL_curpm holds a pointer to the match operator from which $1, $2, etc. get their values. Normally PL_curpm is set at the end of a match. When code blocks are embedded inside a regular expression, PL_curpm is set during a match to point to PL_reg_curpm, which is a dummy op pointing to the current regular expression. S_setup_eval_state is called at the beginning of regexp execution. It is responsible for setting up PL_regcurpm and making PL_curpm point to it. Code blocks are executed using the multicall API. PUSH_MULTICALL records the value of PL_curpm and POP_MULTICALL makes sure that the previous value of PL_curpm is restored. Executing a code block can cause PL_curpm to point to something else. Since we don’t necessarily do POP_MULTICALL between code block calls within a single regular expression (sometimes we do, depending on backtracking), PL_curpm may not have been restored when a second code block fires. So we have to restore it to point to PL_reg_curpm manu- ally after calling a code block.
Diffstat (limited to 't')
-rw-r--r--t/re/re_tests2
1 files changed, 2 insertions, 0 deletions
diff --git a/t/re/re_tests b/t/re/re_tests
index 9a243601ed..3921bb7581 100644
--- a/t/re/re_tests
+++ b/t/re/re_tests
@@ -613,6 +613,8 @@ $(?<=^(a)) a y $1 a
^[^bcd]*(c+) aexycd y $1 c
(?{$a=2})a*aa(?{local$a=$a+1})k*c(?{$b=$a}) yaaxxaaaacd y $b 3
(?{$a=2})(a(?{local$a=$a+1}))*aak*c(?{$b=$a}) yaaxxaaaacd y $b 4
+# [perl #117917]
+^(a(?{ "x" =~ m{x}})b)(??{ $1 }) abab y $& abab
(>a+)ab aaab n - -
(?>a+)b aaab y - -
([[:]+) a:[b]: y $1 :[