Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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]);
  • Loading branch information...
commit e69c155ade49d196491f1d9c96c161b71bb34010 1 parent ae8ade6
Nicholas Clark authored
Showing with 1 addition and 5 deletions.
  1. +1 −0  gv.c
  2. +0 −5 perl.c
View
1  gv.c
@@ -1394,6 +1394,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
ro_magicalize:
SvREADONLY_on(GvSVn(gv));
/* FALL THROUGH */
+ case '0':
case '1':
case '2':
case '3':
View
5 perl.c
@@ -3935,11 +3935,6 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register
if ((tmpgv = gv_fetchpvs("0", GV_ADD|GV_NOTQUAL, SVt_PV))) {
sv_setpv(GvSV(tmpgv),PL_origfilename);
- {
- GV * const gv = gv_fetchpv("0", GV_ADD, SVt_PV);
- if (gv)
- sv_magic(GvSV(gv), MUTABLE_SV(gv), PERL_MAGIC_sv, "0", 1);
- }
}
if ((PL_envgv = gv_fetchpvs("ENV", GV_ADD|GV_NOTQUAL, SVt_PVHV))) {
HV *hv;
Please sign in to comment.
Something went wrong with that request. Please try again.