This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[patch/ob] Fix decimal point printing in printf
- From: Corinna Vinschen <vinschen at redhat dot com>
- To: newlib at sourceware dot org
- Date: Mon, 15 Feb 2010 17:10:33 +0100
- Subject: [patch/ob] Fix decimal point printing in printf
- Reply-to: newlib at sourceware dot org
Hi,
I applied the below patch as obvious. The latest change to _vfprintf_r
introduced a bug when printing integral float or double values. A buggy
condition printed a decimal point, so that values as "1" were printed as
"1." The below patch fixes that.
Corinna
* libc/stdio/vfprintf.c (_VFPRINTF_R): Drop printing a redundant
decimal point in case the float argument is an integral value.
Index: libc/stdio/vfprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vfprintf.c,v
retrieving revision 1.78
diff -u -p -r1.78 vfprintf.c
--- libc/stdio/vfprintf.c 5 Feb 2010 08:35:35 -0000 1.78
+++ libc/stdio/vfprintf.c 15 Feb 2010 16:10:22 -0000
@@ -1578,7 +1578,7 @@ number: if ((dprec = prec) >= 0)
cp = convbuf + ndig;
}
#endif
- if (prec || flags & ALT)
+ if (expt < ndig || flags & ALT)
PRINT (decimal_point, decp_len);
PRINTANDPAD (cp, convbuf + ndig,
ndig - expt, zeroes);
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat