summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-08-02 14:46:17 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-08-14 11:14:29 -0700
commite058c50ad847ead283c43829ad8b0b73f59ef9db (patch)
treeb061a15af42b6380afac0124d1902ab6d564f373
parent7391a1634af9fc4c03048f12594b25fd776ccf98 (diff)
downloadperl-e058c50ad847ead283c43829ad8b0b73f59ef9db.tar.gz
Make sure the CORE package is always called CORE
And not ::CORE or main::CORE or *CORE, etc. Since the CORE package’s magic for autovivifying CORE subs will be based on the package name, we can’t have code like &::CORE::foo breaking the entire package. Making a more general change to gv_fetchpvn_flags causes problems for autoloaded SUPER methods and strangely-named packages like main::::foo, so this patch is CORE-specific.
-rw-r--r--gv.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gv.c b/gv.c
index 12ff1f3d63..aef0aa4514 100644
--- a/gv.c
+++ b/gv.c
@@ -1106,7 +1106,13 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
{
stash = GvHV(gv) = newHV();
if (!HvNAME_get(stash)) {
- hv_name_set(stash, nambeg, name_cursor-nambeg, 0);
+ if (GvSTASH(gv) == PL_defstash && len == 6
+ && strnEQ(name, "CORE", 4))
+ hv_name_set(stash, "CORE", 4, 0);
+ else
+ hv_name_set(
+ stash, nambeg, name_cursor-nambeg, 0
+ );
/* If the containing stash has multiple effective
names, see that this one gets them, too. */
if (HvAUX(GvSTASH(gv))->xhv_name_count)