From: Nicholas Clark Date: Sat, 14 Nov 2009 21:01:21 +0000 (+0000) Subject: Change S_pad_check_dup()'s arguments from char*/STRLEN to SV *. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2d12d04f1cca69e8010b11cf63b89ce3b00490b9;p=p5sagit%2Fp5-mst-13.2.git Change S_pad_check_dup()'s arguments from char*/STRLEN to SV *. Within the function, use sv_eq() rather than strcmp(). --- diff --git a/embed.fnc b/embed.fnc index 1e017e5..7522055 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1940,8 +1940,8 @@ Mpd |PADOFFSET|pad_add_name |NN const char *name|const STRLEN len\ : Only used in op.c pd |PADOFFSET|pad_add_anon |NN SV* sv|OPCODE op_type #if defined(PERL_IN_PAD_C) || defined(PERL_DECL_PROT) -sd |void |pad_check_dup |NN const char *name|const STRLEN len\ - |const U32 flags|NULLOK const HV *ourstash +sd |void |pad_check_dup |NN SV *name|const U32 flags \ + |NULLOK const HV *ourstash #endif #ifdef DEBUGGING : Only used PAD_SETSV() in op.c diff --git a/embed.h b/embed.h index 0ed9380..52e40c6 100644 --- a/embed.h +++ b/embed.h @@ -4099,7 +4099,7 @@ #endif #if defined(PERL_IN_PAD_C) || defined(PERL_DECL_PROT) #ifdef PERL_CORE -#define pad_check_dup(a,b,c,d) S_pad_check_dup(aTHX_ a,b,c,d) +#define pad_check_dup(a,b,c) S_pad_check_dup(aTHX_ a,b,c) #endif #endif #ifdef DEBUGGING diff --git a/pad.c b/pad.c index 3868359..9245480 100644 --- a/pad.c +++ b/pad.c @@ -397,12 +397,6 @@ Perl_pad_add_name(pTHX_ const char *name, const STRLEN len, const U32 flags, 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 & pad_add_NO_DUP_CHECK) == 0) { + /* check for duplicate declaration */ + pad_check_dup(namesv, flags & pad_add_OUR, ourstash); + } + offset = pad_add_name_sv(namesv, flags, typestash, ourstash); /* not yet introduced */ @@ -562,8 +561,7 @@ C indicates that the name to check is an 'our' declaration */ void -S_pad_check_dup(pTHX_ const char *name, const STRLEN len, const U32 flags, - const HV *ourstash) +S_pad_check_dup(pTHX_ SV *name, const U32 flags, const HV *ourstash) { dVAR; SV **svp; @@ -576,11 +574,6 @@ S_pad_check_dup(pTHX_ const char *name, const STRLEN len, const U32 flags, 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); - 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); diff --git a/proto.h b/proto.h index b7b33ab..f1ab3d0 100644 --- a/proto.h +++ b/proto.h @@ -6117,7 +6117,7 @@ PERL_CALLCONV PADOFFSET Perl_pad_add_anon(pTHX_ SV* sv, OPCODE op_type) assert(sv) #if defined(PERL_IN_PAD_C) || defined(PERL_DECL_PROT) -STATIC 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) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_PAD_CHECK_DUP \ assert(name)