From: Andy Lester Date: Wed, 1 Jun 2005 23:16:56 +0000 (-0500) Subject: use lengths in sv_setpv() calls X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=616d8c9c7dee8ffe0d25891708d3380cabc2db84;p=p5sagit%2Fp5-mst-13.2.git use lengths in sv_setpv() calls Message-ID: <20050602041656.GA3000@petdance.com> p4raw-id: //depot/perl@24669 --- diff --git a/gv.c b/gv.c index f1fe784..2d0fc93 100644 --- a/gv.c +++ b/gv.c @@ -1094,11 +1094,11 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, break; case '\014': /* $^L */ - sv_setpv(GvSV(gv),"\f"); + sv_setpvn(GvSV(gv),"\f",1); PL_formfeed = GvSV(gv); break; case ';': - sv_setpv(GvSV(gv),"\034"); + sv_setpvn(GvSV(gv),"\034",1); break; case ']': { diff --git a/sv.c b/sv.c index 42320dd..9a61a35 100644 --- a/sv.c +++ b/sv.c @@ -758,12 +758,15 @@ S_varname(pTHX_ GV *gv, const char *gvtype, PADOFFSET targ, else { U32 u; CV *cv = find_runcv(&u); + STRLEN len; + const char *str; if (!cv || !CvPADLIST(cv)) return Nullsv;; av = (AV*)(*av_fetch(CvPADLIST(cv), 0, FALSE)); sv = *av_fetch(av, targ, FALSE); /* SvLEN in a pad name is not to be trusted */ - sv_setpv(name, SvPV_nolen(sv)); + str = SvPV(sv,len); + sv_setpvn(name, str, len); } if (subscript_type == FUV_SUBSCRIPT_HASH) { @@ -1028,7 +1031,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) : DEFSV)) { sv = sv_newmortal(); - sv_setpv(sv, "$_"); + sv_setpvn(sv, "$_", 2); return sv; } } @@ -7577,9 +7580,7 @@ Perl_newSVpv(pTHX_ const char *s, STRLEN len) register SV *sv; new_SV(sv); - if (!len) - len = strlen(s); - sv_setpvn(sv,s,len); + sv_setpvn(sv,s,len ? len : strlen(s)); return sv; } @@ -10931,9 +10932,9 @@ Perl_sv_dup(pTHX_ SV *sstr, CLONE_PARAMS* param) if (HvARRAY((HV*)sstr)) { STRLEN i = 0; - bool sharekeys = !!HvSHAREKEYS(sstr); - XPVHV *dxhv = (XPVHV*)SvANY(dstr); - XPVHV *sxhv = (XPVHV*)SvANY(sstr); + const bool sharekeys = !!HvSHAREKEYS(sstr); + XPVHV * const dxhv = (XPVHV*)SvANY(dstr); + XPVHV * const sxhv = (XPVHV*)SvANY(sstr); char *darray; New(0, darray, PERL_HV_ARRAY_ALLOC_BYTES(dxhv->xhv_max+1) diff --git a/util.c b/util.c index b97a6f0..dfd912f 100644 --- a/util.c +++ b/util.c @@ -2735,13 +2735,13 @@ Perl_same_dirent(pTHX_ const char *a, const char *b) if (strNE(a,b)) return FALSE; if (fa == a) - sv_setpv(tmpsv, "."); + sv_setpvn(tmpsv, ".", 1); else sv_setpvn(tmpsv, a, fa - a); if (PerlLIO_stat(SvPVX_const(tmpsv), &tmpstatbuf1) < 0) return FALSE; if (fb == b) - sv_setpv(tmpsv, "."); + sv_setpvn(tmpsv, ".", 1); else sv_setpvn(tmpsv, b, fb - b); if (PerlLIO_stat(SvPVX_const(tmpsv), &tmpstatbuf2) < 0)