summaryrefslogtreecommitdiff
path: root/pad.c
diff options
context:
space:
mode:
authorVincent Pit <perl@profvince.com>2010-06-03 11:44:15 +0200
committerVincent Pit <perl@profvince.com>2010-06-03 14:00:38 +0200
commit789bd863840ef4ff6c46f7c2ee0f3f64e0b5daa6 (patch)
tree547efad230cfa3f03e5c971600e394627beb62f3 /pad.c
parent540810e8986e170e75f4b34a7ca1f1dd5b0da3c4 (diff)
downloadperl-789bd863840ef4ff6c46f7c2ee0f3f64e0b5daa6.tar.gz
Make pp_reverse fetch the lexical $_ from the correct pad
This is achieved by introducing a new find_rundefsv() function in pad.c This fixes [perl #75436].
Diffstat (limited to 'pad.c')
-rw-r--r--pad.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/pad.c b/pad.c
index 477ee0f102..e8ba139434 100644
--- a/pad.c
+++ b/pad.c
@@ -704,6 +704,28 @@ Perl_find_rundefsvoffset(pTHX)
}
/*
+ * Returns a lexical $_, if there is one, at run time ; or the global one
+ * otherwise.
+ */
+
+SV *
+Perl_find_rundefsv(pTHX)
+{
+ SV *namesv;
+ int flags;
+ PADOFFSET po;
+
+ po = pad_findlex("$_", find_runcv(NULL), PL_curcop->cop_seq, 1,
+ NULL, &namesv, &flags);
+
+ if (po == NOT_IN_PAD
+ || (SvFLAGS(namesv) & (SVpad_NAME|SVpad_OUR)) == (SVpad_NAME|SVpad_OUR))
+ return DEFSV;
+
+ return PAD_SVl(po);
+}
+
+/*
=for apidoc pad_findlex
Find a named lexical anywhere in a chain of nested pads. Add fake entries