From: Nicholas Clark Date: Sat, 28 Jan 2006 12:08:01 +0000 (+0000) Subject: Pull glob_assign out from sv_setsv_flags into a static function. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5d0301b7eadf057a17208351b165dd2f711900b5;p=p5sagit%2Fp5-mst-13.2.git Pull glob_assign out from sv_setsv_flags into a static function. p4raw-id: //depot/perl@26976 --- diff --git a/sv.c b/sv.c index 60237b6..cbeb3d8 100644 --- a/sv.c +++ b/sv.c @@ -2925,6 +2925,45 @@ copy-ish functions and macros use this underneath. =cut */ +static void +S_glob_assign(pTHX_ SV *dstr, SV *sstr, const int dtype) +{ + if (dtype != SVt_PVGV) { + const char * const name = GvNAME(sstr); + const STRLEN len = GvNAMELEN(sstr); + /* don't upgrade SVt_PVLV: it can hold a glob */ + if (dtype != SVt_PVLV) + sv_upgrade(dstr, SVt_PVGV); + sv_magic(dstr, dstr, PERL_MAGIC_glob, Nullch, 0); + GvSTASH(dstr) = GvSTASH(sstr); + if (GvSTASH(dstr)) + Perl_sv_add_backref(aTHX_ (SV*)GvSTASH(dstr), dstr); + GvNAME(dstr) = savepvn(name, len); + GvNAMELEN(dstr) = len; + SvFAKE_on(dstr); /* can coerce to non-glob */ + } + +#ifdef GV_UNIQUE_CHECK + if (GvUNIQUE((GV*)dstr)) { + Perl_croak(aTHX_ PL_no_modify); + } +#endif + + (void)SvOK_off(dstr); + GvINTRO_off(dstr); /* one-shot flag */ + gp_free((GV*)dstr); + GvGP(dstr) = gp_ref(GvGP(sstr)); + if (SvTAINTED(sstr)) + SvTAINT(dstr); + if (GvIMPORTED(dstr) != GVf_IMPORTED + && CopSTASH_ne(PL_curcop, GvSTASH(dstr))) + { + GvIMPORTED_on(dstr); + } + GvMULTI_on(dstr); + return; +} + void Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags) { @@ -3059,40 +3098,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags) case SVt_PVGV: if (dtype <= SVt_PVGV) { glob_assign: - if (dtype != SVt_PVGV) { - const char * const name = GvNAME(sstr); - const STRLEN len = GvNAMELEN(sstr); - /* don't upgrade SVt_PVLV: it can hold a glob */ - if (dtype != SVt_PVLV) - sv_upgrade(dstr, SVt_PVGV); - sv_magic(dstr, dstr, PERL_MAGIC_glob, Nullch, 0); - GvSTASH(dstr) = GvSTASH(sstr); - if (GvSTASH(dstr)) - Perl_sv_add_backref(aTHX_ (SV*)GvSTASH(dstr), dstr); - GvNAME(dstr) = savepvn(name, len); - GvNAMELEN(dstr) = len; - SvFAKE_on(dstr); /* can coerce to non-glob */ - } - -#ifdef GV_UNIQUE_CHECK - if (GvUNIQUE((GV*)dstr)) { - Perl_croak(aTHX_ PL_no_modify); - } -#endif - - (void)SvOK_off(dstr); - GvINTRO_off(dstr); /* one-shot flag */ - gp_free((GV*)dstr); - GvGP(dstr) = gp_ref(GvGP(sstr)); - if (SvTAINTED(sstr)) - SvTAINT(dstr); - if (GvIMPORTED(dstr) != GVf_IMPORTED - && CopSTASH_ne(PL_curcop, GvSTASH(dstr))) - { - GvIMPORTED_on(dstr); - } - GvMULTI_on(dstr); - return; + return S_glob_assign(aTHX_ dstr, sstr, dtype); } /* FALL THROUGH */