This is the mail archive of the 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

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:

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.

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 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 <>

* 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).

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