summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2015-11-28 22:22:25 -0500
committerSteve Hay <steve.m.hay@googlemail.com>2015-11-29 18:25:50 +0000
commit4b0ae52dee99f81c20d3a8d6b59c926e54eb8fa3 (patch)
treee520b3c3092743fb44981c9c88652e93fc47c474
parentcbd5787eaf5b59c8e7a12e94625c3c1e4dbade7b (diff)
downloadperl-4b0ae52dee99f81c20d3a8d6b59c926e54eb8fa3.tar.gz
hexfp: printf %.13a 1.0
(cherry picked from commit 454ce668d507a01bfb2497b01aa728006848b750)
-rw-r--r--sv.c4
-rw-r--r--t/op/sprintf2.t3
2 files changed, 5 insertions, 2 deletions
diff --git a/sv.c b/sv.c
index 805d0e0a73..17607e59f8 100644
--- a/sv.c
+++ b/sv.c
@@ -12415,8 +12415,8 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
*p++ = xdig[*v++];
/* The radix is always output after the first
- * non-zero xdigit, or if alt. */
- if (vfnz < vlnz || alt) {
+ * non-zero xdigit, or if precis, or if alt. */
+ if (vfnz < vlnz || precis > 0 || alt) {
#ifndef USE_LOCALE_NUMERIC
*p++ = '.';
#else
diff --git a/t/op/sprintf2.t b/t/op/sprintf2.t
index 6aa994ca9d..1f0c515d3d 100644
--- a/t/op/sprintf2.t
+++ b/t/op/sprintf2.t
@@ -67,6 +67,9 @@ if ($Config{nvsize} == 8 &&
[ '% 20.10a', '3.14', ' 0x1.91eb851eb8p+1' ],
[ '%020.10a', '3.14', '0x0001.91eb851eb8p+1' ],
+ [ '%.13a', '1', '0x1.0000000000000p+0' ],
+ [ '%.13a', '-1', '-0x1.0000000000000p+0' ],
+
[ '%30a', '3.14', ' 0x1.91eb851eb851fp+1' ],
[ '%-30a', '3.14', '0x1.91eb851eb851fp+1 ' ],
[ '%030a', '3.14', '0x00000000001.91eb851eb851fp+1' ],