"Marco Bodrato" <bodr...@mail.dm.unipi.it> writes: > Maybe in printf/repl-vsnprintf.c we may also remove the > > #ifdef DBL_MAX_10_EXP > > and unconditionaly set double_digits = DBL_MAX_10_EXP.
Like below, then. Torbjörn, what do you think? Are you aware of any system we'd like to support but which lacks float.h? Regards, /Niels diff -r 384bf781a7ee printf/repl-vsnprintf.c --- a/printf/repl-vsnprintf.c Sun Mar 11 19:22:32 2018 +0100 +++ b/printf/repl-vsnprintf.c Sun Mar 25 12:59:24 2018 +0200 @@ -44,9 +44,7 @@ see https://www.gnu.org/licenses/. */ #include <stdio.h> /* for NULL */ #include <stdlib.h> -#if HAVE_FLOAT_H #include <float.h> /* for DBL_MAX_10_EXP etc */ -#endif #if HAVE_INTTYPES_H # include <inttypes.h> /* for intmax_t */ @@ -102,7 +100,7 @@ int const char *fmt; size_t total_width, integer_sizeof, floating_sizeof, len; char fchar, type; - int width, prec, seen_prec, double_digits, long_double_digits; + int width, prec, seen_prec; int *value; /* preserve orig_ap for use after size estimation */ @@ -124,28 +122,6 @@ int floating_sizeof = MAX (floating_sizeof, sizeof (long double)); #endif - /* IEEE double or VAX G floats have an 11 bit exponent, so the default is - a maximum 308 decimal digits. VAX D floats have only an 8 bit - exponent, but we don't bother trying to detect that directly. */ - double_digits = 308; -#ifdef DBL_MAX_10_EXP - /* but in any case prefer a value the compiler says */ - double_digits = DBL_MAX_10_EXP; -#endif - - /* IEEE 128-bit quad, Intel 80-bit temporary, or VAX H floats all have 15 - bit exponents, so the default is a maximum 4932 decimal digits. */ - long_double_digits = 4932; - /* but if double == long double, then go with that size */ -#if HAVE_LONG_DOUBLE - if (sizeof (double) == sizeof (long double)) - long_double_digits = double_digits; -#endif -#ifdef LDBL_MAX_10_EXP - /* but in any case prefer a value the compiler says */ - long_double_digits = LDBL_MAX_10_EXP; -#endif - for (;;) { fmt = strchr (fmt, '%'); @@ -253,7 +229,7 @@ int { #if HAVE_LONG_DOUBLE (void) va_arg (ap, long double); - total_width += long_double_digits; + total_width += LDBL_MAX_10_EXP; #else ASSERT_FAIL (long double not available); #endif @@ -261,7 +237,7 @@ int else { (void) va_arg (ap, double); - total_width += double_digits; + total_width += DBL_MAX_10_EXP; } break; -- Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677. Internet email is subject to wholesale government surveillance. _______________________________________________ gmp-devel mailing list gmp-devel@gmplib.org https://gmplib.org/mailman/listinfo/gmp-devel