#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)
#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
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));
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)
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");
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");
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);
}
static SV *
cstring(SV *sv)
{
- SV *sstr = newSVpv("", 0);
+ SV *sstr = newSVpvn("", 0);
STRLEN len;
char *s;
static SV *
cchar(SV *sv)
{
- SV *sstr = newSVpv("'", 0);
+ SV *sstr = newSVpvn("'", 1);
STRLEN n_a;
char *s = SvPV(sv, n_a);
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
*/
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
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
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)
(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));
}
}
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
}
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
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);
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
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);
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);
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));
}
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");
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");
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);
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));
}
}
}
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)
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
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
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
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
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
{
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
{
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
{
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
{
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));
}
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)));
&& 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);
}
}
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);
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);
}
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)
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);
}
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;
}
#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;
}
}
#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
#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;
}
}
#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
#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;
}
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)));
}
#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))
}
else {
if (RETVAL_len_) {
- PUSHs(sv_2mortal(newSVpv((char*)RETVAL,
+ PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
(STRLEN)RETVAL_len_ * sizeof(jboolean))));
}
else
}
else {
if (RETVAL_len_) {
- PUSHs(sv_2mortal(newSVpv((char*)RETVAL,
+ PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
(STRLEN)RETVAL_len_ * sizeof(jbyte))));
}
else
}
else {
if (RETVAL_len_) {
- PUSHs(sv_2mortal(newSVpv((char*)RETVAL,
+ PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
(STRLEN)RETVAL_len_ * sizeof(jchar))));
}
else
}
else {
if (RETVAL_len_) {
- PUSHs(sv_2mortal(newSVpv((char*)RETVAL,
+ PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
(STRLEN)RETVAL_len_ * sizeof(jshort))));
}
else
}
else {
if (RETVAL_len_) {
- PUSHs(sv_2mortal(newSVpv((char*)RETVAL,
+ PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
(STRLEN)RETVAL_len_ * sizeof(jint))));
}
else
}
else {
if (RETVAL_len_) {
- PUSHs(sv_2mortal(newSVpv((char*)RETVAL,
+ PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
(STRLEN)RETVAL_len_ * sizeof(jlong))));
}
else
}
else {
if (RETVAL_len_) {
- PUSHs(sv_2mortal(newSVpv((char*)RETVAL,
+ PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
(STRLEN)RETVAL_len_ * sizeof(jfloat))));
}
else
}
else {
if (RETVAL_len_) {
- PUSHs(sv_2mortal(newSVpv((char*)RETVAL,
+ PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
(STRLEN)RETVAL_len_ * sizeof(jdouble))));
}
else
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);
}
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;
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);
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)),
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,
/* 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,
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 */
}
#endif
}
- PL_nrs = newSVpv("\n", 1);
+ PL_nrs = newSVpvn("\n", 1);
PL_rs = SvREFCNT_inc(PL_nrs);
init_stacks(ARGS);
}
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();
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)
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;
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;
}
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);
}
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"))
PL_rsfp = Nullfp;
lex_start(PL_linestr);
PL_rsfp = tmpfp;
- PL_subname = newSVpv("main",4);
+ PL_subname = newSVpvn("main",4);
}
STATIC void
/* 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++;
}
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),
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 */
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;
=item newSVpv
Creates a new SV and copies a string into it. The reference count for the
-SV is set to 1. If C<len> is zero then Perl will compute the length.
+SV is set to 1. If C<len> is zero, Perl will compute the length using
+strlen(). For efficiency, consider using C<newSVpvn> instead.
SV* newSVpv (const char* s, STRLEN len)
Creates a new SV an initialize it with the string formatted like
C<sprintf>.
- 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<len> is zero then Perl will create a zero length
-string.
+SV is set to 1. Note that if C<len> is zero, Perl will create a zero length
+string. You are responsible for ensuring that the source string is at least
+C<len> bytes long.
SV* newSVpvn (const char* s, STRLEN len)
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;
}
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;
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"))
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 */
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;
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;
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;
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 */
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
ENTER;
SAVETMPS;
- lex_start(sv_2mortal(newSVpv("",0)));
+ lex_start(sv_2mortal(newSVpvn("",0)));
SAVEGENERICSV(PL_rsfp_filters);
PL_rsfp_filters = Nullav;
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';
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;
}
#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
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;
/*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
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
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) {
*/
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;
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);
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 == '-')
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;
}
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] == '\\'))
SV *nsv;
p = SvPV(sv, len);
- nsv = newSVpv(p, len);
+ nsv = newSVpvn(p, len);
SvREFCNT_dec(sv);
sv = nsv;
}
{
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;
}
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);
/* 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
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
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);
#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);
dTHR;
register char *eol;
register char *t;
- SV *stuff = newSVpv("",0);
+ SV *stuff = newSVpvn("",0);
bool needargs = FALSE;
while (!needargs) {
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 */
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))
SV *msg;
ENTER;
- if(message) {
+ if (message) {
msg = newSVpv(message, 0);
SvREADONLY_on(msg);
SAVEFREESV(msg);
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);
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);
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);
}
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;
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;
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;
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));