summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-10-28 10:24:43 +0000
committerNicholas Clark <nick@ccl4.org>2005-10-28 10:24:43 +0000
commit4150c1890ffe73fc298ab9944c3d80e0d6511038 (patch)
tree0d250e872190d623d80126517519bb50e2a30d13
parent74af07f22d4e66739ed9bf90220ae0c162150d08 (diff)
downloadperl-4150c1890ffe73fc298ab9944c3d80e0d6511038.tar.gz
Use the return value from sprintf and avoid a call to strlen
p4raw-id: //depot/perl@25862
-rw-r--r--sv.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/sv.c b/sv.c
index 53ef6e09ee..f18950276e 100644
--- a/sv.c
+++ b/sv.c
@@ -9642,8 +9642,11 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV
aka precis is 0 */
if ( c == 'g' && precis) {
Gconvert((NV)nv, (int)precis, 0, PL_efloatbuf);
- if (*PL_efloatbuf) /* May return an empty string for digits==0 */
+ /* May return an empty string for digits==0 */
+ if (*PL_efloatbuf) {
+ elen = strlen(PL_efloatbuf);
goto float_converted;
+ }
} else if ( c == 'f' && !precis) {
if ((eptr = F0convert(nv, ebuf + sizeof ebuf, &elen)))
break;
@@ -9687,17 +9690,15 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV
* where printf() taints but print($float) doesn't.
* --jhi */
#if defined(HAS_LONG_DOUBLE)
- if (intsize == 'q')
- (void)sprintf(PL_efloatbuf, ptr, nv);
- else
- (void)sprintf(PL_efloatbuf, ptr, (double)nv);
+ elen = ((intsize == 'q')
+ ? my_sprintf(PL_efloatbuf, ptr, nv)
+ : my_sprintf(PL_efloatbuf, ptr, (double)nv));
#else
- (void)sprintf(PL_efloatbuf, ptr, nv);
+ elen = my_sprintf(PL_efloatbuf, ptr, nv);
#endif
}
float_converted:
eptr = PL_efloatbuf;
- elen = strlen(PL_efloatbuf);
break;
/* SPECIAL */