This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] printf("%#f") format specifier bug


According to Brian Dessent on 4/19/2007 4:15 AM:
> When the 'alternate-form' printf flag (#) is used with floating point
> output types, the spec says that a trailing decimal must be output. 
> However, newlib currently gets this wrong.
> 
> I used the tfformat.c testcase from glibc to check this:
> <http://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/libc/stdio-common/tfformat.c?cvsroot=glibc>
> 
> Before the patch:
> 
> Error in line 593 using "%#6.f".  Result is "   -0"; should be: "  
> -0.".

Prior to looking at the glibc test, it took me a while to figure out how
you were seeing the bug, when using cygwin's bash printf builtin:

$ printf %#4.f/ -0.
 -0./

then it dawned on me:

$ printf %#4.f/ -0.1
 -0/

> 
> With the patch, the only errors left are %a (which I believe Eric Blake
> has already tackled):

Yes, I am working on %a, but it's harder than I thought.  frexp and frexpf
are already present in libc (I had been afraid that they were only in
libm, but fortunately discovered MATHOBJS_IN_LIBC in the newlib
Makefile.am).  But there is no frexpl (or many other long double
variants), so part of correctly implementing %a will be augmenting the
math library with more long double support.

> 2007-04-19  Brian Dessent  <brian@dessent.net>
> 
> 	* libc/stdio/vfprintf.c (_vfprintf_r): When the alternate-form flag
> 	has been specified with types 'e', 'E', or 'f', ensure the trailing
> 	decimal is printed.

This patch looks correct to me.  But the changelog is a bit off; you were
only patching f, F, g, and G (e and E were already correct).

-- 
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@byu.net

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]