diff options
-rw-r--r-- | XSUB.h | 2 | ||||
-rw-r--r-- | cv.h | 2 | ||||
-rw-r--r-- | doio.c | 6 | ||||
-rw-r--r-- | dump.c | 10 | ||||
-rw-r--r-- | embed.h | 6 | ||||
-rwxr-xr-x | embed.pl | 2 | ||||
-rw-r--r-- | ext/B/B.xs | 16 | ||||
-rw-r--r-- | ext/B/defsubs.h.PL | 2 | ||||
-rw-r--r-- | ext/DB_File/DB_File.xs | 22 | ||||
-rw-r--r-- | ext/DynaLoader/dl_vms.xs | 2 | ||||
-rw-r--r-- | ext/IPC/SysV/SysV.xs | 4 | ||||
-rw-r--r-- | ext/Opcode/Opcode.xs | 2 | ||||
-rw-r--r-- | ext/POSIX/POSIX.xs | 8 | ||||
-rw-r--r-- | ext/Socket/Socket.xs | 18 | ||||
-rw-r--r-- | ext/attrs/attrs.xs | 4 | ||||
-rw-r--r-- | global.sym | 2 | ||||
-rw-r--r-- | gv.c | 10 | ||||
-rw-r--r-- | hv.c | 22 | ||||
-rw-r--r-- | hv.h | 2 | ||||
-rw-r--r-- | jpl/JNI/JNI.xs | 16 | ||||
-rw-r--r-- | mg.c | 2 | ||||
-rw-r--r-- | objXSUB.h | 8 | ||||
-rw-r--r-- | op.c | 14 | ||||
-rw-r--r-- | perl.c | 26 | ||||
-rw-r--r-- | pod/perlguts.pod | 10 | ||||
-rw-r--r-- | pp.c | 38 | ||||
-rw-r--r-- | pp.h | 14 | ||||
-rw-r--r-- | pp_ctl.c | 16 | ||||
-rw-r--r-- | pp_hot.c | 54 | ||||
-rw-r--r-- | pp_sys.c | 14 | ||||
-rw-r--r-- | proto.h | 5 | ||||
-rw-r--r-- | regcomp.c | 14 | ||||
-rw-r--r-- | scope.c | 21 | ||||
-rw-r--r-- | sv.c | 251 | ||||
-rw-r--r-- | sv.h | 2 | ||||
-rw-r--r-- | toke.c | 26 | ||||
-rw-r--r-- | util.c | 6 | ||||
-rw-r--r-- | win32/dl_win32.xs | 2 | ||||
-rw-r--r-- | win32/win32.c | 8 |
39 files changed, 309 insertions, 380 deletions
@@ -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 @@ -75,9 +75,11 @@ struct xpvcv { #define CvANON_on(cv) (CvFLAGS(cv) |= CVf_ANON) #define CvANON_off(cv) (CvFLAGS(cv) &= ~CVf_ANON) +#ifdef PERL_XSUB_OLDSTYLE #define CvOLDSTYLE(cv) (CvFLAGS(cv) & CVf_OLDSTYLE) #define CvOLDSTYLE_on(cv) (CvFLAGS(cv) |= CVf_OLDSTYLE) #define CvOLDSTYLE_off(cv) (CvFLAGS(cv) &= ~CVf_OLDSTYLE) +#endif #define CvUNIQUE(cv) (CvFLAGS(cv) & CVf_UNIQUE) #define CvUNIQUE_on(cv) (CvFLAGS(cv) |= CVf_UNIQUE) @@ -1615,12 +1615,6 @@ do_msgrcv(SV **mark, SV **sp) msize = SvIVx(*++mark); mtype = (long)SvIVx(*++mark); flags = SvIVx(*++mark); - if (SvTHINKFIRST(mstr)) { - if (SvREADONLY(mstr)) - croak("Can't msgrcv to readonly var"); - if (SvROK(mstr)) - sv_unref(mstr); - } SvPV_force(mstr, len); mbuf = SvGROW(mstr, sizeof(long)+msize+1); @@ -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); } @@ -868,6 +868,7 @@ #define sv_derived_from Perl_sv_derived_from #define sv_dump Perl_sv_dump #define sv_eq Perl_sv_eq +#define sv_force_normal Perl_sv_force_normal #define sv_free Perl_sv_free #define sv_free_arenas Perl_sv_free_arenas #define sv_gets Perl_sv_gets @@ -930,6 +931,7 @@ #define swash_init Perl_swash_init #define taint_env Perl_taint_env #define taint_proper Perl_taint_proper +#define tmps_grow Perl_tmps_grow #define to_uni_lower Perl_to_uni_lower #define to_uni_lower_lc Perl_to_uni_lower_lc #define to_uni_title Perl_to_uni_title @@ -2013,7 +2015,6 @@ #define sv_catpvn_mg CPerlObj::Perl_sv_catpvn_mg #define sv_catsv CPerlObj::Perl_sv_catsv #define sv_catsv_mg CPerlObj::Perl_sv_catsv_mg -#define sv_check_thinkfirst CPerlObj::Perl_sv_check_thinkfirst #define sv_chop CPerlObj::Perl_sv_chop #define sv_clean_all CPerlObj::Perl_sv_clean_all #define sv_clean_objs CPerlObj::Perl_sv_clean_objs @@ -2026,6 +2027,7 @@ #define sv_derived_from CPerlObj::Perl_sv_derived_from #define sv_dump CPerlObj::Perl_sv_dump #define sv_eq CPerlObj::Perl_sv_eq +#define sv_force_normal CPerlObj::Perl_sv_force_normal #define sv_free CPerlObj::Perl_sv_free #define sv_free_arenas CPerlObj::Perl_sv_free_arenas #define sv_gets CPerlObj::Perl_sv_gets @@ -2040,7 +2042,6 @@ #define sv_len_utf8 CPerlObj::Perl_sv_len_utf8 #define sv_magic CPerlObj::Perl_sv_magic #define sv_mortalcopy CPerlObj::Perl_sv_mortalcopy -#define sv_mortalgrow CPerlObj::Perl_sv_mortalgrow #define sv_ncmp CPerlObj::Perl_sv_ncmp #define sv_newmortal CPerlObj::Perl_sv_newmortal #define sv_newref CPerlObj::Perl_sv_newref @@ -2092,6 +2093,7 @@ #define swash_init CPerlObj::Perl_swash_init #define taint_env CPerlObj::Perl_taint_env #define taint_proper CPerlObj::Perl_taint_proper +#define tmps_grow CPerlObj::Perl_tmps_grow #define to_uni_lower CPerlObj::Perl_to_uni_lower #define to_uni_lower_lc CPerlObj::Perl_to_uni_lower_lc #define to_uni_title CPerlObj::Perl_to_uni_title @@ -225,9 +225,7 @@ my @staticfuncs = qw( del_xnv del_xpv del_xrv - sv_mortalgrow sv_unglob - sv_check_thinkfirst avhv_index_sv do_report_used do_clean_objs diff --git a/ext/B/B.xs b/ext/B/B.xs index a2ee8141c3..ccac053da9 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 c24eb94170..94ca5b3538 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 94113eb4e2..3f6c094395 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 08fd2f3f46..2a9ba3cb0f 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 0aaf0527a1..dbed151a71 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 e93b90046a..648ee91330 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 bd5cb7202d..59e937ecf4 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 30499483d0..4a8d8765c9 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 7f7970d207..4e0afb08ed 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/global.sym b/global.sym index 89199578f6..e7d1e365e4 100644 --- a/global.sym +++ b/global.sym @@ -515,6 +515,7 @@ sv_dec sv_derived_from sv_dump sv_eq +sv_force_normal sv_free sv_free_arenas sv_gets @@ -577,6 +578,7 @@ swash_fetch swash_init taint_env taint_proper +tmps_grow to_uni_lower to_uni_lower_lc to_uni_title @@ -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); } } @@ -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))); } @@ -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 080e10f60c..97416db760 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 @@ -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); } @@ -2893,8 +2893,6 @@ #define sv_catsv pPerl->Perl_sv_catsv #undef sv_catsv_mg #define sv_catsv_mg pPerl->Perl_sv_catsv_mg -#undef sv_check_thinkfirst -#define sv_check_thinkfirst pPerl->Perl_sv_check_thinkfirst #undef sv_chop #define sv_chop pPerl->Perl_sv_chop #undef sv_clean_all @@ -2919,6 +2917,8 @@ #define sv_dump pPerl->Perl_sv_dump #undef sv_eq #define sv_eq pPerl->Perl_sv_eq +#undef sv_force_normal +#define sv_force_normal pPerl->Perl_sv_force_normal #undef sv_free #define sv_free pPerl->Perl_sv_free #undef sv_free_arenas @@ -2947,8 +2947,6 @@ #define sv_magic pPerl->Perl_sv_magic #undef sv_mortalcopy #define sv_mortalcopy pPerl->Perl_sv_mortalcopy -#undef sv_mortalgrow -#define sv_mortalgrow pPerl->Perl_sv_mortalgrow #undef sv_ncmp #define sv_ncmp pPerl->Perl_sv_ncmp #undef sv_newmortal @@ -3051,6 +3049,8 @@ #define taint_env pPerl->Perl_taint_env #undef taint_proper #define taint_proper pPerl->Perl_taint_proper +#undef tmps_grow +#define tmps_grow pPerl->Perl_tmps_grow #undef to_uni_lower #define to_uni_lower pPerl->Perl_to_uni_lower #undef to_uni_lower_lc @@ -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 */ } @@ -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 c5289a1d86..b71337c137 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<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) @@ -2295,13 +2296,14 @@ SV is set to 1. If C<len> is zero then Perl will compute the length. 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) @@ -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")) @@ -792,15 +792,8 @@ PP(pp_undef) if (!sv) RETPUSHUNDEF; - if (SvTHINKFIRST(sv)) { - if (SvREADONLY(sv)) { - dTHR; - if (PL_curcop != &PL_compiling) - croak(PL_no_modify); - } - if (SvROK(sv)) - sv_unref(sv); - } + if (SvTHINKFIRST(sv)) + sv_force_normal(sv); switch (SvTYPE(sv)) { case SVt_NULL: @@ -817,9 +810,12 @@ PP(pp_undef) CvANON((CV*)sv) ? "(anonymous)" : GvENAME(CvGV((CV*)sv))); /* FALL THROUGH */ case SVt_PVFM: - { GV* gv = (GV*)SvREFCNT_inc(CvGV((CV*)sv)); - cv_undef((CV*)sv); - CvGV((CV*)sv) = gv; } /* let user-undef'd sub keep its identity */ + { + /* let user-undef'd sub keep its identity */ + GV* gv = (GV*)SvREFCNT_inc(CvGV((CV*)sv)); + cv_undef((CV*)sv); + CvGV((CV*)sv) = gv; + } break; case SVt_PVGV: if (SvFAKE(sv)) @@ -1037,12 +1033,6 @@ PP(pp_repeat) STRLEN len; tmpstr = POPs; - if (TARG == tmpstr && SvTHINKFIRST(tmpstr)) { - if (SvREADONLY(tmpstr) && PL_curcop != &PL_compiling) - DIE("Can't x= to readonly value"); - if (SvROK(tmpstr)) - sv_unref(tmpstr); - } SvSetSV(TARG, tmpstr); SvPV_force(TARG, len); if (count != 1) { @@ -3181,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 */ @@ -4171,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; @@ -155,18 +155,18 @@ #define SWITCHSTACK(f,t) \ STMT_START { \ - AvFILLp(f) = sp - PL_stack_base; \ + AvFILLp(f) = sp - PL_stack_base; \ PL_stack_base = AvARRAY(t); \ - PL_stack_max = PL_stack_base + AvMAX(t); \ + PL_stack_max = PL_stack_base + AvMAX(t); \ sp = PL_stack_sp = PL_stack_base + AvFILLp(t); \ - PL_curstack = t; \ + PL_curstack = t; \ } STMT_END #define EXTEND_MORTAL(n) \ - STMT_START { \ - if (PL_tmps_ix + (n) >= PL_tmps_max) \ - Renew(PL_tmps_stack, PL_tmps_max = PL_tmps_ix + (n) + 1, SV*); \ - } STMT_END + STMT_START { \ + if (PL_tmps_ix + (n) >= PL_tmps_max) \ + tmps_grow(n); \ + } STMT_END #define AMGf_noright 1 #define AMGf_noleft 2 @@ -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; @@ -2120,6 +2121,7 @@ PP(pp_goto) /* Now do some callish stuff. */ SAVETMPS; if (CvXSUB(cv)) { +#ifdef PERL_XSUB_OLDSTYLE if (CvOLDSTYLE(cv)) { I32 (*fp3)_((int,int,int)); while (SP > mark) { @@ -2132,7 +2134,9 @@ PP(pp_goto) items); SP = PL_stack_base + items; } - else { + else +#endif /* PERL_XSUB_OLDSTYLE */ + { SV **newsp; I32 gimme; @@ -2634,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 */ @@ -2668,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 @@ -2876,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; @@ -733,16 +733,10 @@ PP(pp_aassign) } break; default: - if (SvTHINKFIRST(sv)) { - if (SvREADONLY(sv) && PL_curcop != &PL_compiling) { - if (!SvIMMORTAL(sv)) - DIE(PL_no_modify); - if (relem <= lastrelem) - relem++; - break; - } - if (SvROK(sv)) - sv_unref(sv); + if (SvIMMORTAL(sv)) { + if (relem <= lastrelem) + relem++; + break; } if (relem <= lastrelem) { sv_setsv(sv, *relem); @@ -2099,16 +2093,15 @@ PP(pp_entersub) case SVt_PVGV: if (!(cv = GvCVu((GV*)sv))) cv = sv_2cv(sv, &stash, &gv, TRUE); - break; + if (cv) + break; + DIE("Not a CODE reference"); } ENTER; SAVETMPS; retry: - if (!cv) - DIE("Not a CODE reference"); - if (!CvROOT(cv) && !CvXSUB(cv)) { GV* autogv; SV* sub_name; @@ -2116,29 +2109,34 @@ PP(pp_entersub) /* anonymous or undef'd function leaves us no recourse */ if (CvANON(cv) || !(gv = CvGV(cv))) DIE("Undefined subroutine called"); + /* autoloaded stub? */ if (cv != GvCV(gv)) { cv = GvCV(gv); - goto retry; } /* should call AUTOLOAD now? */ - if ((autogv = gv_autoload4(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv), + else if ((autogv = gv_autoload4(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv), FALSE))) { cv = GvCV(autogv); - goto retry; } /* sorry */ - sub_name = sv_newmortal(); - gv_efullname3(sub_name, gv, Nullch); - DIE("Undefined subroutine &%s called", SvPVX(sub_name)); + else { + sub_name = sv_newmortal(); + gv_efullname3(sub_name, gv, Nullch); + DIE("Undefined subroutine &%s called", SvPVX(sub_name)); + } + if (!cv) + DIE("Not a CODE reference"); + goto retry; } gimme = GIMME_V; - if ((PL_op->op_private & OPpENTERSUB_DB) && GvCV(PL_DBsub) && !CvNODEBUG(cv)) + if ((PL_op->op_private & OPpENTERSUB_DB) && GvCV(PL_DBsub) && !CvNODEBUG(cv)) { cv = get_db_sub(&sv, cv); - if (!cv) - DIE("No DBsub routine"); + if (!cv) + DIE("No DBsub routine"); + } #ifdef USE_THREADS /* @@ -2274,6 +2272,7 @@ PP(pp_entersub) #endif /* USE_THREADS */ if (CvXSUB(cv)) { +#ifdef PERL_XSUB_OLDSTYLE if (CvOLDSTYLE(cv)) { I32 (*fp3)_((int,int,int)); dMARK; @@ -2290,7 +2289,9 @@ PP(pp_entersub) items); PL_stack_sp = PL_stack_base + items; } - else { + else +#endif /* PERL_XSUB_OLDSTYLE */ + { I32 markix = TOPMARK; PUTBACK; @@ -2316,9 +2317,8 @@ PP(pp_entersub) PUTBACK ; } } - if (PL_curcopdb) { /* We assume that the first - XSUB in &DB::sub is the - called one. */ + /* We assume first XSUB in &DB::sub is the called one. */ + if (PL_curcopdb) { SAVESPTR(PL_curcop); PL_curcop = PL_curcopdb; PL_curcopdb = NULL; @@ -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 @@ -715,9 +715,7 @@ void del_xiv _((XPVIV* p)); void del_xnv _((XPVNV* p)); void del_xpv _((XPV* p)); void del_xrv _((XRV* p)); -void sv_mortalgrow _((void)); void sv_unglob _((SV* sv)); -void sv_check_thinkfirst _((SV *sv)); I32 avhv_index_sv _((SV* sv)); void do_report_used _((SV *sv)); @@ -967,3 +965,6 @@ VIRTUAL void magic_dump _((MAGIC *mg)); VIRTUAL void reginitcolors _((void)); VIRTUAL char* sv_2pv_nolen _((SV* sv)); VIRTUAL char* sv_pv _((SV *sv)); +VIRTUAL void sv_force_normal _((SV *sv)); +VIRTUAL void tmps_grow _((I32 n)); + @@ -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 == '-') @@ -135,6 +135,19 @@ savestack_grow(void) #undef GROW void +tmps_grow(I32 n) +{ + dTHR; +#ifndef STRESS_REALLOC + if (n < 128) + n = (PL_tmps_max < 512) ? 128 : 512; +#endif + PL_tmps_max = PL_tmps_ix + n + 1; + Renew(PL_tmps_stack, PL_tmps_max, SV*); +} + + +void free_tmps(void) { dTHR; @@ -742,12 +755,8 @@ leave_scope(I32 base) sv = *(SV**)ptr; /* Can clear pad variable in place? */ if (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) { - if (SvTHINKFIRST(sv)) { - if (SvREADONLY(sv)) - croak("panic: leave_scope clearsv"); - if (SvROK(sv)) - sv_unref(sv); - } + if (SvTHINKFIRST(sv)) + sv_force_normal(sv); if (SvMAGICAL(sv)) mg_free(sv); @@ -57,9 +57,7 @@ static void del_xiv _((XPVIV* p)); static void del_xnv _((XPVNV* p)); static void del_xpv _((XPV* p)); static void del_xrv _((XRV* p)); -static void sv_mortalgrow _((void)); static void sv_unglob _((SV* sv)); -static void sv_check_thinkfirst _((SV *sv)); #ifndef PURIFY static void *my_safemalloc(MEM_SIZE size); @@ -71,25 +69,28 @@ typedef void (*SVFUNC) _((SV*)); #endif /* PERL_OBJECT */ -#define SV_CHECK_THINKFIRST(sv) if (SvTHINKFIRST(sv)) sv_check_thinkfirst(sv) +#define SV_CHECK_THINKFIRST(sv) if (SvTHINKFIRST(sv)) sv_force_normal(sv) #ifdef PURIFY -#define new_SV(p) \ - do { \ - LOCK_SV_MUTEX; \ - (p) = (SV*)safemalloc(sizeof(SV)); \ - reg_add(p); \ - UNLOCK_SV_MUTEX; \ - } while (0) - -#define del_SV(p) \ - do { \ - LOCK_SV_MUTEX; \ - reg_remove(p); \ - Safefree((char*)(p)); \ - UNLOCK_SV_MUTEX; \ - } while (0) +#define new_SV(p) \ + STMT_START { \ + LOCK_SV_MUTEX; \ + (p) = (SV*)safemalloc(sizeof(SV)); \ + reg_add(p); \ + UNLOCK_SV_MUTEX; \ + SvANY(p) = 0; \ + SvREFCNT(p) = 1; \ + SvFLAGS(p) = 0; \ + } STMT_END + +#define del_SV(p) \ + STMT_START { \ + LOCK_SV_MUTEX; \ + reg_remove(p); \ + Safefree((char*)(p)); \ + UNLOCK_SV_MUTEX; \ + } STMT_END static SV **registry; static I32 registry_size; @@ -97,18 +98,18 @@ static I32 registry_size; #define REGHASH(sv,size) ((((U32)(sv)) >> 2) % (size)) #define REG_REPLACE(sv,a,b) \ - do { \ - void* p = sv->sv_any; \ - I32 h = REGHASH(sv, registry_size); \ - I32 i = h; \ - while (registry[i] != (a)) { \ - if (++i >= registry_size) \ - i = 0; \ - if (i == h) \ - die("SV registry bug"); \ - } \ - registry[i] = (b); \ - } while (0) + STMT_START { \ + void* p = sv->sv_any; \ + I32 h = REGHASH(sv, registry_size); \ + I32 i = h; \ + while (registry[i] != (a)) { \ + if (++i >= registry_size) \ + i = 0; \ + if (i == h) \ + die("SV registry bug"); \ + } \ + registry[i] = (b); \ + } STMT_END #define REG_ADD(sv) REG_REPLACE(sv,Nullsv,sv) #define REG_REMOVE(sv) REG_REPLACE(sv,sv,Nullsv) @@ -178,41 +179,46 @@ U32 flags; * "A time to plant, and a time to uproot what was planted..." */ -#define plant_SV(p) \ - do { \ - SvANY(p) = (void *)PL_sv_root; \ - SvFLAGS(p) = SVTYPEMASK; \ - PL_sv_root = (p); \ - --PL_sv_count; \ - } while (0) +#define plant_SV(p) \ + STMT_START { \ + SvANY(p) = (void *)PL_sv_root; \ + SvFLAGS(p) = SVTYPEMASK; \ + PL_sv_root = (p); \ + --PL_sv_count; \ + } STMT_END /* sv_mutex must be held while calling uproot_SV() */ -#define uproot_SV(p) \ - do { \ - (p) = PL_sv_root; \ - PL_sv_root = (SV*)SvANY(p); \ - ++PL_sv_count; \ - } while (0) - -#define new_SV(p) do { \ - LOCK_SV_MUTEX; \ - if (PL_sv_root) \ - uproot_SV(p); \ - else \ - (p) = more_sv(); \ - UNLOCK_SV_MUTEX; \ - } while (0) +#define uproot_SV(p) \ + STMT_START { \ + (p) = PL_sv_root; \ + PL_sv_root = (SV*)SvANY(p); \ + ++PL_sv_count; \ + } STMT_END + +#define new_SV(p) \ + STMT_START { \ + LOCK_SV_MUTEX; \ + if (PL_sv_root) \ + uproot_SV(p); \ + else \ + (p) = more_sv(); \ + UNLOCK_SV_MUTEX; \ + SvANY(p) = 0; \ + SvREFCNT(p) = 1; \ + SvFLAGS(p) = 0; \ + } STMT_END #ifdef DEBUGGING -#define del_SV(p) do { \ - LOCK_SV_MUTEX; \ - if (PL_debug & 32768) \ - del_sv(p); \ - else \ - plant_SV(p); \ - UNLOCK_SV_MUTEX; \ - } while (0) +#define del_SV(p) \ + STMT_START { \ + LOCK_SV_MUTEX; \ + if (PL_debug & 32768) \ + del_sv(p); \ + else \ + plant_SV(p); \ + UNLOCK_SV_MUTEX; \ + } STMT_END STATIC void del_sv(SV *p) @@ -1002,11 +1008,6 @@ sv_setiv(register SV *sv, IV i) break; case SVt_PVGV: - if (SvFAKE(sv)) { - sv_unglob(sv); - break; - } - /* FALL THROUGH */ case SVt_PVAV: case SVt_PVHV: case SVt_PVCV: @@ -1062,11 +1063,6 @@ sv_setnv(register SV *sv, double num) break; case SVt_PVGV: - if (SvFAKE(sv)) { - sv_unglob(sv); - break; - } - /* FALL THROUGH */ case SVt_PVAV: case SVt_PVHV: case SVt_PVCV: @@ -1810,13 +1806,6 @@ sv_setsv(SV *dstr, register SV *sstr) stype = SvTYPE(sstr); dtype = SvTYPE(dstr); - if (dtype == SVt_PVGV && (SvFLAGS(dstr) & SVf_FAKE)) { - sv_unglob(dstr); /* so fake GLOB won't perpetuate */ - sv_setpvn(dstr, "", 0); - (void)SvPOK_only(dstr); - dtype = SvTYPE(dstr); - } - SvAMAGIC_off(dstr); /* There's a lot of redundancy below but we're going for speed here */ @@ -1949,9 +1938,9 @@ sv_setsv(SV *dstr, register SV *sstr) } } if (stype == SVt_PVLV) - SvUPGRADE(dstr, SVt_PVNV); + (void)SvUPGRADE(dstr, SVt_PVNV); else - SvUPGRADE(dstr, stype); + (void)SvUPGRADE(dstr, stype); } sflags = SvFLAGS(sstr); @@ -2183,12 +2172,7 @@ sv_setpvn(register SV *sv, register const char *ptr, register STRLEN len) (void)SvOK_off(sv); return; } - if (SvTYPE(sv) >= SVt_PV) { - if (SvFAKE(sv) && SvTYPE(sv) == SVt_PVGV) - sv_unglob(sv); - } - else - sv_upgrade(sv, SVt_PV); + (void)SvUPGRADE(sv, SVt_PV); SvGROW(sv, len + 1); dptr = SvPVX(sv); @@ -2217,12 +2201,7 @@ sv_setpv(register SV *sv, register const char *ptr) return; } len = strlen(ptr); - if (SvTYPE(sv) >= SVt_PV) { - if (SvFAKE(sv) && SvTYPE(sv) == SVt_PVGV) - sv_unglob(sv); - } - else - sv_upgrade(sv, SVt_PV); + (void)SvUPGRADE(sv, SVt_PV); SvGROW(sv, len + 1); Move(ptr,SvPVX(sv),len+1,char); @@ -2266,8 +2245,8 @@ sv_usepvn_mg(register SV *sv, register char *ptr, register STRLEN len) SvSETMAGIC(sv); } -STATIC void -sv_check_thinkfirst(register SV *sv) +void +sv_force_normal(register SV *sv) { if (SvREADONLY(sv)) { dTHR; @@ -2276,6 +2255,8 @@ sv_check_thinkfirst(register SV *sv) } if (SvROK(sv)) sv_unref(sv); + else if (SvFAKE(sv) && SvTYPE(sv) == SVt_PVGV) + sv_unglob(sv); } void @@ -2378,9 +2359,6 @@ newSV(STRLEN len) register SV *sv; new_SV(sv); - SvANY(sv) = 0; - SvREFCNT(sv) = 1; - SvFLAGS(sv) = 0; if (len) { sv_upgrade(sv, SVt_PV); SvGROW(sv, len + 1); @@ -3176,12 +3154,7 @@ sv_gets(register SV *sv, register PerlIO *fp, I32 append) I32 i; SV_CHECK_THINKFIRST(sv); - if (SvTYPE(sv) >= SVt_PV) { - if (SvFAKE(sv) && SvTYPE(sv) == SVt_PVGV) - sv_unglob(sv); - } - else - sv_upgrade(sv, SVt_PV); + (void)SvUPGRADE(sv, SVt_PV); SvSCREAM_off(sv); @@ -3582,14 +3555,6 @@ sv_dec(register SV *sv) * hopefully we won't free it until it has been assigned to a * permanent location. */ -STATIC void -sv_mortalgrow(void) -{ - dTHR; - PL_tmps_max += (PL_tmps_max < 512) ? 128 : 512; - Renew(PL_tmps_stack, PL_tmps_max, SV*); -} - SV * sv_mortalcopy(SV *oldstr) { @@ -3597,13 +3562,9 @@ sv_mortalcopy(SV *oldstr) register SV *sv; new_SV(sv); - SvANY(sv) = 0; - SvREFCNT(sv) = 1; - SvFLAGS(sv) = 0; sv_setsv(sv,oldstr); - if (++PL_tmps_ix >= PL_tmps_max) - sv_mortalgrow(); - PL_tmps_stack[PL_tmps_ix] = sv; + EXTEND_MORTAL(1); + PL_tmps_stack[++PL_tmps_ix] = sv; SvTEMP_on(sv); return sv; } @@ -3615,12 +3576,9 @@ sv_newmortal(void) register SV *sv; new_SV(sv); - SvANY(sv) = 0; - SvREFCNT(sv) = 1; SvFLAGS(sv) = SVs_TEMP; - if (++PL_tmps_ix >= PL_tmps_max) - sv_mortalgrow(); - PL_tmps_stack[PL_tmps_ix] = sv; + EXTEND_MORTAL(1); + PL_tmps_stack[++PL_tmps_ix] = sv; return sv; } @@ -3634,9 +3592,8 @@ sv_2mortal(register SV *sv) return sv; if (SvREADONLY(sv) && SvIMMORTAL(sv)) return sv; - if (++PL_tmps_ix >= PL_tmps_max) - sv_mortalgrow(); - PL_tmps_stack[PL_tmps_ix] = sv; + EXTEND_MORTAL(1); + PL_tmps_stack[++PL_tmps_ix] = sv; SvTEMP_on(sv); return sv; } @@ -3647,9 +3604,6 @@ newSVpv(const char *s, STRLEN len) register SV *sv; new_SV(sv); - SvANY(sv) = 0; - SvREFCNT(sv) = 1; - SvFLAGS(sv) = 0; if (!len) len = strlen(s); sv_setpvn(sv,s,len); @@ -3662,9 +3616,6 @@ newSVpvn(const char *s, STRLEN len) register SV *sv; new_SV(sv); - SvANY(sv) = 0; - SvREFCNT(sv) = 1; - SvFLAGS(sv) = 0; sv_setpvn(sv,s,len); return sv; } @@ -3676,9 +3627,6 @@ newSVpvf(const char* pat, ...) va_list args; new_SV(sv); - SvANY(sv) = 0; - SvREFCNT(sv) = 1; - SvFLAGS(sv) = 0; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); va_end(args); @@ -3692,9 +3640,6 @@ newSVnv(double n) register SV *sv; new_SV(sv); - SvANY(sv) = 0; - SvREFCNT(sv) = 1; - SvFLAGS(sv) = 0; sv_setnv(sv,n); return sv; } @@ -3705,9 +3650,6 @@ newSViv(IV i) register SV *sv; new_SV(sv); - SvANY(sv) = 0; - SvREFCNT(sv) = 1; - SvFLAGS(sv) = 0; sv_setiv(sv,i); return sv; } @@ -3719,9 +3661,6 @@ newRV_noinc(SV *tmpRef) register SV *sv; new_SV(sv); - SvANY(sv) = 0; - SvREFCNT(sv) = 1; - SvFLAGS(sv) = 0; sv_upgrade(sv, SVt_RV); SvTEMP_off(tmpRef); SvRV(sv) = tmpRef; @@ -3749,9 +3688,6 @@ newSVsv(register SV *old) return Nullsv; } new_SV(sv); - SvANY(sv) = 0; - SvREFCNT(sv) = 1; - SvFLAGS(sv) = 0; if (SvTEMP(old)) { SvTEMP_off(old); sv_setsv(sv,old); @@ -4016,27 +3952,17 @@ sv_pvn_force(SV *sv, STRLEN *lp) { char *s; - if (SvREADONLY(sv)) { - dTHR; - if (PL_curcop != &PL_compiling) - croak(PL_no_modify); - } + if (SvTHINKFIRST(sv) && !SvROK(sv)) + sv_force_normal(sv); if (SvPOK(sv)) { *lp = SvCUR(sv); } else { if (SvTYPE(sv) > SVt_PVLV && SvTYPE(sv) != SVt_PVFM) { - if (SvFAKE(sv) && SvTYPE(sv) == SVt_PVGV) { - sv_unglob(sv); - s = SvPVX(sv); - *lp = SvCUR(sv); - } - else { - dTHR; - croak("Can't coerce %s to string in %s", sv_reftype(sv,0), - PL_op_name[PL_op->op_type]); - } + dTHR; + croak("Can't coerce %s to string in %s", sv_reftype(sv,0), + PL_op_name[PL_op->op_type]); } else s = sv_2pv(sv, lp); @@ -4130,9 +4056,6 @@ newSVrv(SV *rv, const char *classname) SV *sv; new_SV(sv); - SvANY(sv) = 0; - SvREFCNT(sv) = 0; - SvFLAGS(sv) = 0; SV_CHECK_THINKFIRST(rv); SvAMAGIC_off(rv); @@ -4141,7 +4064,7 @@ newSVrv(SV *rv, const char *classname) sv_upgrade(rv, SVt_RV); (void)SvOK_off(rv); - SvRV(rv) = SvREFCNT_inc(sv); + SvRV(rv) = sv; SvROK_on(rv); if (classname) { @@ -137,7 +137,7 @@ struct io { #define SVf_BREAK 0x00400000 /* refcnt is artificially low */ #define SVf_READONLY 0x00800000 /* may not be modified */ -#define SVf_THINKFIRST (SVf_READONLY|SVf_ROK) +#define SVf_THINKFIRST (SVf_READONLY|SVf_ROK|SVf_FAKE) #define SVp_IOK 0x01000000 /* has valid non-public integer value */ #define SVp_NOK 0x02000000 /* has valid non-public numeric value */ @@ -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)) @@ -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 c650acffb7..3473520372 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 5d2bdaa5f1..480dfeb987 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)); |