From: Jarkko Hietaniemi Date: Wed, 27 Feb 2002 17:50:09 +0000 (+0000) Subject: Repatch from Robin Barker: anon subs in C are X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c99da3702f996b1fc1415a829383240bdf2f0fd2;p=p5sagit%2Fp5-mst-13.2.git Repatch from Robin Barker: anon subs in C are now __ANON__::__ANON__ (should help for mod_perl breakage since #12251) p4raw-id: //depot/perl@14899 --- diff --git a/gv.c b/gv.c index a67b36f..08a103c 100644 --- a/gv.c +++ b/gv.c @@ -662,7 +662,7 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type) strEQ(name, "ARGVOUT"))) global = TRUE; } - else if (*name == '_' && (!name[1] || strEQ(name,"__ANON__"))) + else if (*name == '_' && !name[1]) global = TRUE; if (global) diff --git a/op.c b/op.c index e39850e..a03f0e5 100644 --- a/op.c +++ b/op.c @@ -4755,13 +4755,15 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) name = o ? SvPVx(cSVOPo->op_sv, n_a) : Nullch; if (!name && PERLDB_NAMEANON && CopLINE(PL_curcop)) { SV *sv = sv_newmortal(); - Perl_sv_setpvf(aTHX_ sv, "__ANON__[%s:%"IVdf"]", + Perl_sv_setpvf(aTHX_ sv, "%s[%s:%"IVdf"]", + PL_curstash ? "__ANON__" : "__ANON__::__ANON__", CopFILE(PL_curcop), (IV)CopLINE(PL_curcop)); aname = SvPVX(sv); } else aname = Nullch; - gv = gv_fetchpv(name ? name : (aname ? aname : "__ANON__"), + gv = gv_fetchpv(name ? name : (aname ? aname : + (PL_curstash ? "__ANON__" : "__ANON__::__ANON__")), GV_ADDMULTI | ((block || attrs) ? 0 : GV_NOINIT), SVt_PVCV); @@ -5179,7 +5181,9 @@ Used by C to hook up XSUBs as Perl subs. CV * Perl_newXS(pTHX_ char *name, XSUBADDR_t subaddr, char *filename) { - GV *gv = gv_fetchpv(name ? name : "__ANON__", GV_ADDMULTI, SVt_PVCV); + GV *gv = gv_fetchpv(name ? name : + (PL_curstash ? "__ANON__" : "__ANON__::__ANON__"), + GV_ADDMULTI, SVt_PVCV); register CV *cv; if ((cv = (name ? GvCV(gv) : Nullcv))) { diff --git a/t/op/runlevel.t b/t/op/runlevel.t index 6a10e8b..1eedda8 100755 --- a/t/op/runlevel.t +++ b/t/op/runlevel.t @@ -311,7 +311,7 @@ $SIG{__DIE__} = sub { eval { die }; &{sub { eval 'die' }}(); sub foo { eval { die } } foo(); -{package rmb; sub{ eval{die} } ->() }; # check __ANON__ is global +{package rmb; sub{ eval{die} } ->() }; # check __ANON__ knows package EXPECT In DIE main|-|8|(eval) @@ -323,7 +323,7 @@ main|-|10|(eval) main|-|10|main::foo In DIE rmb|-|11|(eval) -rmb|-|11|main::__ANON__ +rmb|-|11|rmb::__ANON__ ######## package TEST; diff --git a/toke.c b/toke.c index 9440260..6e457c2 100644 --- a/toke.c +++ b/toke.c @@ -4027,7 +4027,8 @@ Perl_yylex(pTHX) if (strEQ(proto, "$")) OPERATOR(UNIOPSUB); if (*proto == '&' && *s == '{') { - sv_setpv(PL_subname,"__ANON__"); + sv_setpv(PL_subname, PL_curstash ? + "__ANON__" : "__ANON__::__ANON__"); PREBLOCK(LSTOPSUB); } } @@ -5008,7 +5009,8 @@ Perl_yylex(pTHX) force_next(THING); } if (!have_name) { - sv_setpv(PL_subname,"__ANON__"); + sv_setpv(PL_subname, + PL_curstash ? "__ANON__" : "__ANON__::__ANON__"); TOKEN(ANONSUB); } (void) force_word(PL_oldbufptr + tboffset, WORD,