From: Nicholas Clark Date: Sat, 23 May 2009 10:08:47 +0000 (+0100) Subject: Move the code to add magic to $0 into Perl_gv_fetchpvn_flags(). X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e69c155ade49d196491f1d9c96c161b71bb34010;p=p5sagit%2Fp5-mst-13.2.git 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]); --- diff --git a/gv.c b/gv.c index 703635c..549d672 100644 --- a/gv.c +++ b/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': diff --git a/perl.c b/perl.c index 73082ba..8b4f8d7 100644 --- a/perl.c +++ b/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;