From: Gurusamy Sarathy Date: Sun, 4 Apr 1999 01:59:26 +0000 (+0000) Subject: correct places that said newSVpv() when they meant newSVpvn() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=79cb57f6e01f91d8fff40d69caa187aaa669671b;p=p5sagit%2Fp5-mst-13.2.git correct places that said newSVpv() when they meant newSVpvn() p4raw-id: //depot/perl@3217 --- diff --git a/XSUB.h b/XSUB.h index f847886..22805a0 100644 --- a/XSUB.h +++ b/XSUB.h @@ -40,6 +40,7 @@ #define XST_mIV(i,v) (ST(i) = sv_2mortal(newSViv(v)) ) #define XST_mNV(i,v) (ST(i) = sv_2mortal(newSVnv(v)) ) #define XST_mPV(i,v) (ST(i) = sv_2mortal(newSVpv(v,0))) +#define XST_mPVN(i,v,n) (ST(i) = sv_2mortal(newSVpvn(v,n))) #define XST_mNO(i) (ST(i) = &PL_sv_no ) #define XST_mYES(i) (ST(i) = &PL_sv_yes ) #define XST_mUNDEF(i) (ST(i) = &PL_sv_undef) @@ -47,6 +48,7 @@ #define XSRETURN_IV(v) STMT_START { XST_mIV(0,v); XSRETURN(1); } STMT_END #define XSRETURN_NV(v) STMT_START { XST_mNV(0,v); XSRETURN(1); } STMT_END #define XSRETURN_PV(v) STMT_START { XST_mPV(0,v); XSRETURN(1); } STMT_END +#define XSRETURN_PVN(v) STMT_START { XST_mPVN(0,v,n); XSRETURN(1); } STMT_END #define XSRETURN_NO STMT_START { XST_mNO(0); XSRETURN(1); } STMT_END #define XSRETURN_YES STMT_START { XST_mYES(0); XSRETURN(1); } STMT_END #define XSRETURN_UNDEF STMT_START { XST_mUNDEF(0); XSRETURN(1); } STMT_END diff --git a/dump.c b/dump.c index 34d0eb7..cce9830 100644 --- a/dump.c +++ b/dump.c @@ -267,7 +267,7 @@ sv_peek(SV *sv) if (!SvPVX(sv)) sv_catpv(t, "(null)"); else { - SV *tmp = newSVpv("", 0); + SV *tmp = newSVpvn("", 0); sv_catpv(t, "("); if (SvOOK(sv)) sv_catpvf(t, "[%s]", pv_display(tmp, SvPVX(sv)-SvIVX(sv), SvIVX(sv), 0, 127)); @@ -318,7 +318,7 @@ do_pmop_dump(I32 level, PerlIO *file, PMOP *pm) op_dump(pm->op_pmreplroot); } if (pm->op_pmflags || (pm->op_pmregexp && pm->op_pmregexp->check_substr)) { - SV *tmpsv = newSVpv("", 0); + SV *tmpsv = newSVpvn("", 0); if (pm->op_pmdynflags & PMdf_USED) sv_catpv(tmpsv, ",USED"); if (pm->op_pmdynflags & PMdf_TAINTED) @@ -388,7 +388,7 @@ do_op_dump(I32 level, PerlIO *file, OP *o) dump_indent(level, file, "ADDR = 0x%lx => 0x%lx\n",o, o->op_next); #endif if (o->op_flags) { - SV *tmpsv = newSVpv("", 0); + SV *tmpsv = newSVpvn("", 0); switch (o->op_flags & OPf_WANT) { case OPf_WANT_VOID: sv_catpv(tmpsv, ",VOID"); @@ -419,7 +419,7 @@ do_op_dump(I32 level, PerlIO *file, OP *o) SvREFCNT_dec(tmpsv); } if (o->op_private) { - SV *tmpsv = newSVpv("", 0); + SV *tmpsv = newSVpvn("", 0); if (o->op_type == OP_AASSIGN) { if (o->op_private & OPpASSIGN_COMMON) sv_catpv(tmpsv, ",COMMON"); @@ -671,7 +671,7 @@ do_magic_dump(I32 level, PerlIO *file, MAGIC *mg, I32 nest, I32 maxnest, bool du if (mg->mg_ptr) { dump_indent(level, file, " MG_PTR = 0x%lx", (long)mg->mg_ptr); if (mg->mg_len >= 0) { - SV *sv = newSVpv("", 0); + SV *sv = newSVpvn("", 0); PerlIO_printf(file, " %s", pv_display(sv, mg->mg_ptr, mg->mg_len, 0, pvlim)); SvREFCNT_dec(sv); } diff --git a/ext/B/B.xs b/ext/B/B.xs index a2ee814..ccac053 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -221,7 +221,7 @@ make_mg_object(SV *arg, MAGIC *mg) static SV * cstring(SV *sv) { - SV *sstr = newSVpv("", 0); + SV *sstr = newSVpvn("", 0); STRLEN len; char *s; @@ -274,7 +274,7 @@ cstring(SV *sv) static SV * cchar(SV *sv) { - SV *sstr = newSVpv("'", 0); + SV *sstr = newSVpvn("'", 1); STRLEN n_a; char *s = SvPV(sv, n_a); @@ -600,7 +600,7 @@ threadsv_names() EXTEND(sp, len); for (i = 0; i < len; i++) - PUSHs(sv_2mortal(newSVpv(&PL_threadsv_names[i], 1))); + PUSHs(sv_2mortal(newSVpvn(&PL_threadsv_names[i], 1))); #endif @@ -879,10 +879,10 @@ packiv(sv) */ wp[0] = htonl(((U32)iv) >> (sizeof(IV)*4)); wp[1] = htonl(iv & 0xffffffff); - ST(0) = sv_2mortal(newSVpv((char *)wp, 8)); + ST(0) = sv_2mortal(newSVpvn((char *)wp, 8)); } else { U32 w = htonl((U32)SvIVX(sv)); - ST(0) = sv_2mortal(newSVpv((char *)&w, 4)); + ST(0) = sv_2mortal(newSVpvn((char *)&w, 4)); } MODULE = B PACKAGE = B::NV PREFIX = Sv @@ -1013,7 +1013,7 @@ BmTABLE(sv) CODE: str = SvPV(sv, len); /* Boyer-Moore table is just after string and its safety-margin \0 */ - ST(0) = sv_2mortal(newSVpv(str + len + 1, 256)); + ST(0) = sv_2mortal(newSVpvn(str + len + 1, 256)); MODULE = B PACKAGE = B::GV PREFIX = Gv @@ -1021,7 +1021,7 @@ void GvNAME(gv) B::GV gv CODE: - ST(0) = sv_2mortal(newSVpv(GvNAME(gv), GvNAMELEN(gv))); + ST(0) = sv_2mortal(newSVpvn(GvNAME(gv), GvNAMELEN(gv))); B::HV GvSTASH(gv) @@ -1257,7 +1257,7 @@ HvARRAY(hv) (void)hv_iterinit(hv); EXTEND(sp, HvKEYS(hv) * 2); while (sv = hv_iternextsv(hv, &key, &len)) { - PUSHs(newSVpv(key, len)); + PUSHs(newSVpvn(key, len)); PUSHs(make_sv_object(sv_newmortal(), sv)); } } diff --git a/ext/B/defsubs.h.PL b/ext/B/defsubs.h.PL index c24eb94..94ca5b3 100644 --- a/ext/B/defsubs.h.PL +++ b/ext/B/defsubs.h.PL @@ -29,6 +29,6 @@ sub doconst my $l = length($sym); print OUT <<"END"; newCONSTSUB(stash,"$sym",newSViv($sym)); - av_push(export_ok,newSVpv("$sym",$l)); + av_push(export_ok,newSVpvn("$sym",$l)); END } diff --git a/ext/DB_File/DB_File.xs b/ext/DB_File/DB_File.xs index 94113eb..3f6c094 100644 --- a/ext/DB_File/DB_File.xs +++ b/ext/DB_File/DB_File.xs @@ -382,7 +382,7 @@ const DBT * key2 ; data1 = key1->data ; data2 = key2->data ; - +#if 0 /* As newSVpv will assume that the data pointer is a null terminated C string if the size parameter is 0, make sure that data points to an empty string if the length is 0 @@ -391,14 +391,14 @@ const DBT * key2 ; data1 = "" ; if (key2->size == 0) data2 = "" ; - +#endif ENTER ; SAVETMPS; PUSHMARK(SP) ; EXTEND(SP,2) ; - PUSHs(sv_2mortal(newSVpv(data1,key1->size))); - PUSHs(sv_2mortal(newSVpv(data2,key2->size))); + PUSHs(sv_2mortal(newSVpvn(data1,key1->size))); + PUSHs(sv_2mortal(newSVpvn(data2,key2->size))); PUTBACK ; count = perl_call_sv(CurrentDB->compare, G_SCALAR); @@ -429,7 +429,7 @@ const DBT * key2 ; data1 = key1->data ; data2 = key2->data ; - +#if 0 /* As newSVpv will assume that the data pointer is a null terminated C string if the size parameter is 0, make sure that data points to an empty string if the length is 0 @@ -438,14 +438,14 @@ const DBT * key2 ; data1 = "" ; if (key2->size == 0) data2 = "" ; - +#endif ENTER ; SAVETMPS; PUSHMARK(SP) ; EXTEND(SP,2) ; - PUSHs(sv_2mortal(newSVpv(data1,key1->size))); - PUSHs(sv_2mortal(newSVpv(data2,key2->size))); + PUSHs(sv_2mortal(newSVpvn(data1,key1->size))); + PUSHs(sv_2mortal(newSVpvn(data2,key2->size))); PUTBACK ; count = perl_call_sv(CurrentDB->prefix, G_SCALAR); @@ -472,17 +472,17 @@ size_t size ; dSP ; int retval ; int count ; - +#if 0 if (size == 0) data = "" ; - +#endif /* DGH - Next two lines added to fix corrupted stack problem */ ENTER ; SAVETMPS; PUSHMARK(SP) ; - XPUSHs(sv_2mortal(newSVpv((char*)data,size))); + XPUSHs(sv_2mortal(newSVpvn((char*)data,size))); PUTBACK ; count = perl_call_sv(CurrentDB->hash, G_SCALAR); diff --git a/ext/DynaLoader/dl_vms.xs b/ext/DynaLoader/dl_vms.xs index 08fd2f3..2a9ba3c 100644 --- a/ext/DynaLoader/dl_vms.xs +++ b/ext/DynaLoader/dl_vms.xs @@ -216,7 +216,7 @@ dl_expandspec(filespec) ST(0) = &PL_sv_undef; } else { - ST(0) = sv_2mortal(newSVpv(dlnam.nam$l_rsa,dlnam.nam$b_rsl)); + ST(0) = sv_2mortal(newSVpvn(dlnam.nam$l_rsa,dlnam.nam$b_rsl)); DLDEBUG(1,PerlIO_printf(PerlIO_stderr(), "\tresult = \\%.*s\\\n", dlnam.nam$b_rsl,dlnam.nam$l_rsa)); } diff --git a/ext/IPC/SysV/SysV.xs b/ext/IPC/SysV/SysV.xs index 0aaf052..dbed151 100644 --- a/ext/IPC/SysV/SysV.xs +++ b/ext/IPC/SysV/SysV.xs @@ -69,7 +69,7 @@ PPCODE: sv = *av_fetch(list,1,TRUE); ds.msg_perm.gid = SvIV(sv); sv = *av_fetch(list,4,TRUE); ds.msg_perm.mode = SvIV(sv); sv = *av_fetch(list,6,TRUE); ds.msg_qbytes = SvIV(sv); - ST(0) = sv_2mortal(newSVpv((char *)&ds,sizeof(ds))); + ST(0) = sv_2mortal(newSVpvn((char *)&ds,sizeof(ds))); XSRETURN(1); #else croak("System V msgxxx is not implemented on this machine"); @@ -185,7 +185,7 @@ PPCODE: ds.sem_otime = SvIV(*sv_ptr); if((sv_ptr = av_fetch(list,7,TRUE)) && (sv = *sv_ptr)) ds.sem_nsems = SvIV(*sv_ptr); - ST(0) = sv_2mortal(newSVpv((char *)&ds,sizeof(ds))); + ST(0) = sv_2mortal(newSVpvn((char *)&ds,sizeof(ds))); XSRETURN(1); #else croak("System V semxxx is not implemented on this machine"); diff --git a/ext/Opcode/Opcode.xs b/ext/Opcode/Opcode.xs index e93b900..648ee91 100644 --- a/ext/Opcode/Opcode.xs +++ b/ext/Opcode/Opcode.xs @@ -388,7 +388,7 @@ PPCODE: char **op_desc = get_op_descs(); /* copy args to a scratch area since we may push output values onto */ /* the stack faster than we read values off it if masks are used. */ - args = (SV**)SvPVX(sv_2mortal(newSVpv((char*)&ST(0), items*sizeof(SV*)))); + args = (SV**)SvPVX(sv_2mortal(newSVpvn((char*)&ST(0), items*sizeof(SV*)))); for (i = 0; i < items; i++) { char *opname = SvPV(args[i], len); SV *bitspec = get_op_bitspec(opname, len, 1); diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index bd5cb72..59e937e 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -3662,10 +3662,10 @@ strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) Renew(buf, bufsize, char); } if ( buf ) { - ST(0) = sv_2mortal(newSVpv(buf, buflen)); + ST(0) = sv_2mortal(newSVpvn(buf, buflen)); Safefree(buf); } else { - ST(0) = sv_2mortal(newSVpv(tmpbuf, len)); + ST(0) = sv_2mortal(newSVpvn(tmpbuf, len)); } } } @@ -3677,8 +3677,8 @@ void tzname() PPCODE: EXTEND(SP,2); - PUSHs(sv_2mortal(newSVpv(tzname[0],strlen(tzname[0])))); - PUSHs(sv_2mortal(newSVpv(tzname[1],strlen(tzname[1])))); + PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0])))); + PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1])))); SysRet access(filename, mode) diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs index 3049948..4a8d876 100644 --- a/ext/Socket/Socket.xs +++ b/ext/Socket/Socket.xs @@ -879,7 +879,7 @@ inet_ntoa(ip_address_sv) Copy( ip_address, &addr, sizeof addr, char ); addr_str = inet_ntoa(addr); - ST(0) = sv_2mortal(newSVpv(addr_str, strlen(addr_str))); + ST(0) = sv_2mortal(newSVpvn(addr_str, strlen(addr_str))); } void @@ -896,7 +896,7 @@ pack_sockaddr_un(pathname) if (len > sizeof(sun_ad.sun_path)) len = sizeof(sun_ad.sun_path); Copy( pathname, sun_ad.sun_path, len, char ); - ST(0) = sv_2mortal(newSVpv((char *)&sun_ad, sizeof sun_ad)); + ST(0) = sv_2mortal(newSVpvn((char *)&sun_ad, sizeof sun_ad)); #else ST(0) = (SV *) not_here("pack_sockaddr_un"); #endif @@ -931,7 +931,7 @@ unpack_sockaddr_un(sun_sv) e = addr.sun_path; while (*e && e < addr.sun_path + sizeof addr.sun_path) ++e; - ST(0) = sv_2mortal(newSVpv(addr.sun_path, e - addr.sun_path)); + ST(0) = sv_2mortal(newSVpvn(addr.sun_path, e - addr.sun_path)); #else ST(0) = (SV *) not_here("unpack_sockaddr_un"); #endif @@ -950,7 +950,7 @@ pack_sockaddr_in(port,ip_address) sin.sin_port = htons(port); Copy( ip_address, &sin.sin_addr, sizeof sin.sin_addr, char ); - ST(0) = sv_2mortal(newSVpv((char *)&sin, sizeof sin)); + ST(0) = sv_2mortal(newSVpvn((char *)&sin, sizeof sin)); } void @@ -980,7 +980,7 @@ unpack_sockaddr_in(sin_sv) EXTEND(SP, 2); PUSHs(sv_2mortal(newSViv((IV) port))); - PUSHs(sv_2mortal(newSVpv((char *)&ip_address,sizeof ip_address))); + PUSHs(sv_2mortal(newSVpvn((char *)&ip_address,sizeof ip_address))); } void @@ -989,7 +989,7 @@ INADDR_ANY() { struct in_addr ip_address; ip_address.s_addr = htonl(INADDR_ANY); - ST(0) = sv_2mortal(newSVpv((char *)&ip_address,sizeof ip_address )); + ST(0) = sv_2mortal(newSVpvn((char *)&ip_address,sizeof ip_address )); } void @@ -998,7 +998,7 @@ INADDR_LOOPBACK() { struct in_addr ip_address; ip_address.s_addr = htonl(INADDR_LOOPBACK); - ST(0) = sv_2mortal(newSVpv((char *)&ip_address,sizeof ip_address)); + ST(0) = sv_2mortal(newSVpvn((char *)&ip_address,sizeof ip_address)); } void @@ -1007,7 +1007,7 @@ INADDR_NONE() { struct in_addr ip_address; ip_address.s_addr = htonl(INADDR_NONE); - ST(0) = sv_2mortal(newSVpv((char *)&ip_address,sizeof ip_address)); + ST(0) = sv_2mortal(newSVpvn((char *)&ip_address,sizeof ip_address)); } void @@ -1016,5 +1016,5 @@ INADDR_BROADCAST() { struct in_addr ip_address; ip_address.s_addr = htonl(INADDR_BROADCAST); - ST(0) = sv_2mortal(newSVpv((char *)&ip_address,sizeof ip_address)); + ST(0) = sv_2mortal(newSVpvn((char *)&ip_address,sizeof ip_address)); } diff --git a/ext/attrs/attrs.xs b/ext/attrs/attrs.xs index 7f7970d..4e0afb0 100644 --- a/ext/attrs/attrs.xs +++ b/ext/attrs/attrs.xs @@ -55,7 +55,7 @@ SV * sub if (!sub) croak("invalid subroutine reference or name"); if (CvFLAGS(sub) & CVf_METHOD) - XPUSHs(sv_2mortal(newSVpv("method", 0))); + XPUSHs(sv_2mortal(newSVpvn("method", 6))); if (CvFLAGS(sub) & CVf_LOCKED) - XPUSHs(sv_2mortal(newSVpv("locked", 0))); + XPUSHs(sv_2mortal(newSVpvn("locked", 6))); diff --git a/gv.c b/gv.c index 9dc883e..b2941c3 100644 --- a/gv.c +++ b/gv.c @@ -635,15 +635,15 @@ gv_fetchpv(const char *nambeg, I32 add, I32 sv_type) && AvFILLp(av) == -1) { char *pname; - av_push(av, newSVpv(pname = "NDBM_File",0)); + av_push(av, newSVpvn(pname = "NDBM_File",9)); gv_stashpvn(pname, 9, TRUE); - av_push(av, newSVpv(pname = "DB_File",0)); + av_push(av, newSVpvn(pname = "DB_File",7)); gv_stashpvn(pname, 7, TRUE); - av_push(av, newSVpv(pname = "GDBM_File",0)); + av_push(av, newSVpvn(pname = "GDBM_File",9)); gv_stashpvn(pname, 9, TRUE); - av_push(av, newSVpv(pname = "SDBM_File",0)); + av_push(av, newSVpvn(pname = "SDBM_File",9)); gv_stashpvn(pname, 9, TRUE); - av_push(av, newSVpv(pname = "ODBM_File",0)); + av_push(av, newSVpvn(pname = "ODBM_File",9)); gv_stashpvn(pname, 9, TRUE); } } diff --git a/hv.c b/hv.c index 3fd0fd7..5a42d2f 100644 --- a/hv.c +++ b/hv.c @@ -114,7 +114,7 @@ hv_fetch(HV *hv, const char *key, U32 klen, I32 lval) U32 i; for (i = 0; i < klen; ++i) if (isLOWER(key[i])) { - char *nkey = strupr(SvPVX(sv_2mortal(newSVpv(key,klen)))); + char *nkey = strupr(SvPVX(sv_2mortal(newSVpvn(key,klen)))); SV **ret = hv_fetch(hv, nkey, klen, 0); if (!ret && lval) ret = hv_store(hv, key, klen, NEWSV(61,0), 0); @@ -153,7 +153,7 @@ hv_fetch(HV *hv, const char *key, U32 klen, I32 lval) char *gotenv; if ((gotenv = PerlEnv_getenv(key)) != Nullch) { - sv = newSVpv(gotenv,strlen(gotenv)); + sv = newSVpvn(gotenv,strlen(gotenv)); SvTAINTED_on(sv); return hv_store(hv,key,klen,sv,hash); } @@ -201,7 +201,7 @@ hv_fetch_ent(HV *hv, SV *keysv, I32 lval, register U32 hash) key = SvPV(keysv, klen); for (i = 0; i < klen; ++i) if (isLOWER(key[i])) { - SV *nkeysv = sv_2mortal(newSVpv(key,klen)); + SV *nkeysv = sv_2mortal(newSVpvn(key,klen)); (void)strupr(SvPVX(nkeysv)); entry = hv_fetch_ent(hv, nkeysv, 0, 0); if (!entry && lval) @@ -244,7 +244,7 @@ hv_fetch_ent(HV *hv, SV *keysv, I32 lval, register U32 hash) char *gotenv; if ((gotenv = PerlEnv_getenv(key)) != Nullch) { - sv = newSVpv(gotenv,strlen(gotenv)); + sv = newSVpvn(gotenv,strlen(gotenv)); SvTAINTED_on(sv); return hv_store_ent(hv,keysv,sv,hash); } @@ -298,7 +298,7 @@ hv_store(HV *hv, const char *key, U32 klen, SV *val, register U32 hash) return 0; #ifdef ENV_IS_CASELESS else if (mg_find((SV*)hv,'E')) { - SV *sv = sv_2mortal(newSVpv(key,klen)); + SV *sv = sv_2mortal(newSVpvn(key,klen)); key = strupr(SvPVX(sv)); hash = 0; } @@ -376,7 +376,7 @@ hv_store_ent(HV *hv, SV *keysv, SV *val, register U32 hash) #ifdef ENV_IS_CASELESS else if (mg_find((SV*)hv,'E')) { key = SvPV(keysv, klen); - keysv = sv_2mortal(newSVpv(key,klen)); + keysv = sv_2mortal(newSVpvn(key,klen)); (void)strupr(SvPVX(keysv)); hash = 0; } @@ -456,7 +456,7 @@ hv_delete(HV *hv, const char *key, U32 klen, I32 flags) } #ifdef ENV_IS_CASELESS else if (mg_find((SV*)hv,'E')) { - sv = sv_2mortal(newSVpv(key,klen)); + sv = sv_2mortal(newSVpvn(key,klen)); key = strupr(SvPVX(sv)); } #endif @@ -526,7 +526,7 @@ hv_delete_ent(HV *hv, SV *keysv, I32 flags, U32 hash) #ifdef ENV_IS_CASELESS else if (mg_find((SV*)hv,'E')) { key = SvPV(keysv, klen); - keysv = sv_2mortal(newSVpv(key,klen)); + keysv = sv_2mortal(newSVpvn(key,klen)); (void)strupr(SvPVX(keysv)); hash = 0; } @@ -590,7 +590,7 @@ hv_exists(HV *hv, const char *key, U32 klen) } #ifdef ENV_IS_CASELESS else if (mg_find((SV*)hv,'E')) { - sv = sv_2mortal(newSVpv(key,klen)); + sv = sv_2mortal(newSVpvn(key,klen)); key = strupr(SvPVX(sv)); } #endif @@ -640,7 +640,7 @@ hv_exists_ent(HV *hv, SV *keysv, U32 hash) #ifdef ENV_IS_CASELESS else if (mg_find((SV*)hv,'E')) { key = SvPV(keysv, klen); - keysv = sv_2mortal(newSVpv(key,klen)); + keysv = sv_2mortal(newSVpvn(key,klen)); (void)strupr(SvPVX(keysv)); hash = 0; } @@ -1091,7 +1091,7 @@ hv_iterkeysv(register HE *entry) if (HeKLEN(entry) == HEf_SVKEY) return sv_mortalcopy(HeKEY_sv(entry)); else - return sv_2mortal(newSVpv((HeKLEN(entry) ? HeKEY(entry) : ""), + return sv_2mortal(newSVpvn((HeKLEN(entry) ? HeKEY(entry) : ""), HeKLEN(entry))); } diff --git a/hv.h b/hv.h index 5f56c1e..e9772d4 100644 --- a/hv.h +++ b/hv.h @@ -104,7 +104,7 @@ struct xpvhv { #define HeSVKEY_force(he) (HeKEY(he) ? \ ((HeKLEN(he) == HEf_SVKEY) ? \ HeKEY_sv(he) : \ - sv_2mortal(newSVpv(HeKEY(he), \ + sv_2mortal(newSVpvn(HeKEY(he), \ HeKLEN(he)))) : \ &PL_sv_undef) #define HeSVKEY_set(he,sv) ((HeKLEN(he) = HEf_SVKEY), (HeKEY_sv(he) = sv)) diff --git a/jpl/JNI/JNI.xs b/jpl/JNI/JNI.xs index 080e10f..97416db 100644 --- a/jpl/JNI/JNI.xs +++ b/jpl/JNI/JNI.xs @@ -2518,7 +2518,7 @@ GetBooleanArrayElements(array) } else { if (RETVAL_len_) { - PUSHs(sv_2mortal(newSVpv((char*)RETVAL, + PUSHs(sv_2mortal(newSVpvn((char*)RETVAL, (STRLEN)RETVAL_len_ * sizeof(jboolean)))); } else @@ -2548,7 +2548,7 @@ GetByteArrayElements(array) } else { if (RETVAL_len_) { - PUSHs(sv_2mortal(newSVpv((char*)RETVAL, + PUSHs(sv_2mortal(newSVpvn((char*)RETVAL, (STRLEN)RETVAL_len_ * sizeof(jbyte)))); } else @@ -2578,7 +2578,7 @@ GetCharArrayElements(array) } else { if (RETVAL_len_) { - PUSHs(sv_2mortal(newSVpv((char*)RETVAL, + PUSHs(sv_2mortal(newSVpvn((char*)RETVAL, (STRLEN)RETVAL_len_ * sizeof(jchar)))); } else @@ -2608,7 +2608,7 @@ GetShortArrayElements(array) } else { if (RETVAL_len_) { - PUSHs(sv_2mortal(newSVpv((char*)RETVAL, + PUSHs(sv_2mortal(newSVpvn((char*)RETVAL, (STRLEN)RETVAL_len_ * sizeof(jshort)))); } else @@ -2638,7 +2638,7 @@ GetIntArrayElements(array) } else { if (RETVAL_len_) { - PUSHs(sv_2mortal(newSVpv((char*)RETVAL, + PUSHs(sv_2mortal(newSVpvn((char*)RETVAL, (STRLEN)RETVAL_len_ * sizeof(jint)))); } else @@ -2668,7 +2668,7 @@ GetLongArrayElements(array) } else { if (RETVAL_len_) { - PUSHs(sv_2mortal(newSVpv((char*)RETVAL, + PUSHs(sv_2mortal(newSVpvn((char*)RETVAL, (STRLEN)RETVAL_len_ * sizeof(jlong)))); } else @@ -2698,7 +2698,7 @@ GetFloatArrayElements(array) } else { if (RETVAL_len_) { - PUSHs(sv_2mortal(newSVpv((char*)RETVAL, + PUSHs(sv_2mortal(newSVpvn((char*)RETVAL, (STRLEN)RETVAL_len_ * sizeof(jfloat)))); } else @@ -2728,7 +2728,7 @@ GetDoubleArrayElements(array) } else { if (RETVAL_len_) { - PUSHs(sv_2mortal(newSVpv((char*)RETVAL, + PUSHs(sv_2mortal(newSVpvn((char*)RETVAL, (STRLEN)RETVAL_len_ * sizeof(jdouble)))); } else diff --git a/mg.c b/mg.c index a9c137b..3584dbc 100644 --- a/mg.c +++ b/mg.c @@ -1093,7 +1093,7 @@ magic_methcall(SV *sv, MAGIC *mg, char *meth, I32 flags, int n, SV *val) if (n > 1) { if (mg->mg_ptr) { if (mg->mg_len >= 0) - PUSHs(sv_2mortal(newSVpv(mg->mg_ptr, mg->mg_len))); + PUSHs(sv_2mortal(newSVpvn(mg->mg_ptr, mg->mg_len))); else if (mg->mg_len == HEf_SVKEY) PUSHs((SV*)mg->mg_ptr); } diff --git a/op.c b/op.c index d5af3c9..635a04a 100644 --- a/op.c +++ b/op.c @@ -2189,7 +2189,7 @@ pmtrans(OP *o, OP *expr, OP *repl) squash = o->op_private & OPpTRANS_SQUASH; if (o->op_private & (OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF)) { - SV* listsv = newSVpv("# comment\n",0); + SV* listsv = newSVpvn("# comment\n",10); SV* transv = 0; U8* tend = t + tlen; U8* rend = r + rlen; @@ -2217,7 +2217,7 @@ pmtrans(OP *o, OP *expr, OP *repl) UV nextmin = 0; New(1109, cp, tlen, U8*); i = 0; - transv = newSVpv("",0); + transv = newSVpvn("",0); while (t < tend) { cp[i++] = t; t += UTF8SKIP(t); @@ -2706,7 +2706,7 @@ utilize(int aver, I32 floor, OP *version, OP *id, OP *arg) pack = newSVOP(OP_CONST, 0, newSVsv(((SVOP*)id)->op_sv)); /* Fake up a method call to VERSION */ - meth = newSVOP(OP_CONST, 0, newSVpv("VERSION", 7)); + meth = newSVOP(OP_CONST, 0, newSVpvn("VERSION", 7)); veop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL, append_elem(OP_LIST, prepend_elem(OP_LIST, pack, list(version)), @@ -2725,8 +2725,8 @@ utilize(int aver, I32 floor, OP *version, OP *id, OP *arg) pack = newSVOP(OP_CONST, 0, newSVsv(((SVOP*)id)->op_sv)); meth = newSVOP(OP_CONST, 0, aver - ? newSVpv("import", 6) - : newSVpv("unimport", 8) + ? newSVpvn("import", 6) + : newSVpvn("unimport", 8) ); imop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL, append_elem(OP_LIST, @@ -2752,7 +2752,7 @@ utilize(int aver, I32 floor, OP *version, OP *id, OP *arg) /* Fake up the BEGIN {}, which does its thing immediately. */ newSUB(floor, - newSVOP(OP_CONST, 0, newSVpv("BEGIN", 5)), + newSVOP(OP_CONST, 0, newSVpvn("BEGIN", 5)), Nullop, append_elem(OP_LINESEQ, append_elem(OP_LINESEQ, @@ -5235,7 +5235,7 @@ ck_split(OP *o) op_free(cLISTOPo->op_first); cLISTOPo->op_first = kid; if (!kid) { - cLISTOPo->op_first = kid = newSVOP(OP_CONST, 0, newSVpv(" ", 1)); + cLISTOPo->op_first = kid = newSVOP(OP_CONST, 0, newSVpvn(" ", 1)); cLISTOPo->op_last = kid; /* There was only one element previously */ } diff --git a/perl.c b/perl.c index e7bfe7e..5321eff 100644 --- a/perl.c +++ b/perl.c @@ -187,7 +187,7 @@ perl_construct(register PerlInterpreter *sv_interp) #endif } - PL_nrs = newSVpv("\n", 1); + PL_nrs = newSVpvn("\n", 1); PL_rs = SvREFCNT_inc(PL_nrs); init_stacks(ARGS); @@ -716,7 +716,7 @@ setuid perl scripts securely.\n"); } sv_setpvn(PL_linestr,"",0); - sv = newSVpv("",0); /* first used for -I flags */ + sv = newSVpvn("",0); /* first used for -I flags */ SAVEFREESV(sv); init_main_stash(); @@ -769,7 +769,7 @@ setuid perl scripts securely.\n"); if (PL_euid != PL_uid || PL_egid != PL_gid) croak("No -e allowed in setuid scripts"); if (!PL_e_script) { - PL_e_script = newSVpv("",0); + PL_e_script = newSVpvn("",0); filter_add(read_e_script, NULL); } if (*++s) @@ -953,7 +953,7 @@ print \" \\@INC:\\n @INC\\n\";"); PL_min_intro_pending = 0; PL_padix = 0; #ifdef USE_THREADS - av_store(PL_comppad_name, 0, newSVpv("@_", 2)); + av_store(PL_comppad_name, 0, newSVpvn("@_", 2)); PL_curpad[0] = (SV*)newAV(); SvPADMY_on(PL_curpad[0]); /* XXX Needed? */ CvOWNER(PL_compcv) = 0; @@ -1555,10 +1555,10 @@ moreswitches(char *s) if (rschar & ~((U8)~0)) PL_nrs = &PL_sv_undef; else if (!rschar && numlen >= 2) - PL_nrs = newSVpv("", 0); + PL_nrs = newSVpvn("", 0); else { char ch = rschar; - PL_nrs = newSVpv(&ch, 1); + PL_nrs = newSVpvn(&ch, 1); } return s + numlen; } @@ -1942,7 +1942,7 @@ init_main_stash(void) hv_ksplit(PL_strtab, 512); PL_curstash = PL_defstash = newHV(); - PL_curstname = newSVpv("main",4); + PL_curstname = newSVpvn("main",4); gv = gv_fetchpv("main::",TRUE, SVt_PVHV); SvREFCNT_dec(GvHV(gv)); GvHV(gv) = (HV*)SvREFCNT_inc(PL_defstash); @@ -2008,7 +2008,7 @@ open_script(char *scriptname, bool dosearch, SV *sv, int *fdscript) } else if (PL_preprocess) { char *cpp_cfg = CPPSTDIN; - SV *cpp = newSVpv("",0); + SV *cpp = newSVpvn("",0); SV *cmd = NEWSV(0,0); if (strEQ(cpp_cfg, "cppstdin")) @@ -2596,7 +2596,7 @@ init_lexer(void) PL_rsfp = Nullfp; lex_start(PL_linestr); PL_rsfp = tmpfp; - PL_subname = newSVpv("main",4); + PL_subname = newSVpvn("main",4); } STATIC void @@ -2825,7 +2825,7 @@ incpush(char *p, int addsubdirs) /* skip any consecutive separators */ while ( *p == PERLLIB_SEP ) { /* Uncomment the next line for PATH semantics */ - /* av_push(GvAVn(PL_incgv), newSVpv(".", 1)); */ + /* av_push(GvAVn(PL_incgv), newSVpvn(".", 1)); */ p++; } @@ -2865,7 +2865,7 @@ incpush(char *p, int addsubdirs) if (PerlLIO_stat(SvPVX(subdir), &tmpstatbuf) >= 0 && S_ISDIR(tmpstatbuf.st_mode)) av_push(GvAVn(PL_incgv), - newSVpv(SvPVX(subdir), SvCUR(subdir) - sizeof "auto")); + newSVpvn(SvPVX(subdir), SvCUR(subdir) - sizeof "auto")); /* .../archname if -d .../archname/auto */ sv_insert(subdir, SvCUR(libdir) + sizeof(ARCHNAME), @@ -2873,7 +2873,7 @@ incpush(char *p, int addsubdirs) if (PerlLIO_stat(SvPVX(subdir), &tmpstatbuf) >= 0 && S_ISDIR(tmpstatbuf.st_mode)) av_push(GvAVn(PL_incgv), - newSVpv(SvPVX(subdir), SvCUR(subdir) - sizeof "auto")); + newSVpvn(SvPVX(subdir), SvCUR(subdir) - sizeof "auto")); } /* finally push this lib directory on the end of @INC */ @@ -2940,7 +2940,7 @@ init_main_thread() sv_upgrade(PL_bodytarget, SVt_PVFM); sv_setpvn(PL_bodytarget, "", 0); PL_formtarget = PL_bodytarget; - thr->errsv = newSVpv("", 0); + thr->errsv = newSVpvn("", 0); (void) find_threadsv("@"); /* Ensure $@ is initialised early */ PL_maxscream = -1; diff --git a/pod/perlguts.pod b/pod/perlguts.pod index c5289a1..b71337c 100644 --- a/pod/perlguts.pod +++ b/pod/perlguts.pod @@ -2286,7 +2286,8 @@ SV is set to 1. =item newSVpv Creates a new SV and copies a string into it. The reference count for the -SV is set to 1. If C is zero then Perl will compute the length. +SV is set to 1. If C is zero, Perl will compute the length using +strlen(). For efficiency, consider using C instead. SV* newSVpv (const char* s, STRLEN len) @@ -2295,13 +2296,14 @@ SV is set to 1. If C is zero then Perl will compute the length. Creates a new SV an initialize it with the string formatted like C. - SV* newSVpvf(const char* pat, ...); + SV* newSVpvf(const char* pat, ...) =item newSVpvn Creates a new SV and copies a string into it. The reference count for the -SV is set to 1. If C is zero then Perl will create a zero length -string. +SV is set to 1. Note that if C is zero, Perl will create a zero length +string. You are responsible for ensuring that the source string is at least +C bytes long. SV* newSVpvn (const char* s, STRLEN len) diff --git a/pp.c b/pp.c index 207a72d..d837d4b 100644 --- a/pp.c +++ b/pp.c @@ -448,7 +448,7 @@ PP(pp_prototype) oa = oa >> 4; } str[n++] = '\0'; - ret = sv_2mortal(newSVpv(str, n - 1)); + ret = sv_2mortal(newSVpvn(str, n - 1)); } else if (code) /* Non-Overridable */ goto set; @@ -460,7 +460,7 @@ PP(pp_prototype) } cv = sv_2cv(TOPs, &stash, &gv, FALSE); if (cv && SvPOK(cv)) - ret = sv_2mortal(newSVpv(SvPVX(cv), SvCUR(cv))); + ret = sv_2mortal(newSVpvn(SvPVX(cv), SvCUR(cv))); set: SETs(ret); RETURN; @@ -609,7 +609,7 @@ PP(pp_gelem) break; case 'N': if (strEQ(elem, "NAME")) - sv = newSVpv(GvNAME(gv), GvNAMELEN(gv)); + sv = newSVpvn(GvNAME(gv), GvNAMELEN(gv)); break; case 'P': if (strEQ(elem, "PACKAGE")) @@ -3171,7 +3171,7 @@ mul128(SV *sv, U8 m) U32 i = 0; if (!strnEQ(s, "0000", 4)) { /* need to grow sv */ - SV *tmpNew = newSVpv("0000000000", 10); + SV *tmpNew = newSVpvn("0000000000", 10); sv_catsv(tmpNew, sv); SvREFCNT_dec(sv); /* free old sv */ @@ -4161,11 +4161,11 @@ doencodes(register SV *sv, register char *s, register I32 len) sv_catpvn(sv, "\n", 1); } -STATIC SV * +STATIC SV * is_an_int(char *s, STRLEN l) { STRLEN n_a; - SV *result = newSVpv("", l); + SV *result = newSVpvn(s, l); char *result_c = SvPV(result, n_a); /* convenience */ char *out = result_c; bool skip = 1; diff --git a/pp_ctl.c b/pp_ctl.c index da56eca..e29ff19 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -1489,7 +1489,8 @@ PP(pp_caller) PUSHs(&PL_sv_undef); else PUSHs(sv_2mortal(newSVpv(HvNAME(hv), 0))); - PUSHs(sv_2mortal(newSVpv(SvPVX(GvSV(cx->blk_oldcop->cop_filegv)), 0))); + PUSHs(sv_2mortal(newSVpvn(SvPVX(GvSV(cx->blk_oldcop->cop_filegv)), + SvCUR(GvSV(cx->blk_oldcop->cop_filegv))))); PUSHs(sv_2mortal(newSViv((I32)cx->blk_oldcop->cop_line))); if (!MAXARG) RETURN; @@ -1500,7 +1501,7 @@ PP(pp_caller) PUSHs(sv_2mortal(newSViv((I32)cx->blk_sub.hasargs))); } else { - PUSHs(sv_2mortal(newSVpv("(eval)",0))); + PUSHs(sv_2mortal(newSVpvn("(eval)",6))); PUSHs(sv_2mortal(newSViv(0))); } gimme = (I32)cx->blk_gimme; @@ -2637,7 +2638,7 @@ doeval(int gimme, OP** startop) PL_min_intro_pending = 0; PL_padix = 0; #ifdef USE_THREADS - av_store(PL_comppad_name, 0, newSVpv("@_", 2)); + av_store(PL_comppad_name, 0, newSVpvn("@_", 2)); PL_curpad[0] = (SV*)newAV(); SvPADMY_on(PL_curpad[0]); /* XXX Needed? */ #endif /* USE_THREADS */ @@ -2671,7 +2672,7 @@ doeval(int gimme, OP** startop) PL_curcop = &PL_compiling; PL_curcop->cop_arybase = 0; SvREFCNT_dec(PL_rs); - PL_rs = newSVpv("\n", 1); + PL_rs = newSVpvn("\n", 1); if (saveop && saveop->op_flags & OPf_SPECIAL) PL_in_eval |= 4; else @@ -2879,7 +2880,7 @@ PP(pp_require) ENTER; SAVETMPS; - lex_start(sv_2mortal(newSVpv("",0))); + lex_start(sv_2mortal(newSVpvn("",0))); SAVEGENERICSV(PL_rsfp_filters); PL_rsfp_filters = Nullav; diff --git a/pp_sys.c b/pp_sys.c index 00ee2b1..fee8260 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -370,7 +370,7 @@ PP(pp_glob) PL_last_in_gv = (GV*)*PL_stack_sp--; SAVESPTR(PL_rs); /* This is not permanent, either. */ - PL_rs = sv_2mortal(newSVpv("", 1)); + PL_rs = sv_2mortal(newSVpvn("\000", 1)); #ifndef DOSISH #ifndef CSH *SvPVX(PL_rs) = '\n'; @@ -1639,7 +1639,7 @@ PP(pp_sysseek) Off_t n = do_sysseek(gv, offset, whence); PUSHs((n < 0) ? &PL_sv_undef : sv_2mortal(n ? newSViv((IV)n) - : newSVpv(zero_but_true, ZBTLEN))); + : newSVpvn(zero_but_true, ZBTLEN))); } RETURN; } @@ -2332,7 +2332,7 @@ PP(pp_stat) #ifdef USE_STAT_RDEV PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_rdev))); #else - PUSHs(sv_2mortal(newSVpv("", 0))); + PUSHs(sv_2mortal(newSVpvn("", 0))); #endif PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_size))); #ifdef BIG_TIME @@ -2348,8 +2348,8 @@ PP(pp_stat) PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_blksize))); PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_blocks))); #else - PUSHs(sv_2mortal(newSVpv("", 0))); - PUSHs(sv_2mortal(newSVpv("", 0))); + PUSHs(sv_2mortal(newSVpvn("", 0))); + PUSHs(sv_2mortal(newSVpvn("", 0))); #endif } RETURN; @@ -3235,7 +3235,7 @@ PP(pp_readdir) /*SUPPRESS 560*/ while (dp = (Direntry_t *)PerlDir_read(IoDIRP(io))) { #ifdef DIRNAMLEN - sv = newSVpv(dp->d_name, dp->d_namlen); + sv = newSVpvn(dp->d_name, dp->d_namlen); #else sv = newSVpv(dp->d_name, 0); #endif @@ -3249,7 +3249,7 @@ PP(pp_readdir) if (!(dp = (Direntry_t *)PerlDir_read(IoDIRP(io)))) goto nope; #ifdef DIRNAMLEN - sv = newSVpv(dp->d_name, dp->d_namlen); + sv = newSVpvn(dp->d_name, dp->d_namlen); #else sv = newSVpv(dp->d_name, 0); #endif diff --git a/regcomp.c b/regcomp.c index bacf2ca..d8a62da 100644 --- a/regcomp.c +++ b/regcomp.c @@ -616,7 +616,7 @@ study_chunk(regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32 l -= old; /* Get the added string: */ - last_str = newSVpv(s + old, l); + last_str = newSVpvn(s + old, l); if (deltanext == 0 && pos_before == b) { /* What was added is a constant string */ if (mincount > 1) { @@ -977,9 +977,9 @@ pregcomp(char *exp, char *xend, PMOP *pm) */ minlen = 0; - data.longest_fixed = newSVpv("",0); - data.longest_float = newSVpv("",0); - data.last_found = newSVpv("",0); + data.longest_fixed = newSVpvn("",0); + data.longest_float = newSVpvn("",0); + data.last_found = newSVpvn("",0); data.longest = &(data.longest_fixed); first = scan; @@ -1166,9 +1166,9 @@ reg(I32 paren, I32 *flagp) AV *av; if (PL_regcomp_parse - 1 - s) - sv = newSVpv(s, PL_regcomp_parse - 1 - s); + sv = newSVpvn(s, PL_regcomp_parse - 1 - s); else - sv = newSVpv("", 0); + sv = newSVpvn("", 0); rop = sv_compile_2op(sv, &sop, "re", &av); @@ -2378,7 +2378,7 @@ regclassutf8(void) flags |= ANYOF_FOLD; if (LOC) flags |= ANYOF_LOCALE; - listsv = newSVpv("# comment\n",0); + listsv = newSVpvn("# comment\n",10); } if (*PL_regcomp_parse == ']' || *PL_regcomp_parse == '-') diff --git a/toke.c b/toke.c index 5ad891b..4803bc8 100644 --- a/toke.c +++ b/toke.c @@ -363,7 +363,7 @@ lex_start(SV *line) PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = PL_linestart = SvPVX(PL_linestr); PL_bufend = PL_bufptr + SvCUR(PL_linestr); SvREFCNT_dec(PL_rs); - PL_rs = newSVpv("\n", 1); + PL_rs = newSVpvn("\n", 1); PL_rsfp = 0; } @@ -683,7 +683,7 @@ tokeq(SV *sv) goto finish; d = s; if ( PL_hints & HINT_NEW_STRING ) - pv = sv_2mortal(newSVpv(SvPVX(pv), len)); + pv = sv_2mortal(newSVpvn(SvPVX(pv), len)); while (s < send) { if (*s == '\\') { if (s + 1 < send && (s[1] == '\\')) @@ -719,7 +719,7 @@ sublex_start(void) SV *nsv; p = SvPV(sv, len); - nsv = newSVpv(p, len); + nsv = newSVpvn(p, len); SvREFCNT_dec(sv); sv = nsv; } @@ -801,7 +801,7 @@ sublex_done(void) { if (!PL_lex_starts++) { PL_expect = XOPERATOR; - yylval.opval = (OP*)newSVOP(OP_CONST, 0, newSVpv("",0)); + yylval.opval = (OP*)newSVOP(OP_CONST, 0, newSVpvn("",0)); return THING; } @@ -1411,7 +1411,7 @@ intuit_method(char *start, GV *gv) return 0; /* no assumptions -- "=>" quotes bearword */ bare_package: PL_nextval[PL_nexttoke].opval = (OP*)newSVOP(OP_CONST, 0, - newSVpv(tmpbuf,0)); + newSVpvn(tmpbuf,len)); PL_nextval[PL_nexttoke].opval->op_private = OPpCONST_BARE; PL_expect = XTERM; force_next(WORD); @@ -3129,7 +3129,7 @@ int yylex(PERL_YYLEX_PARAM_DECL) /* if we saw a global override before, get the right name */ if (gvp) { - sv = newSVpv("CORE::GLOBAL::",14); + sv = newSVpvn("CORE::GLOBAL::",14); sv_catpv(sv,PL_tokenbuf); } else @@ -5011,7 +5011,7 @@ new_constant(char *s, STRLEN len, char *key, SV *sv, SV *pv, char *type) sv_2mortal(sv); /* Parent created it permanently */ cv = *cvp; if (!pv) - pv = sv_2mortal(newSVpv(s, len)); + pv = sv_2mortal(newSVpvn(s, len)); if (type) typesv = sv_2mortal(newSVpv(type, 0)); else @@ -5356,7 +5356,7 @@ scan_subst(char *start) PL_sublex_info.super_bufend = PL_bufend; PL_multi_end = 0; pm->op_pmflags |= PMf_EVAL; - repl = newSVpv("",0); + repl = newSVpvn("",0); while (es-- > 0) sv_catpv(repl, es ? "eval " : "do "); sv_catpvn(repl, "{ ", 2); @@ -5524,9 +5524,9 @@ scan_heredoc(register char *s) #endif d = "\n"; if (outer || !(d=ninstr(s,PL_bufend,d,d+1))) - herewas = newSVpv(s,PL_bufend-s); + herewas = newSVpvn(s,PL_bufend-s); else - s--, herewas = newSVpv(s,d-s); + s--, herewas = newSVpvn(s,d-s); s += SvCUR(herewas); tmpstr = NEWSV(87,79); @@ -6233,7 +6233,7 @@ scan_formline(register char *s) dTHR; register char *eol; register char *t; - SV *stuff = newSVpv("",0); + SV *stuff = newSVpvn("",0); bool needargs = FALSE; while (!needargs) { @@ -6346,7 +6346,7 @@ start_subparse(I32 is_format, U32 flags) PL_padix = 0; PL_subline = PL_curcop->cop_line; #ifdef USE_THREADS - av_store(PL_comppad_name, 0, newSVpv("@_", 2)); + av_store(PL_comppad_name, 0, newSVpvn("@_", 2)); PL_curpad[0] = (SV*)newAV(); SvPADMY_on(PL_curpad[0]); /* XXX Needed? */ #endif /* USE_THREADS */ @@ -6415,7 +6415,7 @@ yyerror(char *s) where = "within string"; } else { - SV *where_sv = sv_2mortal(newSVpv("next char ", 0)); + SV *where_sv = sv_2mortal(newSVpvn("next char ", 10)); if (yychar < 32) sv_catpvf(where_sv, "^%c", toCTRL(yychar)); else if (isPRINT_LC(yychar)) diff --git a/util.c b/util.c index f08a593..0b3673e 100644 --- a/util.c +++ b/util.c @@ -1277,7 +1277,7 @@ die(const char* pat, ...) SV *msg; ENTER; - if(message) { + if (message) { msg = newSVpv(message, 0); SvREADONLY_on(msg); SAVEFREESV(msg); @@ -2840,7 +2840,7 @@ new_struct_thread(struct perl_thread *t) SV **svp; I32 i; - sv = newSVpv("", 0); + sv = newSVpvn("", 0); SvGROW(sv, sizeof(struct perl_thread) + 1); SvCUR_set(sv, sizeof(struct perl_thread)); thr = (Thread) SvPVX(sv); @@ -2864,7 +2864,7 @@ new_struct_thread(struct perl_thread *t) thr->cvcache = newHV(); thr->threadsv = newAV(); thr->specific = newAV(); - thr->errsv = newSVpv("", 0); + thr->errsv = newSVpvn("", 0); thr->errhv = newHV(); thr->flags = THRf_R_JOINABLE; MUTEX_INIT(&thr->mutex); diff --git a/win32/dl_win32.xs b/win32/dl_win32.xs index c650acf..3473520 100644 --- a/win32/dl_win32.xs +++ b/win32/dl_win32.xs @@ -42,7 +42,7 @@ OS_Error_String(CPERLarg) DWORD err = GetLastError(); STRLEN len; if (!error_sv) - error_sv = newSVpv("",0); + error_sv = newSVpvn("",0); win32_str_os_error(error_sv,err); return SvPV(error_sv,len); } diff --git a/win32/win32.c b/win32/win32.c index 5d2bdaa..480dfeb 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2573,7 +2573,7 @@ XS(w32_LoginName) EXTEND(SP,1); if (GetUserName(name,&size)) { /* size includes NULL */ - ST(0) = sv_2mortal(newSVpv(name,size-1)); + ST(0) = sv_2mortal(newSVpvn(name,size-1)); XSRETURN(1); } XSRETURN_UNDEF; @@ -2588,7 +2588,7 @@ XS(w32_NodeName) EXTEND(SP,1); if (GetComputerName(name,&size)) { /* size does NOT include NULL :-( */ - ST(0) = sv_2mortal(newSVpv(name,size)); + ST(0) = sv_2mortal(newSVpvn(name,size)); XSRETURN(1); } XSRETURN_UNDEF; @@ -2648,7 +2648,7 @@ XS(w32_FsType) if (GetVolumeInformation(NULL, NULL, 0, NULL, &filecomplen, &flags, fsname, sizeof(fsname))) { if (GIMME_V == G_ARRAY) { - XPUSHs(sv_2mortal(newSVpv(fsname,0))); + XPUSHs(sv_2mortal(newSVpvn(fsname,strlen(fsname)))); XPUSHs(sv_2mortal(newSViv(flags))); XPUSHs(sv_2mortal(newSViv(filecomplen))); PUTBACK; @@ -2668,7 +2668,7 @@ XS(w32_GetOSVersion) osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (GetVersionEx(&osver)) { - XPUSHs(newSVpv(osver.szCSDVersion, 0)); + XPUSHs(newSVpvn(osver.szCSDVersion, strlen(osver.szCSDVersion))); XPUSHs(newSViv(osver.dwMajorVersion)); XPUSHs(newSViv(osver.dwMinorVersion)); XPUSHs(newSViv(osver.dwBuildNumber));