summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Ragwitz <rafl@debian.org>2010-09-30 01:45:16 +0200
committerFlorian Ragwitz <rafl@debian.org>2010-09-30 01:45:16 +0200
commitb7f4cd045844046472b87b9aed90518bfb96818c (patch)
treee93d836dfc6942c5011cbab8dcc86d268d329afb
parent5233ad255ae7fe1debb56a6b67e408e699ea4fe0 (diff)
downloadperl-b7f4cd045844046472b87b9aed90518bfb96818c.tar.gz
Document why we're not using the save stack
-rw-r--r--regexec.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/regexec.c b/regexec.c
index 867965ae56..2f18231f36 100644
--- a/regexec.c
+++ b/regexec.c
@@ -3977,6 +3977,20 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
char *saved_regeol = PL_regeol;
struct re_save_state saved_state;
+ /* To not corrupt the existing regex state while executign the
+ * eval we would normally put it on the save stack, like with
+ * save_re_context. However, re-evals have a weird scoping so we
+ * can't just add ENTER/LEAVE here. With that, things like
+ *
+ * (?{$a=2})(a(?{local$a=$a+1}))*aak*c(?{$b=$a})
+ *
+ * would break, as they expect the localisation to be unwound
+ * only when the re-engine backtracks through the bit that
+ * localised it.
+ *
+ * What we do instead is just saving the state in a local c
+ * variable.
+ */
Copy(&PL_reg_state, &saved_state, 1, struct re_save_state);
n = ARG(scan);