summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2010-10-27 09:44:04 -0700
committerFather Chrysostomos <sprout@cpan.org>2010-10-27 09:45:26 -0700
commit78b79c7758384edd69ba966d2f0571855acb1117 (patch)
tree5804749f02e2f3d1440bc78bd3c684d31ff72202 /sv.c
parent13d356f324d3ac73ad7eb9e627a33e3fa89132ec (diff)
downloadperl-78b79c7758384edd69ba966d2f0571855acb1117.tar.gz
Renaming of stashes should not be visible from Perl
Change 35759254 made stashes get renamed when moved around. This had an unintended consequence: Typeglobs, ref() return values, stringifi- cation of blessed references and __PACKAGE__ are all affected by this. This commit makes a new distinction between stashes’ names and effect- ive names. Stash names are now unaffected when the stashes move around. Only the effective names are affected. (The apparent presence of any puns in the previous sentence is purely incidental and most likely the result of the reader’s inferential propensity.) To this end a new HvENAME_get macro is introduced, returning the first effective name (what HvNAME_get was returning). (Only one effective name needs to be in effect at a time.) hv_add_name and hv_delete_name have been renamed hv_add_ename and hv_delete_ename. hv_name_set is modified to leave the effective names in place unless the name is being set to NULL. These names are now stored in HvAUX as follows: When xhv_name_count is 0, xhv_name is a HEK pointer, containing the name which is also the effective name. When xhv_name_count is not zero, then xhv_name is a pointer to an array of HEK pointers. If xhv_name_count is positive, the first HEK is the name *and* one of the effective names. When xhv_name_count is negative, the first HEK is the name and subsequent HEKs are the effective names.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sv.c b/sv.c
index ccb18e760e..4d98e68494 100644
--- a/sv.c
+++ b/sv.c
@@ -3656,7 +3656,7 @@ S_glob_assign_glob(pTHX_ SV *const dstr, SV *const sstr, const int dtype)
if(mro_changes == 2) mro_isa_changed_in(GvSTASH(dstr));
else if(mro_changes == 3) {
HV * const stash = GvHV(dstr);
- if(old_stash ? (HV *)HvNAME(old_stash) : stash)
+ if(old_stash ? (HV *)HvENAME_get(old_stash) : stash)
mro_package_moved(
stash, old_stash,
(GV *)dstr, NULL, 0
@@ -3773,7 +3773,7 @@ S_glob_assign_ref(pTHX_ SV *const dstr, SV *const sstr)
const STRLEN len = GvNAMELEN(dstr);
if (
len > 1 && name[len-2] == ':' && name[len-1] == ':'
- && (!dref || HvNAME(dref))
+ && (!dref || HvENAME_get(dref))
) {
mro_package_moved(
(HV *)sref, (HV *)dref,
@@ -4043,7 +4043,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV* sstr, const I32 flags)
if (reset_isa) {
HV * const stash = GvHV(dstr);
if(
- old_stash ? (HV *)HvNAME(old_stash) : stash
+ old_stash ? (HV *)HvENAME_get(old_stash) : stash
)
mro_package_moved(
stash, old_stash,
@@ -11744,7 +11744,10 @@ S_sv_dup_common(pTHX_ const SV *const sstr, CLONE_PARAMS *const param)
hvname = saux->xhv_name;
if (saux->xhv_name_count) {
HEK ** const sname = (HEK **)saux->xhv_name;
- const U32 count = saux->xhv_name_count;
+ const I32 count
+ = saux->xhv_name_count < 0
+ ? -saux->xhv_name_count
+ : saux->xhv_name_count;
HEK **shekp = sname + count;
HEK **dhekp;
Newxc(daux->xhv_name, count, HEK *, HEK);