summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-07-15 18:57:01 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-07-15 19:14:23 -0700
commit96c2a8ff507ccc5e4a6d00051b23e7a73d844322 (patch)
tree21a226d6eb96eaca777384ff09bc5e466807608d /sv.c
parentd30fb84472a75fa446629f16d12e1ced09787ce4 (diff)
downloadperl-96c2a8ff507ccc5e4a6d00051b23e7a73d844322.tar.gz
[perl #77814] Make defelems propagate pos
When elements of @_ refer to nonexistent hash or array elements, then the magic scalar in $_[0] delegates all set/get actions to the element in represents, vivifying it if needed. pos($_[0]), however, was not delegating the value to the element, but storing it on the magical ‘deferred element’ scalar.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/sv.c b/sv.c
index 183b60bb14..e5f60a2c39 100644
--- a/sv.c
+++ b/sv.c
@@ -5410,6 +5410,24 @@ Perl_sv_magicext(pTHX_ SV *const sv, SV *const obj, const int how,
return mg;
}
+MAGIC *
+Perl_sv_magicext_mglob(pTHX_ SV *sv)
+{
+ PERL_ARGS_ASSERT_SV_MAGICEXT_MGLOB;
+ if (SvTYPE(sv) == SVt_PVLV && LvTYPE(sv) == 'y') {
+ /* This sv is only a delegate. //g magic must be attached to
+ its target. */
+ vivify_defelem(sv);
+ sv = LvTARG(sv);
+ }
+#ifdef PERL_OLD_COPY_ON_WRITE
+ if (SvIsCOW(sv))
+ sv_force_normal_flags(sv, 0);
+#endif
+ return sv_magicext(sv, NULL, PERL_MAGIC_regex_global,
+ &PL_vtbl_mglob, 0, 0);
+}
+
/*
=for apidoc sv_magic