[patch/ob] Fix decimal point printing in printf

Corinna Vinschen vinschen@redhat.com
Mon Feb 15 16:10:00 GMT 2010


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



More information about the Newlib mailing list