X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pad.c;h=f94125269231847c46685f3a537edfdac08d18ee;hb=842c41230043ce99d4bf7b2c79aed85ce2908e89;hp=3868359598d5e5f3442cda47024314c4d98ae23b;hpb=73b81b142731b84cfdd5037cbef3bf9cf5ff3094;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pad.c b/pad.c index 3868359..f941252 100644 --- a/pad.c +++ b/pad.c @@ -101,13 +101,13 @@ become so if C is implemented.) Note that formats are treated as anon subs, and are cloned each time write is called (if necessary). -The flag SVf_PADSTALE is cleared on lexicals each time the my() is executed, +The flag SVs_PADSTALE is cleared on lexicals each time the my() is executed, and set on scope exit. This allows the 'Variable $x is not available' warning to be generated in evals, such as { my $x = 1; sub f { eval '$x'} } f(); -For state vars, SVf_PADSTALE is overloaded to mean 'not yet initialised' +For state vars, SVs_PADSTALE is overloaded to mean 'not yet initialised' =cut */ @@ -360,7 +360,7 @@ S_pad_add_name_sv(pTHX_ SV *namesv, const U32 flags, HV *typestash, SvOURSTASH_set(namesv, ourstash); SvREFCNT_inc_simple_void_NN(ourstash); } - else if (flags & pad_add_STATE) { + else if (flags & padadd_STATE) { SvPAD_STATE_on(namesv); } @@ -393,16 +393,10 @@ Perl_pad_add_name(pTHX_ const char *name, const STRLEN len, const U32 flags, PERL_ARGS_ASSERT_PAD_ADD_NAME; - if (flags & ~(pad_add_OUR|pad_add_STATE|pad_add_NO_DUP_CHECK)) + if (flags & ~(padadd_OUR|padadd_STATE|padadd_NO_DUP_CHECK)) Perl_croak(aTHX_ "panic: pad_add_name illegal flag bits 0x%" UVxf, (UV)flags); - - if ((flags & pad_add_NO_DUP_CHECK) == 0) { - /* check for duplicate declaration */ - pad_check_dup(name, len, flags & pad_add_OUR, ourstash); - } - namesv = newSV_type((ourstash || typestash) ? SVt_PVMG : SVt_PVNV); /* Until we're using the length for real, cross check that we're being told @@ -412,6 +406,11 @@ Perl_pad_add_name(pTHX_ const char *name, const STRLEN len, const U32 flags, sv_setpv(namesv, name); + if ((flags & padadd_NO_DUP_CHECK) == 0) { + /* check for duplicate declaration */ + pad_check_dup(namesv, flags & padadd_OUR, ourstash); + } + offset = pad_add_name_sv(namesv, flags, typestash, ourstash); /* not yet introduced */ @@ -561,25 +560,19 @@ C indicates that the name to check is an 'our' declaration =cut */ -void -S_pad_check_dup(pTHX_ const char *name, const STRLEN len, const U32 flags, - const HV *ourstash) +STATIC void +S_pad_check_dup(pTHX_ SV *name, const U32 flags, const HV *ourstash) { dVAR; SV **svp; PADOFFSET top, off; - const U32 is_our = flags & pad_add_OUR; + const U32 is_our = flags & padadd_OUR; PERL_ARGS_ASSERT_PAD_CHECK_DUP; ASSERT_CURPAD_ACTIVE("pad_check_dup"); - assert((flags & ~pad_add_OUR) == 0); - - /* Until we're using the length for real, cross check that we're being told - the truth. */ - PERL_UNUSED_ARG(len); - assert(strlen(name) == len); + assert((flags & ~padadd_OUR) == 0); if (AvFILLp(PL_comppad_name) < 0 || !ckWARN(WARN_MISC)) return; /* nothing to check */ @@ -595,7 +588,7 @@ S_pad_check_dup(pTHX_ const char *name, const STRLEN len, const U32 flags, && sv != &PL_sv_undef && !SvFAKE(sv) && (COP_SEQ_RANGE_HIGH(sv) == PAD_MAX || COP_SEQ_RANGE_HIGH(sv) == 0) - && strEQ(name, SvPVX_const(sv))) + && sv_eq(name, sv)) { if (is_our && (SvPAD_OUR(sv))) break; /* "our" masking "our" */ @@ -617,7 +610,7 @@ S_pad_check_dup(pTHX_ const char *name, const STRLEN len, const U32 flags, && !SvFAKE(sv) && (COP_SEQ_RANGE_HIGH(sv) == PAD_MAX || COP_SEQ_RANGE_HIGH(sv) == 0) && SvOURSTASH(sv) == ourstash - && strEQ(name, SvPVX_const(sv))) + && sv_eq(name, sv)) { Perl_warner(aTHX_ packWARN(WARN_MISC), "\"our\" variable %"SVf" redeclared", sv); @@ -926,7 +919,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn, new_offset = pad_add_name_sv(new_namesv, - (SvPAD_STATE(*out_name_sv) ? pad_add_STATE : 0), + (SvPAD_STATE(*out_name_sv) ? padadd_STATE : 0), SvPAD_TYPED(*out_name_sv) ? SvSTASH(*out_name_sv) : NULL, SvOURSTASH(*out_name_sv)