/* util.c
*
* Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- * 2000, 2001, 2002, 2003, 2004, by Larry Wall and others
+ * 2000, 2001, 2002, 2003, 2004, 2005, by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
Perl_savepv(pTHX_ const char *pv)
{
register char *newaddr;
+#ifdef PERL_MALLOC_WRAP
+ STRLEN pvlen;
+#endif
if (!pv)
return Nullch;
+#ifdef PERL_MALLOC_WRAP
+ pvlen = strlen(pv)+1;
+ New(902,newaddr,pvlen,char);
+#else
New(902,newaddr,strlen(pv)+1,char);
+#endif
return strcpy(newaddr,pv);
}
return strcpy(newaddr,pv);
}
+/*
+=for apidoc savesvpv
+
+A version of C<savepv()>/C<savepvn()> which gets the string to duplicate from
+the passed in SV using C<SvPV()>
+
+=cut
+*/
+
+char *
+Perl_savesvpv(pTHX_ SV *sv)
+{
+ STRLEN len;
+ const char *pv = SvPV(sv, len);
+ register char *newaddr;
+
+ ++len;
+ New(903,newaddr,len,char);
+ return CopyD(pv,newaddr,len,char);
+}
/* the SV for Perl_form() and mess() is not kept in an arena */
register I32 This, that;
register Pid_t pid;
SV *sv;
- I32 doexec = strNE(cmd,"-");
+ I32 doexec = !(*cmd == '-' && cmd[1] == '\0');
I32 did_pipes = 0;
int pp[2];
#endif
else /* must be a string or something like a string */
{
- STRLEN n_a;
- version = savepv(SvPV(ver,n_a));
+ version = savesvpv(ver);
}
(void)scan_version(version, ver, qv);
Safefree(version);