This is the mail archive of the
mailing list for the newlib project.
Re: [PATCH] printf("%#f") format specifier bug
- From: Jeff Johnston <jjohnstn at redhat dot com>
- To: Eric Blake <ebb9 at byu dot net>
- Cc: newlib at sourceware dot org
- Date: Mon, 23 Apr 2007 17:56:18 -0400
- Subject: Re: [PATCH] printf("%#f") format specifier bug
- References: <4627413C.1C602138@dessent.net> <46291A97.email@example.com>
Patch checked in with modified ChangeLog entry as mentioned below.
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:
Before the patch:
Error in line 593 using "%#6.f". Result is " -0"; should be: "
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.
then it dawned on me:
$ printf %#4.f/ -0.1
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 <firstname.lastname@example.org>
* 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).