[patch] %e in vfprintf
DJ Delorie
dj@delorie.com
Wed Jul 12 15:31:00 GMT 2000
OK to apply? Here's the original bug report from the Cygwin list:
> The latest net release of gcc seems to have a slight bug in the %e print
> format specifier. It prints garbage when you try to print a variable whose
> value is zero.
>
> For example, attached is a (very) short program that does nothing but print
> two variables, with values 0 and 1 respectively. I'd show the output, but it
> contains several null characters which don't seem to cut/paste very well.
> The basic result is that the 1 variable works fine. The zero variable prints
> stuff it shouldn't.
>
> #include <stdio.h>
>
> int main(int argc, char *argv[])
> {
> double tt = 0.0;
> double uu = 1.0;
>
> printf("tt = %e\n", tt);
> printf("uu = %e\n", uu);
> return 0;
> }
2000-07-12 DJ Delorie <dj@cygnus.com>
* libc/stdio/vfprintf.c: pad 0.0 correctly with %e
Index: libc/stdio/vfprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vfprintf.c,v
retrieving revision 1.3
diff -p -2 -r1.3 libc/stdio/vfprintf.c
*** vfprintf.c 2000/04/17 17:10:16 1.3
--- vfprintf.c 2000/07/12 22:27:31
*************** number: if ((dprec = prec) >= 0)
*** 825,829 ****
ox[1] = '.';
PRINT(ox, 2);
! if (_double || (flags & ALT) == 0) {
PRINT(cp, ndig-1);
} else /* 0.[0..] */
--- 825,829 ----
ox[1] = '.';
PRINT(ox, 2);
! if (_double) {
PRINT(cp, ndig-1);
} else /* 0.[0..] */
More information about the Newlib
mailing list