Move the code to add magic to $0 into Perl_gv_fetchpvn_flags().
Curiously, this appears to always have been implemented slightly inefficiently.
It dates from perl 4.000, which added the functionality to make assigning to $0
set the process name. The equivalent fix for 4.000 is:
--- a/perl.c
+++ b/perl.c
@@ -738,7 +738,7 @@ FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n");
(void)hadd(sigstab);
}
- magicalize("!#?^~=-%.+&*()<>,\\/[|`':\004\t\020\024\027\006");
+ magicalize("!#?^~=-%.+&*()<>,\\/[|`':0\004\t\020\024\027\006");
userinit(); /* in case linked C routines want magical variables */
amperstab = stabent("&",allstabs);
@@ -828,7 +828,6 @@ FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n");
#endif
if (tmpstab = stabent("0",allstabs)) {
str_set(stab_val(tmpstab),origfilename);
- magicname("0", Nullch, 0);
}
if (tmpstab = stabent("\030",allstabs))
str_set(stab_val(tmpstab),origargv[0]);