diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-07-15 18:57:01 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-07-15 19:14:23 -0700 |
commit | 96c2a8ff507ccc5e4a6d00051b23e7a73d844322 (patch) | |
tree | 21a226d6eb96eaca777384ff09bc5e466807608d /sv.c | |
parent | d30fb84472a75fa446629f16d12e1ced09787ce4 (diff) | |
download | perl-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.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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 |