From: Gisle Aas Date: Wed, 4 Jan 2006 12:48:34 +0000 (+0000) Subject: Introduce the macros newSVpvs(str) and sv_catpvs(sv, str). X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=396482e1e4786de2b4c8ab57cb613dc0f110b931;p=p5sagit%2Fp5-mst-13.2.git Introduce the macros newSVpvs(str) and sv_catpvs(sv, str). Gets rid of many hardcoded string lengths. p4raw-id: //depot/perl@26641 --- diff --git a/dump.c b/dump.c index 2285cca..904b3ba 100644 --- a/dump.c +++ b/dump.c @@ -128,12 +128,12 @@ Perl_pv_display(pTHX_ SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pv break; } switch (*pv) { - case '\t': sv_catpvn(dsv, "\\t", 2); break; - case '\n': sv_catpvn(dsv, "\\n", 2); break; - case '\r': sv_catpvn(dsv, "\\r", 2); break; - case '\f': sv_catpvn(dsv, "\\f", 2); break; - case '"': sv_catpvn(dsv, "\\\"", 2); break; - case '\\': sv_catpvn(dsv, "\\\\", 2); break; + case '\t': sv_catpvs(dsv, "\\t"); break; + case '\n': sv_catpvs(dsv, "\\n"); break; + case '\r': sv_catpvs(dsv, "\\r"); break; + case '\f': sv_catpvs(dsv, "\\f"); break; + case '"': sv_catpvs(dsv, "\\\""); break; + case '\\': sv_catpvs(dsv, "\\\\"); break; default: if (isPRINT(*pv)) sv_catpvn(dsv, pv, 1); @@ -143,11 +143,11 @@ Perl_pv_display(pTHX_ SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pv Perl_sv_catpvf(aTHX_ dsv, "\\%o", (U8)*pv); } } - sv_catpvn(dsv, "\"", 1); + sv_catpvs(dsv, "\""); if (truncated) - sv_catpvn(dsv, "...", 3); + sv_catpvs(dsv, "..."); if (nul_terminated) - sv_catpvn(dsv, "\\0", 2); + sv_catpvs(dsv, "\\0"); return SvPVX(dsv); } @@ -301,7 +301,7 @@ Perl_sv_peek(pTHX_ SV *sv) if (!SvPVX_const(sv)) sv_catpv(t, "(null)"); else { - SV *tmp = newSVpvn("", 0); + SV *tmp = newSVpvs(""); sv_catpv(t, "("); if (SvOOK(sv)) Perl_sv_catpvf(aTHX_ t, "[%s]", pv_display(tmp, SvPVX_const(sv)-SvIVX(sv), SvIVX(sv), 0, 127)); @@ -361,7 +361,7 @@ Perl_do_pmop_dump(pTHX_ I32 level, PerlIO *file, const PMOP *pm) op_dump(pm->op_pmreplroot); } if (pm->op_pmflags || (PM_GETRE(pm) && PM_GETRE(pm)->check_substr)) { - SV *tmpsv = newSVpvn("", 0); + SV *tmpsv = newSVpvs(""); if (pm->op_pmdynflags & PMdf_USED) sv_catpv(tmpsv, ",USED"); if (pm->op_pmdynflags & PMdf_TAINTED) @@ -555,7 +555,7 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, const OP *o) Perl_dump_indent(aTHX_ level, file, "ADDR = 0x%"UVxf" => 0x%"UVxf"\n", (UV)o, (UV)o->op_next); #endif if (o->op_flags) { - SV *tmpsv = newSVpvn("", 0); + SV *tmpsv = newSVpvs(""); switch (o->op_flags & OPf_WANT) { case OPf_WANT_VOID: sv_catpv(tmpsv, ",VOID"); @@ -586,7 +586,7 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, const OP *o) SvREFCNT_dec(tmpsv); } if (o->op_private) { - SV *tmpsv = newSVpvn("", 0); + SV *tmpsv = newSVpvs(""); if (PL_opargs[o->op_type] & OA_TARGLEX) { if (o->op_private & OPpTARGET_MY) sv_catpv(tmpsv, ",TARGET_MY"); @@ -1023,7 +1023,7 @@ Perl_do_magic_dump(pTHX_ I32 level, PerlIO *file, const MAGIC *mg, I32 nest, I32 Perl_dump_indent(aTHX_ level, file, " MG_PTR = 0x%"UVxf, PTR2UV(mg->mg_ptr)); if (mg->mg_len >= 0) { if (mg->mg_type != PERL_MAGIC_utf8) { - SV *sv = newSVpvn("", 0); + SV *sv = newSVpvs(""); PerlIO_printf(file, " %s", pv_display(sv, mg->mg_ptr, mg->mg_len, 0, pvlim)); SvREFCNT_dec(sv); } diff --git a/gv.c b/gv.c index 06982bd..d341da3 100644 --- a/gv.c +++ b/gv.c @@ -626,7 +626,7 @@ Perl_gv_autoload4(pTHX_ HV *stash, const char *name, STRLEN len, I32 method) LEAVE; varsv = GvSVn(vargv); sv_setpvn(varsv, packname, packname_len); - sv_catpvn(varsv, "::", 2); + sv_catpvs(varsv, "::"); sv_catpvn(varsv, name, len); SvTAINTED_off(varsv); return gv; @@ -647,7 +647,7 @@ S_require_errno(pTHX_ GV *gv) ENTER; save_scalar(gv); /* keep the value of $! */ Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, - newSVpvn("Errno",5), Nullsv); + newSVpvs("Errno"), Nullsv); LEAVE; SPAGAIN; stash = gv_stashpvn("Errno",5,FALSE); @@ -1222,7 +1222,7 @@ Perl_gv_fullname4(pTHX_ SV *sv, const GV *gv, const char *prefix, bool keepmain) if (keepmain || strNE(name, "main")) { sv_catpvn(sv,name,namelen); - sv_catpvn(sv,"::", 2); + sv_catpvs(sv,"::"); } sv_catpvn(sv,GvNAME(gv),GvNAMELEN(gv)); } diff --git a/op.c b/op.c index 54d8f6d..e14b4e6 100644 --- a/op.c +++ b/op.c @@ -2429,7 +2429,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl) o->op_private |= OPpTRANS_TO_UTF; if (o->op_private & (OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF)) { - SV* const listsv = newSVpvn("# comment\n",10); + SV* const listsv = newSVpvs("# comment\n"); SV* transv = NULL; const U8* tend = t + tlen; const U8* rend = r + rlen; @@ -2474,7 +2474,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl) UV nextmin = 0; Newx(cp, 2*tlen, UV); i = 0; - transv = newSVpvn("",0); + transv = newSVpvs(""); while (t < tend) { cp[2*i] = utf8n_to_uvuni(t, tend-t, &ulen, 0); t += ulen; @@ -4296,12 +4296,12 @@ Perl_cv_ckproto(pTHX_ const CV *cv, const GV *gv, const char *p) if (SvPOK(cv)) Perl_sv_catpvf(aTHX_ msg, " (%"SVf")", (const SV *)cv); else - Perl_sv_catpv(aTHX_ msg, ": none"); - sv_catpv(msg, " vs "); + sv_catpvs(msg, ": none"); + sv_catpvs(msg, " vs "); if (p) Perl_sv_catpvf(aTHX_ msg, "(%s)", p); else - sv_catpv(msg, "none"); + sv_catpvs(msg, "none"); Perl_warner(aTHX_ packWARN(WARN_PROTOTYPE), "%"SVf, msg); } } @@ -5784,7 +5784,7 @@ Perl_ck_glob(pTHX_ OP *o) GV *glob_gv; ENTER; Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, - newSVpvn("File::Glob", 10), Nullsv, Nullsv, Nullsv); + newSVpvs("File::Glob"), Nullsv, Nullsv, Nullsv); gv = gv_fetchpv("CORE::GLOBAL::glob", 0, SVt_PVCV); glob_gv = gv_fetchpv("File::Glob::csh_glob", 0, SVt_PVCV); GvCV(gv) = GvCV(glob_gv); @@ -5987,7 +5987,7 @@ Perl_ck_say(pTHX_ OP *o) o = ck_listiob(o); o->op_type = OP_PRINT; cLISTOPo->op_last = cLISTOPo->op_last->op_sibling - = newSVOP(OP_CONST, 0, newSVpvn("\n", 1)); + = newSVOP(OP_CONST, 0, newSVpvs("\n")); return o; } @@ -6182,7 +6182,7 @@ Perl_ck_require(pTHX_ OP *o) SvCUR_set(sv, SvCUR(sv) - 1); } } - sv_catpvn(sv, ".pm", 3); + sv_catpvs(sv, ".pm"); SvFLAGS(sv) |= was_readonly; } } @@ -6421,7 +6421,7 @@ Perl_ck_split(pTHX_ OP *o) op_free(cLISTOPo->op_first); cLISTOPo->op_first = kid; if (!kid) { - cLISTOPo->op_first = kid = newSVOP(OP_CONST, 0, newSVpvn(" ", 1)); + cLISTOPo->op_first = kid = newSVOP(OP_CONST, 0, newSVpvs(" ")); cLISTOPo->op_last = kid; /* There was only one element previously */ } @@ -6588,7 +6588,7 @@ Perl_ck_subr(pTHX_ OP *o) { GV * const gv = cGVOPx_gv(gvop); OP * const sibling = o2->op_sibling; - SV * const n = newSVpvn("",0); + SV * const n = newSVpvs(""); op_free(o2); gv_fullname4(n, gv, "", FALSE); o2 = newSVOP(OP_CONST, 0, n); diff --git a/perl.c b/perl.c index c5c04c0..ec0fcf5 100644 --- a/perl.c +++ b/perl.c @@ -276,7 +276,7 @@ perl_construct(pTHXx) #endif } - PL_rs = newSVpvn("\n", 1); + PL_rs = newSVpvs("\n"); init_stacks(); @@ -301,7 +301,7 @@ perl_construct(pTHXx) PL_fdpid = newAV(); /* for remembering popen pids by fd */ PL_modglobal = newHV(); /* pointers to per-interpreter module globals */ - PL_errors = newSVpvn("",0); + PL_errors = newSVpvs(""); sv_setpvn(PERL_DEBUG_PAD(0), "", 0); /* For regex debugging. */ sv_setpvn(PERL_DEBUG_PAD(1), "", 0); /* ext/re needs these */ sv_setpvn(PERL_DEBUG_PAD(2), "", 0); /* even without DEBUGGING. */ @@ -1601,7 +1601,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) PL_fdscript = -1; PL_suidscript = -1; sv_setpvn(PL_linestr,"",0); - sv = newSVpvn("",0); /* first used for -I flags */ + sv = newSVpvs(""); /* first used for -I flags */ SAVEFREESV(sv); init_main_stash(); @@ -1679,7 +1679,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) #endif forbid_setid("-e"); if (!PL_e_script) { - PL_e_script = newSVpvn("",0); + PL_e_script = newSVpvs(""); filter_add(read_e_script, NULL); } if (*++s) @@ -1690,7 +1690,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) } else Perl_croak(aTHX_ "No code specified for -%c", *s); - sv_catpv(PL_e_script, "\n"); + sv_catpvs(PL_e_script, "\n"); break; case 'f': @@ -1709,9 +1709,9 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) STRLEN len = strlen(s); const char * const p = savepvn(s, len); incpush(p, TRUE, TRUE, FALSE, FALSE); - sv_catpvn(sv, "-I", 2); + sv_catpvs(sv, "-I"); sv_catpvn(sv, p, len); - sv_catpvn(sv, " ", 1); + sv_catpvs(sv, " "); Safefree(p); } else @@ -1734,15 +1734,15 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) if (!PL_preambleav) PL_preambleav = newAV(); av_push(PL_preambleav, - newSVpv("use Config;",0)); + newSVpvs("use Config;")); if (*++s != ':') { STRLEN opts; - opts_prog = newSVpv("print Config::myconfig(),",0); + opts_prog = newSVpvs("print Config::myconfig(),"); #ifdef VMS - sv_catpv(opts_prog,"\"\\nCharacteristics of this PERLSHR image: \\n\","); + sv_catpvs(opts_prog,"\"\\nCharacteristics of this PERLSHR image: \\n\","); #else - sv_catpv(opts_prog,"\"\\nCharacteristics of this binary (from libperl): \\n\","); + sv_catpvs(opts_prog,"\"\\nCharacteristics of this binary (from libperl): \\n\","); #endif opts = SvCUR(opts_prog); @@ -1864,12 +1864,12 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) "\\n ", 25); } - sv_catpv(opts_prog,"\\n\","); + sv_catpvs(opts_prog,"\\n\","); #if defined(LOCAL_PATCH_COUNT) if (LOCAL_PATCH_COUNT > 0) { int i; - sv_catpv(opts_prog, + sv_catpvs(opts_prog, "\" Locally applied patches:\\n\","); for (i = 1; i <= LOCAL_PATCH_COUNT; i++) { if (PL_localpatches[i]) @@ -1890,14 +1890,14 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) __DATE__); # endif #endif - sv_catpv(opts_prog, "; $\"=\"\\n \"; " + sv_catpvs(opts_prog, "; $\"=\"\\n \"; " "@env = map { \"$_=\\\"$ENV{$_}\\\"\" } " "sort grep {/^PERL/} keys %ENV; "); #ifdef __CYGWIN__ - sv_catpv(opts_prog, + sv_catpvs(opts_prog, "push @env, \"CYGWIN=\\\"$ENV{CYGWIN}\\\"\";"); #endif - sv_catpv(opts_prog, + sv_catpvs(opts_prog, "print \" \\%ENV:\\n @env\\n\" if @env;" "print \" \\@INC:\\n @INC\\n\";"); } @@ -2959,7 +2959,7 @@ Perl_moreswitches(pTHX_ char *s) numlen = 0; s--; } - PL_rs = newSVpvn("", 0); + PL_rs = newSVpvs(""); SvGROW(PL_rs, (STRLEN)(UNISKIP(rschar) + 1)); tmps = (U8*)SvPVX(PL_rs); uvchr_to_utf8(tmps, rschar); @@ -2972,7 +2972,7 @@ Perl_moreswitches(pTHX_ char *s) if (rschar & ~((U8)~0)) PL_rs = &PL_sv_undef; else if (!rschar && numlen >= 2) - PL_rs = newSVpvn("", 0); + PL_rs = newSVpvs(""); else { char ch = (char)rschar; PL_rs = newSVpvn(&ch, 1); @@ -3014,7 +3014,7 @@ Perl_moreswitches(pTHX_ char *s) in the fashion that -MSome::Mod does. */ if (*s == ':' || *s == '=') { const char *start; - SV * const sv = newSVpv("use Devel::", 0); + SV * const sv = newSVpvs("use Devel::"); start = ++s; /* We now allow -d:Module=Foo,Bar */ while(isALNUM(*s) || *s==':') ++s; @@ -3101,14 +3101,14 @@ Perl_moreswitches(pTHX_ char *s) if (isDIGIT(*s)) { I32 flags = 0; STRLEN numlen; - PL_ors_sv = newSVpvn("\n",1); + PL_ors_sv = newSVpvs("\n"); numlen = 3 + (*s == '0'); *SvPVX(PL_ors_sv) = (char)grok_oct(s, &numlen, &flags, NULL); s += numlen; } else { if (RsPARA(PL_rs)) { - PL_ors_sv = newSVpvn("\n\n",2); + PL_ors_sv = newSVpvs("\n\n"); } else { PL_ors_sv = newSVsv(PL_rs); @@ -3122,10 +3122,10 @@ Perl_moreswitches(pTHX_ char *s) s++; { char * const start = s; - SV * const sv = newSVpv("use assertions::activate", 24); + SV * const sv = newSVpvs("use assertions::activate"); while(isALNUM(*s) || *s == ':') ++s; if (s != start) { - sv_catpvn(sv, "::", 2); + sv_catpvs(sv, "::"); sv_catpvn(sv, start, s-start); } if (*s == '=') { @@ -3160,17 +3160,17 @@ Perl_moreswitches(pTHX_ char *s) if (*(start-1) == 'm') { if (*s != '\0') Perl_croak(aTHX_ "Can't use '%c' after -mname", *s); - sv_catpv( sv, " ()"); + sv_catpvs( sv, " ()"); } } else { if (s == start) Perl_croak(aTHX_ "Module name required with -%c option", s[-1]); sv_catpvn(sv, start, s-start); - sv_catpv(sv, " split(/,/,q"); - sv_catpvn(sv, "\0)", 1); /* Use NUL as q//-delimiter. */ + sv_catpvs(sv, " split(/,/,q"); + sv_catpvs(sv, "\0"); /* Use NUL as q//-delimiter. */ sv_catpv(sv, ++s); - sv_catpvn(sv, "\0)", 2); + sv_catpvs(sv, "\0)"); } s += strlen(s); if (!PL_preambleav) @@ -3382,9 +3382,9 @@ Perl_my_unexec(pTHX) extern int etext; prog = newSVpv(BIN_EXP, 0); - sv_catpv(prog, "/perl"); + sv_catpvs(prog, "/perl"); file = newSVpv(PL_origfilename, 0); - sv_catpv(file, ".perldump"); + sv_catpvs(file, ".perldump"); unexec(SvPVX(file), SvPVX(prog), &etext, sbrk(0), 0); /* unexec prints msg to stderr in case of failure */ @@ -3575,7 +3575,7 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch, SV *sv) #else /* IAMSUID */ else if (PL_preprocess) { const char * const cpp_cfg = CPPSTDIN; - SV * const cpp = newSVpvn("",0); + SV * const cpp = newSVpvs(""); SV * const cmd = NEWSV(0,0); if (cpp_cfg[0] == 0) /* PERL_MICRO? */ @@ -3585,7 +3585,7 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch, SV *sv) sv_catpv(cpp, cpp_cfg); # ifndef VMS - sv_catpvn(sv, "-I", 2); + sv_catpvs(sv, "-I"); sv_catpv(sv,PRIVLIB_EXP); # endif @@ -4461,7 +4461,7 @@ S_init_lexer(pTHX) PL_rsfp = Nullfp; lex_start(PL_linestr); PL_rsfp = tmpfp; - PL_subname = newSVpvn("main",4); + PL_subname = newSVpvs("main"); } STATIC void @@ -4816,7 +4816,7 @@ S_incpush(pTHX_ const char *dir, bool addsubdirs, bool addoldvers, bool usesep, if (usesep) { while ( *p == PERLLIB_SEP ) { /* Uncomment the next line for PATH semantics */ - /* av_push(GvAVn(PL_incgv), newSVpvn(".", 1)); */ + /* av_push(GvAVn(PL_incgv), newSVpvs(".")); */ p++; } } @@ -4837,7 +4837,7 @@ S_incpush(pTHX_ const char *dir, bool addsubdirs, bool addoldvers, bool usesep, sv_setpv(libdir, MacPerl_CanonDir(SvPVX(libdir), buf, 0)); } if (SvPVX(libdir)[SvCUR(libdir)-1] != ':') - sv_catpv(libdir, ":"); + sv_catpvs(libdir, ":"); #endif /* Do the if() outside the #ifdef to avoid warnings about an unused @@ -5074,7 +5074,7 @@ S_init_main_thread(pTHX) sv_upgrade(PL_bodytarget, SVt_PVFM); sv_setpvn(PL_bodytarget, "", 0); PL_formtarget = PL_bodytarget; - thr->errsv = newSVpvn("", 0); + thr->errsv = newSVpvs(""); (void) find_threadsv("@"); /* Ensure $@ is initialised early */ PL_maxscream = -1; @@ -5130,7 +5130,7 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList) PL_curcop = &PL_compiling; CopLINE_set(PL_curcop, oldline); if (paramList == PL_beginav) - sv_catpv(atsv, "BEGIN failed--compilation aborted"); + sv_catpvs(atsv, "BEGIN failed--compilation aborted"); else Perl_sv_catpvf(aTHX_ atsv, "%s failed--call queue aborted", diff --git a/perlio.c b/perlio.c index 1c6da02..175b978 100644 --- a/perlio.c +++ b/perlio.c @@ -480,7 +480,7 @@ PerlIO_debug(const char *fmt, ...) #else const char *s = CopFILE(PL_curcop); STRLEN len; - SV * const sv = newSVpvn("", 0); + SV * const sv = newSVpvs(""); Perl_sv_catpvf(aTHX_ sv, "%s:%" IVdf " ", s ? s : "(none)", (IV) CopLINE(PL_curcop)); Perl_sv_vcatpvf(aTHX_ sv, fmt, &ap); @@ -760,7 +760,7 @@ PerlIO_find_layer(pTHX_ const char *name, STRLEN len, int load) Perl_croak(aTHX_ "Recursive call to Perl_load_module in PerlIO_find_layer"); return NULL; } else { - SV * const pkgsv = newSVpvn("PerlIO", 6); + SV * const pkgsv = newSVpvs("PerlIO"); SV * const layer = newSVpvn(name, len); CV * const cv = get_cv("PerlIO::Layer::NoWarnings", FALSE); ENTER; @@ -4855,7 +4855,7 @@ int PerlIO_vprintf(PerlIO *f, const char *fmt, va_list ap) { dTHX; - SV * const sv = newSVpvn("", 0); + SV * const sv = newSVpvs(""); const char *s; STRLEN len; SSize_t wrote; @@ -4909,7 +4909,7 @@ PerlIO_tmpfile(void) f = PerlIO_fdopen(fd, "w+b"); #else /* WIN32 */ # if defined(HAS_MKSTEMP) && ! defined(VMS) && ! defined(OS2) - SV * const sv = newSVpv("/tmp/PerlIO_XXXXXX", 0); + SV * const sv = newSVpvs("/tmp/PerlIO_XXXXXX"); /* * I have no idea how portable mkstemp() is ... NI-S */ diff --git a/pp.c b/pp.c index 3221277..b161eb6 100644 --- a/pp.c +++ b/pp.c @@ -600,7 +600,7 @@ PP(pp_gelem) if (strEQ(second_letter, "ACKAGE")) { const HV * const stash = GvSTASH(gv); const HEK * const hek = stash ? HvNAME_HEK(stash) : NULL; - sv = hek ? newSVhek(hek) : newSVpvn("__ANON__", 8); + sv = hek ? newSVhek(hek) : newSVpvs("__ANON__"); } break; case 'S': diff --git a/pp_ctl.c b/pp_ctl.c index 4706fe6..3e66ada 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -1176,7 +1176,7 @@ PP(pp_flop) if (flop) { sv_setiv(PAD_SV(((UNOP*)cUNOP->op_first)->op_first->op_targ), 0); - sv_catpvn(targ, "E0", 2); + sv_catpvs(targ, "E0"); } SETs(targ); } @@ -1614,12 +1614,12 @@ PP(pp_caller) PUSHs(sv_2mortal(newSViv((I32)cx->blk_sub.hasargs))); } else { - PUSHs(sv_2mortal(newSVpvn("(unknown)",9))); + PUSHs(sv_2mortal(newSVpvs("(unknown)"))); PUSHs(sv_2mortal(newSViv((I32)cx->blk_sub.hasargs))); } } else { - PUSHs(sv_2mortal(newSVpvn("(eval)",6))); + PUSHs(sv_2mortal(newSVpvs("(eval)"))); PUSHs(sv_2mortal(newSViv(0))); } gimme = (I32)cx->blk_gimme; @@ -3312,10 +3312,10 @@ PP(pp_require) )); for (i = 0; i <= AvFILL(ar); i++) { - sv_catpvn(msg, " ", 1); + sv_catpvs(msg, " "); sv_catsv(msg, *av_fetch(ar, i, TRUE)); } - sv_catpvn(msg, ")", 1); + sv_catpvs(msg, ")"); msgstr = SvPV_nolen_const(msg); } } @@ -3340,7 +3340,7 @@ PP(pp_require) ENTER; SAVETMPS; - lex_start(sv_2mortal(newSVpvn("",0))); + lex_start(sv_2mortal(newSVpvs(""))); SAVEGENERICSV(PL_rsfp_filters); PL_rsfp_filters = NULL; diff --git a/pp_pack.c b/pp_pack.c index db53a1e..23cf6df 100644 --- a/pp_pack.c +++ b/pp_pack.c @@ -179,7 +179,7 @@ S_mul128(pTHX_ SV *sv, U8 m) char *t; if (!strnEQ(s, "0000", 4)) { /* need to grow sv */ - SV * const tmpNew = newSVpvn("0000000000", 10); + SV * const tmpNew = newSVpvs("0000000000"); sv_catsv(tmpNew, sv); SvREFCNT_dec(sv); /* free old sv */ diff --git a/pp_sys.c b/pp_sys.c index 4e6c6b7..6ff9acd 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -403,7 +403,7 @@ PP(pp_glob) PL_last_in_gv = (GV*)*PL_stack_sp--; SAVESPTR(PL_rs); /* This is not permanent, either. */ - PL_rs = sv_2mortal(newSVpvn("\000", 1)); + PL_rs = sv_2mortal(newSVpvs("\000")); #ifndef DOSISH #ifndef CSH *SvPVX(PL_rs) = '\n'; @@ -445,12 +445,12 @@ PP(pp_warn) SV * const error = ERRSV; SvUPGRADE(error, SVt_PV); if (SvPOK(error) && SvCUR(error)) - sv_catpv(error, "\t...caught"); + sv_catpvs(error, "\t...caught"); tmpsv = error; tmps = SvPV_const(tmpsv, len); } if (!tmps || !len) - tmpsv = sv_2mortal(newSVpvn("Warning: something's wrong", 26)); + tmpsv = sv_2mortal(newSVpvs("Warning: something's wrong")); Perl_warn(aTHX_ "%"SVf, tmpsv); RETSETYES; @@ -505,7 +505,7 @@ PP(pp_die) } else { if (SvPOK(error) && SvCUR(error)) - sv_catpv(error, "\t...propagated"); + sv_catpvs(error, "\t...propagated"); tmpsv = error; if (SvOK(tmpsv)) tmps = SvPV_const(tmpsv, len); @@ -514,7 +514,7 @@ PP(pp_die) } } if (!tmps || !len) - tmpsv = sv_2mortal(newSVpvn("Died", 4)); + tmpsv = sv_2mortal(newSVpvs("Died")); DIE(aTHX_ "%"SVf, tmpsv); } @@ -2813,7 +2813,7 @@ PP(pp_stat) #ifdef USE_STAT_RDEV PUSHs(sv_2mortal(newSViv(PL_statcache.st_rdev))); #else - PUSHs(sv_2mortal(newSVpvn("", 0))); + PUSHs(sv_2mortal(newSVpvs(""))); #endif #if Off_t_size > IVSIZE PUSHs(sv_2mortal(newSVnv((NV)PL_statcache.st_size))); @@ -2833,8 +2833,8 @@ PP(pp_stat) PUSHs(sv_2mortal(newSVuv(PL_statcache.st_blksize))); PUSHs(sv_2mortal(newSVuv(PL_statcache.st_blocks))); #else - PUSHs(sv_2mortal(newSVpvn("", 0))); - PUSHs(sv_2mortal(newSVpvn("", 0))); + PUSHs(sv_2mortal(newSVpvs(""))); + PUSHs(sv_2mortal(newSVpvs(""))); #endif } RETURN; @@ -4565,7 +4565,7 @@ PP(pp_ghostent) for (elem = hent->h_aliases; elem && *elem; elem++) { sv_catpv(sv, *elem); if (elem[1]) - sv_catpvn(sv, " ", 1); + sv_catpvs(sv, " "); } PUSHs(sv = sv_mortalcopy(&PL_sv_no)); sv_setiv(sv, (IV)hent->h_addrtype); @@ -4657,7 +4657,7 @@ PP(pp_gnetent) for (elem = nent->n_aliases; elem && *elem; elem++) { sv_catpv(sv, *elem); if (elem[1]) - sv_catpvn(sv, " ", 1); + sv_catpvs(sv, " "); } PUSHs(sv = sv_mortalcopy(&PL_sv_no)); sv_setiv(sv, (IV)nent->n_addrtype); @@ -4727,7 +4727,7 @@ PP(pp_gprotoent) for (elem = pent->p_aliases; elem && *elem; elem++) { sv_catpv(sv, *elem); if (elem[1]) - sv_catpvn(sv, " ", 1); + sv_catpvs(sv, " "); } PUSHs(sv = sv_mortalcopy(&PL_sv_no)); sv_setiv(sv, (IV)pent->p_proto); @@ -4805,7 +4805,7 @@ PP(pp_gservent) for (elem = sent->s_aliases; elem && *elem; elem++) { sv_catpv(sv, *elem); if (elem[1]) - sv_catpvn(sv, " ", 1); + sv_catpvs(sv, " "); } PUSHs(sv = sv_mortalcopy(&PL_sv_no)); #ifdef HAS_NTOHS @@ -5232,7 +5232,7 @@ PP(pp_ggrent) for (elem = grent->gr_mem; elem && *elem; elem++) { sv_catpv(sv, *elem); if (elem[1]) - sv_catpvn(sv, " ", 1); + sv_catpvs(sv, " "); } #endif } diff --git a/regcomp.c b/regcomp.c index 66a8f86..67aec27 100644 --- a/regcomp.c +++ b/regcomp.c @@ -3020,9 +3020,9 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm) */ minlen = 0; - data.longest_fixed = newSVpvn("",0); - data.longest_float = newSVpvn("",0); - data.last_found = newSVpvn("",0); + data.longest_fixed = newSVpvs(""); + data.longest_float = newSVpvs(""); + data.last_found = newSVpvs(""); data.longest = &(data.longest_fixed); first = scan; if (!r->regstclass) { @@ -3315,7 +3315,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp) if (RExC_parse - 1 - s) sv = newSVpvn(s, RExC_parse - 1 - s); else - sv = newSVpvn("", 0); + sv = newSVpvs(""); ENTER; Perl_save_re_context(aTHX); @@ -4685,7 +4685,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state) if (LOC) ANYOF_FLAGS(ret) |= ANYOF_LOCALE; ANYOF_BITMAP_ZERO(ret); - listsv = newSVpvn("# comment\n", 10); + listsv = newSVpvs("# comment\n"); } nextvalue = RExC_parse < RExC_end ? UCHARAT(RExC_parse) : 0; @@ -5781,7 +5781,7 @@ Perl_regprop(pTHX_ SV *sv, const regnode *o) k = PL_regkind[(U8)OP(o)]; if (k == EXACT) { - SV * const dsv = sv_2mortal(newSVpvn("", 0)); + SV * const dsv = sv_2mortal(newSVpvs("")); /* Using is_utf8_string() is a crude hack but it may * be the best for now since we have no flag "this EXACTish * node was UTF-8" --jhi */ @@ -5858,12 +5858,12 @@ Perl_regprop(pTHX_ SV *sv, const regnode *o) }; if (flags & ANYOF_LOCALE) - sv_catpv(sv, "{loc}"); + sv_catpvs(sv, "{loc}"); if (flags & ANYOF_FOLD) - sv_catpv(sv, "{i}"); + sv_catpvs(sv, "{i}"); Perl_sv_catpvf(aTHX_ sv, "[%s", PL_colors[0]); if (flags & ANYOF_INVERT) - sv_catpv(sv, "^"); + sv_catpvs(sv, "^"); for (i = 0; i <= 256; i++) { if (i < 256 && ANYOF_BITMAP_TEST(o,i)) { if (rangestart == -1) @@ -5874,7 +5874,7 @@ Perl_regprop(pTHX_ SV *sv, const regnode *o) put_byte(sv, rangestart); else { put_byte(sv, rangestart); - sv_catpv(sv, "-"); + sv_catpvs(sv, "-"); put_byte(sv, i - 1); } rangestart = -1; @@ -5887,9 +5887,9 @@ Perl_regprop(pTHX_ SV *sv, const regnode *o) sv_catpv(sv, anyofs[i]); if (flags & ANYOF_UNICODE) - sv_catpv(sv, "{unicode}"); + sv_catpvs(sv, "{unicode}"); else if (flags & ANYOF_UNICODE_ALL) - sv_catpv(sv, "{unicode_all}"); + sv_catpvs(sv, "{unicode_all}"); { SV *lv; @@ -5918,7 +5918,7 @@ Perl_regprop(pTHX_ SV *sv, const regnode *o) U8 *p; for (p = s; p < e; p++) put_byte(sv, *p); - sv_catpvn(sv, "-", 1); + sv_catpvs(sv, "-"); e = uvchr_to_utf8(s, i-1); for (p = s; p < e; p++) put_byte(sv, *p); @@ -5927,7 +5927,7 @@ Perl_regprop(pTHX_ SV *sv, const regnode *o) } } - sv_catpv(sv, "..."); /* et cetera */ + sv_catpvs(sv, "..."); /* et cetera */ } { diff --git a/sv.c b/sv.c index 022f936..bd43352 100644 --- a/sv.c +++ b/sv.c @@ -1408,7 +1408,7 @@ S_not_a_number(pTHX_ SV *sv) const char *pv; if (DO_UTF8(sv)) { - dsv = sv_2mortal(newSVpvn("", 0)); + dsv = sv_2mortal(newSVpvs("")); pv = sv_uni_display(dsv, sv, 10, 0); } else { char *d = tmpbuf; @@ -2452,7 +2452,7 @@ Perl_sv_2pv_flags(pTHX_ register SV *sv, STRLEN *lp, I32 flags) const SV *const referent = (SV*)SvRV(sv); if (!referent) { - tsv = sv_2mortal(newSVpvn("NULLREF", 7)); + tsv = sv_2mortal(newSVpvs("NULLREF")); } else if (SvTYPE(referent) == SVt_PVMG && ((SvFLAGS(referent) & (SVs_OBJECT|SVf_OK|SVs_GMG|SVs_SMG|SVs_RMG)) @@ -8733,7 +8733,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV "\"%%\\%03"UVof"\"", (UV)c & 0xFF); } else - sv_catpv(msg, "end of string"); + sv_catpvs(msg, "end of string"); Perl_warner(aTHX_ packWARN(WARN_PRINTF), "%"SVf, msg); /* yes, this is reentrant */ } @@ -11449,7 +11449,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) case OP_SCHOMP: case OP_CHOMP: if (SvROK(PL_rs) && uninit_sv == SvRV(PL_rs)) - return sv_2mortal(newSVpvn("${$/}", 5)); + return sv_2mortal(newSVpvs("${$/}")); /* FALL THROUGH */ default: diff --git a/sv.h b/sv.h index b5aeac8..f2bbe10 100644 --- a/sv.h +++ b/sv.h @@ -1425,6 +1425,9 @@ Like C but doesn't process magic. #define sv_2iv(sv) sv_2iv_flags(sv, SV_GMAGIC) #define sv_2uv(sv) sv_2uv_flags(sv, SV_GMAGIC) +#define newSVpvs(str) newSVpvn(STR_WITH_LEN(str)) +#define sv_catpvs(sv, str) sv_catpvn_flags(sv, STR_WITH_LEN(str), SV_GMAGIC) + /* Should be named SvCatPVN_utf8_upgrade? */ #define sv_catpvn_utf8_upgrade(dsv, sstr, slen, nsv) \ STMT_START { \ diff --git a/toke.c b/toke.c index be5fae2..c99f8af 100644 --- a/toke.c +++ b/toke.c @@ -287,7 +287,7 @@ S_tokereport(pTHX_ I32 rv) const char *name = Nullch; enum token_type type = TOKENTYPE_NONE; const struct debug_tokens *p; - SV* const report = newSVpvn("<== ", 4); + SV* const report = newSVpvs("<== "); for (p = debug_tokens; p->token; p++) { if (p->token == (int)rv) { @@ -301,7 +301,7 @@ S_tokereport(pTHX_ I32 rv) else if ((char)rv > ' ' && (char)rv < '~') Perl_sv_catpvf(aTHX_ report, "'%c'", (char)rv); else if (!rv) - Perl_sv_catpv(aTHX_ report, "EOF"); + sv_catpvs(report, "EOF"); else Perl_sv_catpvf(aTHX_ report, "?? %"IVdf, (IV)rv); switch (type) { @@ -329,7 +329,7 @@ S_tokereport(pTHX_ I32 rv) } else - Perl_sv_catpv(aTHX_ report, "(opval=null)"); + sv_catpvs(report, "(opval=null)"); break; } PerlIO_printf(Perl_debug_log, "### %s\n\n", SvPV_nolen_const(report)); @@ -343,7 +343,7 @@ S_tokereport(pTHX_ I32 rv) STATIC void S_printbuf(pTHX_ const char* fmt, const char* s) { - SV* const tmp = newSVpvn("", 0); + SV* const tmp = newSVpvs(""); PerlIO_printf(Perl_debug_log, fmt, pv_display(tmp, s, strlen(s), 0, 60)); SvREFCNT_dec(tmp); } @@ -609,7 +609,7 @@ Perl_lex_start(pTHX_ SV *line) if (!len || s[len-1] != ';') { if (!(SvFLAGS(PL_linestr) & SVs_TEMP)) PL_linestr = sv_2mortal(newSVsv(PL_linestr)); - sv_catpvn(PL_linestr, "\n;", 2); + sv_catpvs(PL_linestr, "\n;"); } SvTEMP_off(PL_linestr); PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = PL_linestart = SvPVX(PL_linestr); @@ -1290,7 +1290,7 @@ S_sublex_done(pTHX) { dVAR; if (!PL_lex_starts++) { - SV * const sv = newSVpvn("",0); + SV * const sv = newSVpvs(""); if (SvUTF8(PL_linestr)) SvUTF8_on(sv); PL_expect = XOPERATOR; @@ -2421,7 +2421,7 @@ Perl_yylex(pTHX) bool bof = FALSE; DEBUG_T( { - SV* tmp = newSVpvn("", 0); + SV* tmp = newSVpvs(""); PerlIO_printf(Perl_debug_log, "### %"IVdf":LEX_%s/X%s %s\n", (IV)CopLINE(PL_curcop), lex_state_names[PL_lex_state], @@ -2672,21 +2672,21 @@ Perl_yylex(pTHX) PL_preambled = TRUE; sv_setpv(PL_linestr,incl_perldb()); if (SvCUR(PL_linestr)) - sv_catpvn(PL_linestr,";", 1); + sv_catpvs(PL_linestr,";"); if (PL_preambleav){ while(AvFILLp(PL_preambleav) >= 0) { SV *tmpsv = av_shift(PL_preambleav); sv_catsv(PL_linestr, tmpsv); - sv_catpvn(PL_linestr, ";", 1); + sv_catpvs(PL_linestr, ";"); sv_free(tmpsv); } sv_free((SV*)PL_preambleav); PL_preambleav = NULL; } if (PL_minus_n || PL_minus_p) { - sv_catpv(PL_linestr, "LINE: while (<>) {"); + sv_catpvs(PL_linestr, "LINE: while (<>) {"); if (PL_minus_l) - sv_catpv(PL_linestr,"chomp;"); + sv_catpvs(PL_linestr,"chomp;"); if (PL_minus_a) { if (PL_minus_F) { if ((*PL_splitstr == '/' || *PL_splitstr == '\'' @@ -2710,16 +2710,16 @@ Perl_yylex(pTHX) /* This loop will embed the trailing NUL of PL_linestr as the last thing it does before terminating. */ - sv_catpvn(PL_linestr, ");", 2); + sv_catpvs(PL_linestr, ");"); } } else - sv_catpv(PL_linestr,"our @F=split(' ');"); + sv_catpvs(PL_linestr,"our @F=split(' ');"); } } if (PL_minus_E) - sv_catpv(PL_linestr,"use feature ':5.10';"); - sv_catpvn(PL_linestr, "\n", 1); + sv_catpvs(PL_linestr,"use feature ':5.10';"); + sv_catpvs(PL_linestr, "\n"); PL_oldoldbufptr = PL_oldbufptr = s = PL_linestart = SvPVX(PL_linestr); PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); PL_last_lop = PL_last_uni = Nullch; @@ -4281,7 +4281,7 @@ Perl_yylex(pTHX) /* if we saw a global override before, get the right name */ if (gvp) { - sv = newSVpvn("CORE::GLOBAL::",14); + sv = newSVpvs("CORE::GLOBAL::"); sv_catpv(sv,PL_tokenbuf); } else { @@ -5438,7 +5438,7 @@ Perl_yylex(pTHX) sv_setpv(PL_subname, tmpbuf); else { sv_setsv(PL_subname,PL_curstname); - sv_catpvn(PL_subname,"::",2); + sv_catpvs(PL_subname,"::"); sv_catpvn(PL_subname,tmpbuf,len); } s = skipspace(d); @@ -5724,7 +5724,7 @@ S_pending_ident(pTHX) HV * const stash = PAD_COMPNAME_OURSTASH(tmp); HEK * const stashname = HvNAME_HEK(stash); SV * const sym = newSVhek(stashname); - sv_catpvn(sym, "::", 2); + sv_catpvs(sym, "::"); sv_catpv(sym, PL_tokenbuf+1); yylval.opval = (OP*)newSVOP(OP_CONST, 0, sym); yylval.opval->op_private = OPpCONST_ENTERED; @@ -9292,7 +9292,7 @@ S_new_constant(pTHX_ const char *s, STRLEN len, const char *key, SV *sv, SV *pv, /* Check the eval first */ if (!PL_in_eval && SvTRUE(ERRSV)) { - sv_catpv(ERRSV, "Propagated"); + sv_catpvs(ERRSV, "Propagated"); yyerror(SvPV_nolen_const(ERRSV)); /* Duplicates the message inside eval */ (void)POPs; res = SvREFCNT_inc(sv); @@ -9624,12 +9624,12 @@ S_scan_subst(pTHX_ char *start) PL_sublex_info.super_bufend = PL_bufend; PL_multi_end = 0; pm->op_pmflags |= PMf_EVAL; - repl = newSVpvn("",0); + repl = newSVpvs(""); while (es-- > 0) sv_catpv(repl, es ? "eval " : "do "); - sv_catpvn(repl, "{ ", 2); + sv_catpvs(repl, "{ "); sv_catsv(repl, PL_lex_repl); - sv_catpvn(repl, " }", 2); + sv_catpvs(repl, " }"); SvEVALED_on(repl); SvREFCNT_dec(PL_lex_repl); PL_lex_repl = repl; @@ -10008,7 +10008,7 @@ S_scan_inputsymbol(pTHX_ char *start) HV *stash = PAD_COMPNAME_OURSTASH(tmp); HEK *stashname = HvNAME_HEK(stash); SV *sym = sv_2mortal(newSVhek(stashname)); - sv_catpvn(sym, "::", 2); + sv_catpvs(sym, "::"); sv_catpv(sym, d+1); d = SvPVX(sym); goto intro_sym; @@ -10790,7 +10790,7 @@ S_scan_formline(pTHX_ register char *s) { register char *eol; register char *t; - SV *stuff = newSVpvn("",0); + SV *stuff = newSVpvs(""); bool needargs = FALSE; bool eofmt = FALSE; @@ -10980,7 +10980,7 @@ Perl_yyerror(pTHX_ const char *s) where = "within string"; } else { - SV *where_sv = sv_2mortal(newSVpvn("next char ", 10)); + SV *where_sv = sv_2mortal(newSVpvs("next char ")); if (yychar < 32) Perl_sv_catpvf(aTHX_ where_sv, "^%c", toCTRL(yychar)); else if (isPRINT_LC(yychar)) diff --git a/universal.c b/universal.c index 5c147b6..fe76f81 100644 --- a/universal.c +++ b/universal.c @@ -549,7 +549,7 @@ XS(XS_version_boolean) SP -= items; if (sv_derived_from(ST(0), "version")) { SV * const lobj = SvRV(ST(0)); - SV * const rs = newSViv( vcmp(lobj,new_version(newSVpvn("0",1))) ); + SV * const rs = newSViv( vcmp(lobj,new_version(newSVpvs("0"))) ); PUSHs(sv_2mortal(rs)); PUTBACK; return; @@ -900,7 +900,7 @@ XS(XS_PerlIO_get_layers) const IV flags = SvIVX(*flgsvp); if (flags & PERLIO_F_UTF8) { - XPUSHs(newSVpvn("utf8", 4)); + XPUSHs(newSVpvs("utf8")); nitem++; } } diff --git a/utf8.c b/utf8.c index db81e26..6a6930d 100644 --- a/utf8.c +++ b/utf8.c @@ -533,12 +533,12 @@ malformed: } if (dowarn) { - SV* const sv = sv_2mortal(newSVpv("Malformed UTF-8 character ", 0)); + SV* const sv = sv_2mortal(newSVpvs("Malformed UTF-8 character ")); switch (warning) { case 0: /* Intentionally empty. */ break; case UTF8_WARN_EMPTY: - Perl_sv_catpv(aTHX_ sv, "(empty string)"); + sv_catpvs(sv, "(empty string)"); break; case UTF8_WARN_CONTINUATION: Perl_sv_catpvf(aTHX_ sv, "(unexpected continuation byte 0x%02"UVxf", with no preceding start byte)", uv); @@ -577,7 +577,7 @@ malformed: Perl_sv_catpvf(aTHX_ sv, "(character 0x%04"UVxf")", uv); break; default: - Perl_sv_catpv(aTHX_ sv, "(unknown reason)"); + sv_catpvs(sv, "(unknown reason)"); break; } @@ -1777,7 +1777,7 @@ S_swash_get(pTHX_ SV* swash, UV start, UV span) } /* create and initialize $swatch */ - swatch = newSVpvn("",0); + swatch = newSVpvs(""); scur = octets ? (span * octets) : (span + 7) / 8; SvGROW(swatch, scur + 1); s = (U8*)SvPVX(swatch); @@ -2181,7 +2181,7 @@ Perl_pv_uni_display(pTHX_ SV *dsv, const U8 *spv, STRLEN len, STRLEN pvlim, UV f Perl_sv_catpvf(aTHX_ dsv, "\\x{%"UVxf"}", u); } if (truncated) - sv_catpvn(dsv, "...", 3); + sv_catpvs(dsv, "..."); return SvPVX(dsv); } diff --git a/util.c b/util.c index d253126..f868645 100644 --- a/util.c +++ b/util.c @@ -432,7 +432,7 @@ Perl_fbm_compile(pTHX_ SV *sv, U32 flags) if (flags & FBMcf_TAIL) { MAGIC * const mg = SvUTF8(sv) && SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_utf8) : NULL; - sv_catpvn(sv, "\n", 1); /* Taken into account in fbm_instr() */ + sv_catpvs(sv, "\n"); /* Taken into account in fbm_instr() */ if (mg && mg->mg_len >= 0) mg->mg_len++; } @@ -914,7 +914,7 @@ S_mess_alloc(pTHX) XPVMG *any; if (!PL_dirty) - return sv_2mortal(newSVpvn("",0)); + return sv_2mortal(newSVpvs("")); if (PL_mess_sv) return PL_mess_sv; @@ -4308,14 +4308,14 @@ Perl_vnumify(pTHX_ SV *vs) /* attempt to retrieve the version array */ if ( !(av = (AV *)SvRV(*hv_fetch((HV*)vs, "version", 7, FALSE)) ) ) { - sv_catpvn(sv,"0",1); + sv_catpvs(sv,"0"); return sv; } len = av_len(av); if ( len == -1 ) { - sv_catpvn(sv,"0",1); + sv_catpvs(sv,"0"); return sv; } @@ -4338,12 +4338,12 @@ Perl_vnumify(pTHX_ SV *vs) { digit = SvIV(*av_fetch(av, len, 0)); if ( alpha && width == 3 ) /* alpha version */ - sv_catpvn(sv,"_",1); + sv_catpvs(sv,"_"); Perl_sv_catpvf(aTHX_ sv, "%0*d", width, (int)digit); } else /* len == 0 */ { - sv_catpvn(sv,"000",3); + sv_catpvs(sv, "000"); } return sv; } @@ -4382,7 +4382,7 @@ Perl_vnormal(pTHX_ SV *vs) len = av_len(av); if ( len == -1 ) { - sv_catpvn(sv,"",0); + sv_catpvs(sv,""); return sv; } digit = SvIV(*av_fetch(av, 0, 0)); @@ -4404,7 +4404,7 @@ Perl_vnormal(pTHX_ SV *vs) if ( len <= 2 ) { /* short version, must be at least three */ for ( len = 2 - len; len != 0; len-- ) - sv_catpvn(sv,".0",2); + sv_catpvs(sv,".0"); } return sv; } diff --git a/xsutils.c b/xsutils.c index 518e543..4908b16 100644 --- a/xsutils.c +++ b/xsutils.c @@ -217,21 +217,21 @@ usage: case SVt_PVCV: cvflags = CvFLAGS((CV*)sv); if (cvflags & CVf_LOCKED) - XPUSHs(sv_2mortal(newSVpvn("locked", 6))); + XPUSHs(sv_2mortal(newSVpvs("locked"))); #ifdef CVf_LVALUE if (cvflags & CVf_LVALUE) - XPUSHs(sv_2mortal(newSVpvn("lvalue", 6))); + XPUSHs(sv_2mortal(newSVpvs("lvalue"))); #endif if (cvflags & CVf_METHOD) - XPUSHs(sv_2mortal(newSVpvn("method", 6))); + XPUSHs(sv_2mortal(newSVpvs("method"))); if (GvUNIQUE(CvGV((CV*)sv))) - XPUSHs(sv_2mortal(newSVpvn("unique", 6))); + XPUSHs(sv_2mortal(newSVpvs("unique"))); if (cvflags & CVf_ASSERTION) - XPUSHs(sv_2mortal(newSVpvn("assertion", 9))); + XPUSHs(sv_2mortal(newSVpvs("assertion"))); break; case SVt_PVGV: if (GvUNIQUE(sv)) - XPUSHs(sv_2mortal(newSVpvn("unique", 6))); + XPUSHs(sv_2mortal(newSVpvs("unique"))); break; default: break;