summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-11-04 20:47:34 +0000
committerNicholas Clark <nick@ccl4.org>2005-11-04 20:47:34 +0000
commit86c11942206ec09dd2a486bb22552aa2f170e322 (patch)
treeda93ee724d8086efae3d2841ff113c9bcaa813f9
parentca563b4e7524b82fcbffcbe3344a4a9d20a7ab64 (diff)
downloadperl-86c11942206ec09dd2a486bb22552aa2f170e322.tar.gz
Use the return value from sprintf().
p4raw-id: //depot/perl@26001
-rw-r--r--regcomp.c4
-rw-r--r--taint.c5
-rw-r--r--universal.c4
-rw-r--r--util.c33
4 files changed, 25 insertions, 21 deletions
diff --git a/regcomp.c b/regcomp.c
index d86083160a..d288eb0450 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -6218,8 +6218,8 @@ Perl_save_re_context(pTHX)
for (i = 1; i <= rx->nparens; i++) {
GV *mgv;
char digits[TYPE_CHARS(long)];
- sprintf(digits, "%lu", (long)i);
- if ((mgv = gv_fetchpv(digits, FALSE, SVt_PV)))
+ const STRLEN len = sprintf(digits, "%lu", (long)i);
+ if ((mgv = gv_fetchpvn_flags(digits, len, FALSE, SVt_PV)))
save_scalar(mgv);
}
}
diff --git a/taint.c b/taint.c
index e0869a9bad..ed1af7453b 100644
--- a/taint.c
+++ b/taint.c
@@ -107,11 +107,12 @@ Perl_taint_env(pTHX)
{
int i = 0;
char name[10 + TYPE_DIGITS(int)] = "DCL$PATH";
+ STRLEN len = 8; /* strlen(name) */
while (1) {
if (i)
- (void)sprintf(name,"DCL$PATH;%d", i);
- svp = hv_fetch(GvHVn(PL_envgv), name, strlen(name), FALSE);
+ len = my_sprintf(name,"DCL$PATH;%d", i);
+ svp = hv_fetch(GvHVn(PL_envgv), name, len, FALSE);
if (!svp || *svp == &PL_sv_undef)
break;
if (SvTAINTED(*svp)) {
diff --git a/universal.c b/universal.c
index 57b9481cd1..f8fa9cda88 100644
--- a/universal.c
+++ b/universal.c
@@ -602,8 +602,8 @@ XS(XS_version_qv)
if ( SvNOK(ver) ) /* may get too much accuracy */
{
char tbuf[64];
- sprintf(tbuf,"%.9"NVgf, SvNVX(ver));
- version = savepv(tbuf);
+ const STRLEN len = my_sprintf(tbuf,"%.9"NVgf, SvNVX(ver));
+ version = savepvn(tbuf, len);
}
else
{
diff --git a/util.c b/util.c
index 6c5605c224..fad5520bea 100644
--- a/util.c
+++ b/util.c
@@ -4150,8 +4150,8 @@ Perl_upg_version(pTHX_ SV *ver)
if ( SvNOK(ver) ) /* may get too much accuracy */
{
char tbuf[64];
- sprintf(tbuf,"%.9"NVgf, SvNVX(ver));
- version = savepv(tbuf);
+ const STRLEN len = my_sprintf(tbuf,"%.9"NVgf, SvNVX(ver));
+ version = savepvn(tbuf, len);
}
#ifdef SvVOK
else if ( SvVOK(ver) ) { /* already a v-string */
@@ -5020,11 +5020,12 @@ Perl_mem_log_alloc(const UV n, const UV typesize, const char *typename, Malloc_t
#ifdef PERL_MEM_LOG_STDERR
/* We can't use PerlIO for obvious reasons. */
char buf[PERL_MEM_LOG_SPRINTF_BUF_SIZE];
- sprintf(buf,
- "alloc: %s:%d:%s: %"IVdf" %"UVuf" %s = %"IVdf": %"UVxf"\n",
- filename, linenumber, funcname,
- n, typesize, typename, n * typesize, PTR2UV(newalloc));
- PerlLIO_write(2, buf, strlen(buf));
+ const STRLEN len = my_sprintf(buf,
+ "alloc: %s:%d:%s: %"IVdf" %"UVuf
+ " %s = %"IVdf": %"UVxf"\n",
+ filename, linenumber, funcname, n, typesize,
+ typename, n * typesize, PTR2UV(newalloc));
+ PerlLIO_write(2, buf, len));
#endif
return newalloc;
}
@@ -5035,11 +5036,12 @@ Perl_mem_log_realloc(const UV n, const UV typesize, const char *typename, Malloc
#ifdef PERL_MEM_LOG_STDERR
/* We can't use PerlIO for obvious reasons. */
char buf[PERL_MEM_LOG_SPRINTF_BUF_SIZE];
- sprintf(buf,
- "realloc: %s:%d:%s: %"IVdf" %"UVuf" %s = %"IVdf": %"UVxf" -> %"UVxf"\n",
- filename, linenumber, funcname,
- n, typesize, typename, n * typesize, PTR2UV(oldalloc), PTR2UV(newalloc));
- PerlLIO_write(2, buf, strlen(buf));
+ const STRLEN len = my_sprintf(buf, "realloc: %s:%d:%s: %"IVdf" %"UVuf
+ " %s = %"IVdf": %"UVxf" -> %"UVxf"\n",
+ filename, linenumber, funcname, n, typesize,
+ typename, n * typesize, PTR2UV(oldalloc),
+ PTR2UV(newalloc));
+ PerlLIO_write(2, buf, len);
#endif
return newalloc;
}
@@ -5050,9 +5052,10 @@ Perl_mem_log_free(Malloc_t oldalloc, const char *filename, const int linenumber,
#ifdef PERL_MEM_LOG_STDERR
/* We can't use PerlIO for obvious reasons. */
char buf[PERL_MEM_LOG_SPRINTF_BUF_SIZE];
- sprintf(buf, "free: %s:%d:%s: %"UVxf"\n",
- filename, linenumber, funcname, PTR2UV(oldalloc));
- PerlLIO_write(2, buf, strlen(buf));
+ const STRLEN len = my_sprintf(buf, "free: %s:%d:%s: %"UVxf"\n",
+ filename, linenumber, funcname,
+ PTR2UV(oldalloc));
+ PerlLIO_write(2, buf, len);
#endif
return oldalloc;
}