This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #117917] /(?{ m|...| }) (?{ $1 })/
authorFather Chrysostomos <sprout@cpan.org>
Sat, 6 Jul 2013 06:59:46 +0000 (23:59 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 6 Jul 2013 13:47:24 +0000 (06:47 -0700)
commitf5df269c5cef57294662d0b1f80a468b91f13643
tree6dbf19729739edad3d0ab6589920979cf0ec5685
parent1500bd919ffeae0f3252f8d1bb28b03b043d328e
[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.
regexec.c
t/re/re_tests