diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-12-23 14:18:16 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-12-23 14:45:55 -0800 |
commit | 1e6bda93199bc72086fd20f4dab89d46590b379a (patch) | |
tree | d3c9063779f46754f059847ce4708cd2dc3dad15 /mg.c | |
parent | f0cd42383d11de42b3b8137c27c960b257975418 (diff) | |
download | perl-1e6bda93199bc72086fd20f4dab89d46590b379a.tar.gz |
[perl #29070] Add vstring set-magic
Some operators, like pp_complement, assign their argument to TARG
(which copies vstring magic), modify it in place, and then call set-
magic. That’s supposed to work, but vstring magic was remaining as it
was, such that ~v7 would still be treated as "v7" by vstring-aware
code, even though the resulting string is not "\7".
This commit adds vstring set-magic that checks to see whether the pv
still matches the vstring. It cannot simply free the vstring magic,
as that would prevent $x=v0 from working.
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -2295,6 +2295,19 @@ Perl_magic_setvec(pTHX_ SV *sv, MAGIC *mg) } int +Perl_magic_setvstring(pTHX_ SV *sv, MAGIC *mg) +{ + PERL_ARGS_ASSERT_MAGIC_SETVSTRING; + + if (SvPOKp(sv)) { + SV * const vecsv = sv_newmortal(); + scan_vstring(mg->mg_ptr, mg->mg_ptr + mg->mg_len, vecsv); + if (sv_eq_flags(vecsv, sv, 0 /*nomg*/)) return 0; + } + return sv_unmagic(sv, mg->mg_type); +} + +int Perl_magic_getdefelem(pTHX_ SV *sv, MAGIC *mg) { dVAR; |