# HG changeset patch # User Bruno Haible # Date 1194306117 -3600 # Node ID 265fad13afeb2c1dc292e61ea7d95e41ab37a86d # Parent 19e60ffc2be6d614ab9ecfe09f3425bef802962a Fix the processing of finite numbers with the 'a' and 'A' directives. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-11-05 Bruno Haible + + * lib/vasnprintf.c (VASNPRINTF): Expand the NEED_PRINTF_DIRECTIVE_A + code when NEED_PRINTF_LONG_DOUBLE or NEED_PRINTF_DOUBLE is set. + Needed on Cygwin, where !NEED_PRINTF_DIRECTIVE_A && NEED_PRINTF_DOUBLE. + Reported by Eric Blake. + 2007-10-27 Ralf Wildenhues Bruno Haible diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -104,10 +104,14 @@ # include "fpucw.h" #endif -#if NEED_PRINTF_DIRECTIVE_A && !defined IN_LIBINTL +#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL # include # include "isnan.h" # include "printf-frexp.h" +#endif + +#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL +# include # include "isnanl-nolibm.h" # include "printf-frexpl.h" # include "fpucw.h" @@ -2033,8 +2037,19 @@ } } #endif -#if NEED_PRINTF_DIRECTIVE_A && !defined IN_LIBINTL - else if (dp->conversion == 'a' || dp->conversion == 'A') +#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL + else if ((dp->conversion == 'a' || dp->conversion == 'A') +# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE)) + && (0 +# if NEED_PRINTF_DOUBLE + || a.arg[dp->arg_index].type == TYPE_DOUBLE +# endif +# if NEED_PRINTF_LONG_DOUBLE + || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE +# endif + ) +# endif + ) { arg_type type = a.arg[dp->arg_index].type; int flags = dp->flags; @@ -2152,6 +2167,7 @@ p = tmp; if (type == TYPE_LONGDOUBLE) { +# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE long double arg = a.arg[dp->arg_index].a.a_longdouble; if (isnanl (arg)) @@ -2271,7 +2287,7 @@ } } *p++ = dp->conversion - 'A' + 'P'; -# if WIDE_CHAR_VERSION +# if WIDE_CHAR_VERSION { static const wchar_t decimal_format[] = { '%', '+', 'd', '\0' }; @@ -2279,7 +2295,7 @@ } while (*p != '\0') p++; -# else +# else if (sizeof (DCHAR_T) == 1) { sprintf ((char *) p, "%+d", exponent); @@ -2294,14 +2310,18 @@ for (ep = expbuf; (*p = *ep) != '\0'; ep++) p++; } -# endif +# endif } END_LONG_DOUBLE_ROUNDING (); } +# else + abort (); +# endif } else { +# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE double arg = a.arg[dp->arg_index].a.a_double; if (isnan (arg)) @@ -2418,7 +2438,7 @@ } } *p++ = dp->conversion - 'A' + 'P'; -# if WIDE_CHAR_VERSION +# if WIDE_CHAR_VERSION { static const wchar_t decimal_format[] = { '%', '+', 'd', '\0' }; @@ -2426,7 +2446,7 @@ } while (*p != '\0') p++; -# else +# else if (sizeof (DCHAR_T) == 1) { sprintf ((char *) p, "%+d", exponent); @@ -2441,9 +2461,12 @@ for (ep = expbuf; (*p = *ep) != '\0'; ep++) p++; } -# endif +# endif } } +# else + abort (); +# endif } /* The generated string now extends from tmp to p, with the zero padding insertion point being at pad_ptr. */