[PATCH] printf("%#f") format specifier bug
Jeff Johnston
jjohnstn@redhat.com
Mon Apr 23 23:05:00 GMT 2007
Patch checked in with modified ChangeLog entry as mentioned below.
-- Jeff
Eric Blake wrote:
> 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).
>
>
More information about the Newlib
mailing list