This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make sure the CORE package is always called CORE
authorFather Chrysostomos <sprout@cpan.org>
Tue, 2 Aug 2011 21:46:17 +0000 (14:46 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 14 Aug 2011 18:14:29 +0000 (11:14 -0700)
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.

gv.c

diff --git a/gv.c b/gv.c
index 12ff1f3..aef0aa4 100644 (file)
--- 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)) {
                {
                    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)
                        /* If the containing stash has multiple effective
                           names, see that this one gets them, too. */
                        if (HvAUX(GvSTASH(gv))->xhv_name_count)