X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=sv.c;h=4352fd4e792fcde1035e7568c0f1f9939089caf9;hb=b2f04286ef15827d0776b081ebcb4c3b2e0c0a52;hp=8ad85942f00b1b707681b24548fcf3221c1812fa;hpb=dd5dc04f542db5aa619bf5c0cc2e371a87aef44b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/sv.c b/sv.c index 8ad8594..4352fd4 100644 --- a/sv.c +++ b/sv.c @@ -3215,12 +3215,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags) #endif if (intro) { - GP *gp; - gp_free((GV*)dstr); GvINTRO_off(dstr); /* one-shot flag */ - Newz(602,gp, 1, GP); - GvGP(dstr) = gp_ref(gp); - GvSV(dstr) = NEWSV(72,0); GvLINE(dstr) = CopLINE(PL_curcop); GvEGV(dstr) = (GV*)dstr; } @@ -8164,8 +8159,11 @@ Perl_sv_dup(pTHX_ SV *sstr) } HvPMROOT((HV*)dstr) = HvPMROOT((HV*)sstr); /* XXX */ HvNAME((HV*)dstr) = SAVEPV(HvNAME((HV*)sstr)); - if(HvNAME((HV*)dstr)) - av_push(PL_clone_callbacks,dstr); + /* If HvNAME() is set hv _may_ be a stash + - record it for possible callback + */ + if(HvNAME((HV*)dstr)) + av_push(PL_clone_callbacks, dstr); break; case SVt_PVFM: SvANY(dstr) = new_XPVFM(); @@ -9312,21 +9310,26 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, PL_ptr_table = NULL; } + /* For the (possible) stashes identified above + - check that they are stashes + - if they are see if the ->CLONE method is defined + - if it is call it + */ while(av_len(PL_clone_callbacks) != -1) { HV* stash = (HV*) av_shift(PL_clone_callbacks); - CV* cloner = (CV*) gv_fetchmethod_autoload(stash,"CLONE",0); - if(cloner) { - dSP; - cloner = GvCV(cloner); - ENTER; - SAVETMPS; - PUSHMARK(SP); - XPUSHs(newSVpv(HvNAME(stash),0)); - PUTBACK; - call_sv((SV*)cloner, G_DISCARD); - FREETMPS; - LEAVE; - + if (gv_stashpv(HvNAME(stash),0)) { + GV* cloner = gv_fetchmethod_autoload(stash,"CLONE",0); + if (cloner && GvCV(cloner)) { + dSP; + ENTER; + SAVETMPS; + PUSHMARK(SP); + XPUSHs(newSVpv(HvNAME(stash),0)); + PUTBACK; + call_sv((SV*)GvCV(cloner), G_DISCARD); + FREETMPS; + LEAVE; + } } }