summaryrefslogtreecommitdiff
path: root/mg_vtable.h
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-07-27 23:46:07 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-07-27 23:46:33 -0700
commit4499db7385adf05fc8c5f6e28aa920d268b63435 (patch)
treed44c8f9c0a2a84ccf98f701d09be2a67955ed1a9 /mg_vtable.h
parent5bbe7184a7198d6334733fd9eb3ca7db21bf04f2 (diff)
downloadperl-4499db7385adf05fc8c5f6e28aa920d268b63435.tar.gz
Flatten vstrings modified in place
A substitution forces its target to a string upon successful substitu- tion, even if the substitution did nothing: $ ./perl -Ilib -le '$a = *f; $a =~ s/f/f/; print ref \$a' SCALAR Notice that $a is no longer a glob after s///. But vstrings are different: $ ./perl -Ilib -le '$a = v102; $a =~ s/f/f/; print ref \$a' VSTRING I fixed this in 5.16 (1e6bda93) for those cases where the vstring ends up with a value that doesn’t correspond to the actual string: $ ./perl -Ilib -le '$a = v102; $a =~ s/f/o/; print ref \$a' SCALAR It works through vstring set-magic, that does the check and removes the magic if it doesn’t match. I did it that way because I couldn’t think of any other way to fix bug #29070, and I didn’t realise at the time that I hadn’t fixed all the bugs. By making SvTHINKFIRST true on a vstring, we force it through sv_force_normal before any in-place string operations. We can also make sv_force_normal handle vstrings as well. This fixes all the lin- gering-vstring-magic bugs in just two lines, making the vstring set- magic (which is also slow) redundant. It also allows the special case in sv_setsv_flags to be removed. Or at least that was what I had hoped. It turns out that pp_subst, twists and turns in tortuous ways, and needs special treatment for things like this. And do_trans functions wasn’t checking SvTHINKFIRST when arguably it should have. I tweaked sv_2pv{utf8,byte} to avoid copying magic variables that do not need copying.
Diffstat (limited to 'mg_vtable.h')
-rw-r--r--mg_vtable.h8
1 files changed, 2 insertions, 6 deletions
diff --git a/mg_vtable.h b/mg_vtable.h
index 3c73c2beff..2490394895 100644
--- a/mg_vtable.h
+++ b/mg_vtable.h
@@ -86,7 +86,6 @@ enum { /* pass one of these to get_vtbl */
want_vtbl_utf8,
want_vtbl_uvar,
want_vtbl_vec,
- want_vtbl_vstring,
magic_vtable_max
};
@@ -120,8 +119,7 @@ EXTCONST char *PL_magic_vtable_names[magic_vtable_max] = {
"taint",
"utf8",
"uvar",
- "vec",
- "vstring"
+ "vec"
};
#else
EXTCONST char *PL_magic_vtable_names[magic_vtable_max];
@@ -182,8 +180,7 @@ EXT_MGVTBL PL_magic_vtables[magic_vtable_max] = {
{ Perl_magic_gettaint, Perl_magic_settaint, 0, 0, 0, 0, 0, 0 },
{ 0, Perl_magic_setutf8, 0, 0, 0, 0, 0, 0 },
{ Perl_magic_getuvar, Perl_magic_setuvar, 0, 0, 0, 0, 0, 0 },
- { Perl_magic_getvec, Perl_magic_setvec, 0, 0, 0, 0, 0, 0 },
- { 0, Perl_magic_setvstring, 0, 0, 0, 0, 0, 0 }
+ { Perl_magic_getvec, Perl_magic_setvec, 0, 0, 0, 0, 0, 0 }
};
#else
EXT_MGVTBL PL_magic_vtables[magic_vtable_max];
@@ -223,6 +220,5 @@ EXT_MGVTBL PL_magic_vtables[magic_vtable_max];
#define PL_vtbl_utf8 PL_magic_vtables[want_vtbl_utf8]
#define PL_vtbl_uvar PL_magic_vtables[want_vtbl_uvar]
#define PL_vtbl_vec PL_magic_vtables[want_vtbl_vec]
-#define PL_vtbl_vstring PL_magic_vtables[want_vtbl_vstring]
/* ex: set ro: */