aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Schultz <das@FreeBSD.org>2003-04-19 23:53:19 +0000
committerDavid Schultz <das@FreeBSD.org>2003-04-19 23:53:19 +0000
commit1f2a0cdf581815ce88168a56079eba4a3e149770 (patch)
tree519d7da30b0d8498849fc8af728bb292a52e27a9
parent0fa05eae77f9d53b8bfc0d4fae55cd3904393b4c (diff)
downloadsrc-1f2a0cdf581815ce88168a56079eba4a3e149770.tar.gz
src-1f2a0cdf581815ce88168a56079eba4a3e149770.zip
%E-like %g and %G conversions should remove trailing zeroes unless
the # flag is present. Implement this behavior and add a comment describing it. Noticed by: Enache Adrian <enache@rdslink.ro> Pointy hat to: das
Notes
Notes: svn path=/head/; revision=113723
-rw-r--r--lib/libc/stdio/vfprintf.c7
-rw-r--r--lib/libc/stdio/vfwprintf.c7
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index 0f0cf5291f35..6125db3db8cc 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -920,6 +920,13 @@ fp_begin:
prec = ndig - expt;
if (prec < 0)
prec = 0;
+ } else {
+ /*
+ * Make %[gG] smell like %[eE], but
+ * trim trailing zeroes if no # flag.
+ */
+ if (!(flags & ALT))
+ prec = ndig;
}
}
if (expchar) {
diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c
index ee50d6408447..3c2392bd0801 100644
--- a/lib/libc/stdio/vfwprintf.c
+++ b/lib/libc/stdio/vfwprintf.c
@@ -889,6 +889,13 @@ fp_begin:
prec = ndig - expt;
if (prec < 0)
prec = 0;
+ } else {
+ /*
+ * Make %[gG] smell like %[eE], but
+ * trim trailing zeroes if no # flag.
+ */
+ if (!(flags & ALT))
+ prec = ndig;
}
}
if (expchar) {