From 82485375ccac3e5ff6119147e18c7aef62fbf50a Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 20 May 2007 09:01:48 +0000 Subject: [PATCH] Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1. --- ChangeLog | 33 ++++++++ doc/functions/fprintf.texi | 8 +- doc/functions/printf.texi | 8 +- doc/functions/snprintf.texi | 8 +- doc/functions/sprintf.texi | 8 +- doc/functions/vfprintf.texi | 8 +- doc/functions/vprintf.texi | 8 +- doc/functions/vsnprintf.texi | 8 +- doc/functions/vsprintf.texi | 8 +- lib/vasnprintf.c | 71 +++++++++++----- m4/fprintf-posix.m4 | 32 +++++--- m4/printf.m4 | 190 ++++++++++++++++++++++++++++++++----------- m4/snprintf-posix.m4 | 40 +++++---- m4/sprintf-posix.m4 | 32 +++++--- m4/vasnprintf-posix.m4 | 36 ++++---- m4/vasnprintf.m4 | 43 +++++++--- m4/vasprintf-posix.m4 | 36 ++++---- m4/vfprintf-posix.m4 | 32 +++++--- m4/vsnprintf-posix.m4 | 40 +++++---- m4/vsprintf-posix.m4 | 32 +++++--- 20 files changed, 454 insertions(+), 227 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f723bc07..46f6a2224 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,38 @@ 2007-05-20 Bruno Haible + Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1. + * m4/printf.m4 (gl_PRINTF_INFINITE): Update cross-compiling guesses. + (gl_PRINTF_INFINITE_LONG_DOUBLE): New macro. + * lib/vasnprintf.c: Use NEED_PRINTF_INFINITE_DOUBLE instead of + NEED_PRINTF_INFINITE. + (is_infinitel): New function. + (VASNPRINTF): Handle NEED_PRINTF_INFINITE_LONG_DOUBLE case. + * m4/vasnprintf.m4 (gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE): Renamed from + gl_PREREQ_VASNPRINTF_INFINITE. + (gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE): New macro. + * m4/fprintf-posix.m4 (gl_FUNC_FPRINTF_POSIX): Invoke + gl_PRINTF_INFINITE_LONG_DOUBLE and test its result. Invoke + gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE and + gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE instead of + gl_PREREQ_VASNPRINTF_INFINITE. + * m4/snprintf-posix.m4 (gl_FUNC_SNPRINTF_POSIX): Likewise. + * m4/sprintf-posix.m4 (gl_FUNC_SPRINTF_POSIX): Likewise. + * m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_POSIX): Likewise. + * m4/vasprintf-posix.m4 (gl_FUNC_VASPRINTF_POSIX): Likewise. + * m4/vfprintf-posix.m4 (gl_FUNC_VFPRINTF_POSIX): Likewise. + * m4/vsnprintf-posix.m4 (gl_FUNC_VSNPRINTF_POSIX): Likewise. + * m4/vsprintf-posix.m4 (gl_FUNC_VSPRINTF_POSIX): Likewise. + * doc/functions/fprintf.texi: Update. + * doc/functions/printf.texi: Update. + * doc/functions/snprintf.texi: Update. + * doc/functions/sprintf.texi: Update. + * doc/functions/vfprintf.texi: Update. + * doc/functions/vprintf.texi: Update. + * doc/functions/vsnprintf.texi: Update. + * doc/functions/vsprintf.texi: Update. + +2007-05-20 Bruno Haible + * m4/frexpl.m4 (gl_FUNC_FREXPL_NO_LIBM): Set REPLACE_FREXPL if frexpl was not found in libc. * m4/printf-frexpl.m4 (gl_FUNC_PRINTF_FREXPL): Likewise. diff --git a/doc/functions/fprintf.texi b/doc/functions/fprintf.texi index d87f312ad..47382e37e 100644 --- a/doc/functions/fprintf.texi +++ b/doc/functions/fprintf.texi @@ -13,13 +13,13 @@ This function does not support size specifiers as in C99 (@code{hh}, @code{ll}, @code{j}, @code{t}, @code{z}) on some platforms: AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 2006, mingw, BeOS. @item -printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an -incorrect result on some platforms: -mingw. -@item printf of @samp{long double} numbers is unsupported on some platforms: mingw, BeOS. @item +printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an +incorrect result on some platforms: +AIX 5.2, OSF/1 5.1, Solaris 10, mingw. +@item This function does not support the @samp{a} and @samp{A} directives on some platforms: glibc-2.3.6, MacOS X 10.3, NetBSD 3.0, OpenBSD 4.0, AIX 5.2, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin, mingw, BeOS. diff --git a/doc/functions/printf.texi b/doc/functions/printf.texi index 57fe9e38a..9a729fd28 100644 --- a/doc/functions/printf.texi +++ b/doc/functions/printf.texi @@ -13,13 +13,13 @@ This function does not support size specifiers as in C99 (@code{hh}, @code{ll}, @code{j}, @code{t}, @code{z}) on some platforms: AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 2006, mingw, BeOS. @item -printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an -incorrect result on some platforms: -mingw. -@item printf of @samp{long double} numbers is unsupported on some platforms: mingw, BeOS. @item +printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an +incorrect result on some platforms: +AIX 5.2, OSF/1 5.1, Solaris 10, mingw. +@item This function does not support the @samp{a} and @samp{A} directives on some platforms: glibc-2.3.6, MacOS X 10.3, NetBSD 3.0, OpenBSD 4.0, AIX 5.2, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin, mingw, BeOS. diff --git a/doc/functions/snprintf.texi b/doc/functions/snprintf.texi index 5b431bba5..fabc2da9b 100644 --- a/doc/functions/snprintf.texi +++ b/doc/functions/snprintf.texi @@ -20,13 +20,13 @@ This function does not support size specifiers as in C99 (@code{hh}, @code{ll}, @code{j}, @code{t}, @code{z}) on some platforms: AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 2006, mingw, BeOS. @item -printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an -incorrect result on some platforms: -mingw. -@item printf of @samp{long double} numbers is unsupported on some platforms: mingw, BeOS. @item +printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an +incorrect result on some platforms: +AIX 5.2, OSF/1 5.1, Solaris 10, mingw. +@item This function does not support the @samp{a} and @samp{A} directives on some platforms: glibc-2.3.6, MacOS X 10.3, NetBSD 3.0, OpenBSD 4.0, AIX 5.2, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin, mingw, BeOS. diff --git a/doc/functions/sprintf.texi b/doc/functions/sprintf.texi index b7a1b0d19..3ab986f50 100644 --- a/doc/functions/sprintf.texi +++ b/doc/functions/sprintf.texi @@ -13,13 +13,13 @@ This function does not support size specifiers as in C99 (@code{hh}, @code{ll}, @code{j}, @code{t}, @code{z}) on some platforms: AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 2006, mingw, BeOS. @item -printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an -incorrect result on some platforms: -mingw. -@item printf of @samp{long double} numbers is unsupported on some platforms: mingw, BeOS. @item +printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an +incorrect result on some platforms: +AIX 5.2, OSF/1 5.1, Solaris 10, mingw. +@item This function does not support the @samp{a} and @samp{A} directives on some platforms: glibc-2.3.6, MacOS X 10.3, NetBSD 3.0, OpenBSD 4.0, AIX 5.2, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin, mingw, BeOS. diff --git a/doc/functions/vfprintf.texi b/doc/functions/vfprintf.texi index 084a0509e..b499323c6 100644 --- a/doc/functions/vfprintf.texi +++ b/doc/functions/vfprintf.texi @@ -13,13 +13,13 @@ This function does not support size specifiers as in C99 (@code{hh}, @code{ll}, @code{j}, @code{t}, @code{z}) on some platforms: AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 2006, mingw, BeOS. @item -printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an -incorrect result on some platforms: -mingw. -@item printf of @samp{long double} numbers is unsupported on some platforms: mingw, BeOS. @item +printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an +incorrect result on some platforms: +AIX 5.2, OSF/1 5.1, Solaris 10, mingw. +@item This function does not support the @samp{a} and @samp{A} directives on some platforms: glibc-2.3.6, MacOS X 10.3, NetBSD 3.0, OpenBSD 4.0, AIX 5.2, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin, mingw, BeOS. diff --git a/doc/functions/vprintf.texi b/doc/functions/vprintf.texi index 05c6aac26..cb59dfcd4 100644 --- a/doc/functions/vprintf.texi +++ b/doc/functions/vprintf.texi @@ -13,13 +13,13 @@ This function does not support size specifiers as in C99 (@code{hh}, @code{ll}, @code{j}, @code{t}, @code{z}) on some platforms: AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 2006, mingw, BeOS. @item -printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an -incorrect result on some platforms: -mingw. -@item printf of @samp{long double} numbers is unsupported on some platforms: mingw, BeOS. @item +printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an +incorrect result on some platforms: +AIX 5.2, OSF/1 5.1, Solaris 10, mingw. +@item This function does not support the @samp{a} and @samp{A} directives on some platforms: glibc-2.3.6, MacOS X 10.3, NetBSD 3.0, OpenBSD 4.0, AIX 5.2, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin, mingw, BeOS. diff --git a/doc/functions/vsnprintf.texi b/doc/functions/vsnprintf.texi index 616eced39..99e792db6 100644 --- a/doc/functions/vsnprintf.texi +++ b/doc/functions/vsnprintf.texi @@ -20,13 +20,13 @@ This function does not support size specifiers as in C99 (@code{hh}, @code{ll}, @code{j}, @code{t}, @code{z}) on some platforms: AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 2006, mingw, BeOS. @item -printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an -incorrect result on some platforms: -mingw. -@item printf of @samp{long double} numbers is unsupported on some platforms: mingw, BeOS. @item +printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an +incorrect result on some platforms: +AIX 5.2, OSF/1 5.1, Solaris 10, mingw. +@item This function does not support the @samp{a} and @samp{A} directives on some platforms: glibc-2.3.6, MacOS X 10.3, NetBSD 3.0, OpenBSD 4.0, AIX 5.2, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin, mingw, BeOS. diff --git a/doc/functions/vsprintf.texi b/doc/functions/vsprintf.texi index 70aaf31e6..1da495971 100644 --- a/doc/functions/vsprintf.texi +++ b/doc/functions/vsprintf.texi @@ -13,13 +13,13 @@ This function does not support size specifiers as in C99 (@code{hh}, @code{ll}, @code{j}, @code{t}, @code{z}) on some platforms: AIX 5.1, HP-UX 11.23, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 2006, mingw, BeOS. @item -printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an -incorrect result on some platforms: -mingw. -@item printf of @samp{long double} numbers is unsupported on some platforms: mingw, BeOS. @item +printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an +incorrect result on some platforms: +AIX 5.2, OSF/1 5.1, Solaris 10, mingw. +@item This function does not support the @samp{a} and @samp{A} directives on some platforms: glibc-2.3.6, MacOS X 10.3, NetBSD 3.0, OpenBSD 4.0, AIX 5.2, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin, mingw, BeOS. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 696047791..bc5834fa9 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -53,14 +53,19 @@ /* Checked size_t computations. */ #include "xsize.h" -#if NEED_PRINTF_INFINITE && !defined IN_LIBINTL +#if NEED_PRINTF_LONG_DOUBLE && !defined IN_LIBINTL +# include +# include "float+.h" +#endif + +#if NEED_PRINTF_INFINITE_DOUBLE && !defined IN_LIBINTL # include # include "isnan.h" #endif -#if NEED_PRINTF_LONG_DOUBLE && !defined IN_LIBINTL +#if NEED_PRINTF_INFINITE_LONG_DOUBLE && !defined IN_LIBINTL # include -# include "float+.h" +# include "isnanl-nolibm.h" #endif #if NEED_PRINTF_DIRECTIVE_A && !defined IN_LIBINTL @@ -169,7 +174,7 @@ decimal_point_char () # endif #endif -#if NEED_PRINTF_INFINITE && !defined IN_LIBINTL +#if NEED_PRINTF_INFINITE_DOUBLE && !defined IN_LIBINTL /* Equivalent to !isfinite(x) || x == 0, but does not require libm. */ static int @@ -180,6 +185,17 @@ is_infinite_or_zero (double x) #endif +#if NEED_PRINTF_INFINITE_LONG_DOUBLE && !defined IN_LIBINTL + +/* Equivalent to !isfinite(x), but does not require libm. */ +static int +is_infinitel (long double x) +{ + return isnanl (x) || (x + x == x && x != 0.0L); +} + +#endif + #if NEED_PRINTF_LONG_DOUBLE && !defined IN_LIBINTL /* Converting 'long double' to decimal without rare rounding bugs requires @@ -1273,12 +1289,12 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar abort (); } } -#if (NEED_PRINTF_INFINITE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL +#if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL else if ((dp->conversion == 'f' || dp->conversion == 'F' || dp->conversion == 'e' || dp->conversion == 'E' || dp->conversion == 'g' || dp->conversion == 'G') && (0 -# if NEED_PRINTF_INFINITE +# if NEED_PRINTF_INFINITE_DOUBLE || (a.arg[dp->arg_index].type == TYPE_DOUBLE /* The systems (mingw) which produce wrong output for Inf and -Inf also do so for NaN and -0.0. @@ -1287,10 +1303,16 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar # endif # if NEED_PRINTF_LONG_DOUBLE || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE +# elif NEED_PRINTF_INFINITE_LONG_DOUBLE + || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE + /* The systems which produce wrong output for Inf + and -Inf also do so for NaN. Therefore treat + this case here as well. */ + && is_infinitel (a.arg[dp->arg_index].a.a_longdouble)) # endif )) { -# if NEED_PRINTF_INFINITE && NEED_PRINTF_LONG_DOUBLE +# if NEED_PRINTF_INFINITE_DOUBLE && (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) arg_type type = a.arg[dp->arg_index].type; # endif int flags = dp->flags; @@ -1373,17 +1395,17 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar precision = 6; /* Allocate a temporary buffer of sufficient size. */ -# if NEED_PRINTF_INFINITE && NEED_PRINTF_LONG_DOUBLE +# if NEED_PRINTF_INFINITE_DOUBLE && NEED_PRINTF_LONG_DOUBLE tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : 0); # elif NEED_PRINTF_LONG_DOUBLE tmp_length = LDBL_DIG + 1; -# elif NEED_PRINTF_INFINITE +# else tmp_length = 0; # endif if (tmp_length < precision) tmp_length = precision; # if NEED_PRINTF_LONG_DOUBLE -# if NEED_PRINTF_INFINITE +# if NEED_PRINTF_INFINITE_DOUBLE if (type == TYPE_LONGDOUBLE) # endif if (dp->conversion == 'f' || dp->conversion == 'F') @@ -1424,8 +1446,8 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar pad_ptr = NULL; p = tmp; -# if NEED_PRINTF_LONG_DOUBLE -# if NEED_PRINTF_INFINITE +# if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE +# if NEED_PRINTF_INFINITE_DOUBLE if (type == TYPE_LONGDOUBLE) # endif { @@ -1475,6 +1497,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar } else { +# if NEED_PRINTF_LONG_DOUBLE pad_ptr = p; if (dp->conversion == 'f' || dp->conversion == 'F') @@ -1587,15 +1610,15 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar } *p++ = dp->conversion; /* 'e' or 'E' */ -# if WIDE_CHAR_VERSION +# if WIDE_CHAR_VERSION { static const wchar_t decimal_format[] = { '%', '+', '.', '2', 'd', '\0' }; SNPRINTF (p, 6 + 1, decimal_format, exponent); } -# else +# else sprintf (p, "%+.2d", exponent); -# endif +# endif while (*p != '\0') p++; } @@ -1731,15 +1754,15 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar } } *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ -# if WIDE_CHAR_VERSION +# if WIDE_CHAR_VERSION { static const wchar_t decimal_format[] = { '%', '+', '.', '2', 'd', '\0' }; SNPRINTF (p, 6 + 1, decimal_format, exponent); } -# else +# else sprintf (p, "%+.2d", exponent); -# endif +# endif while (*p != '\0') p++; } @@ -1749,16 +1772,20 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar } else abort (); +# else + /* arg is finite. */ + abort (); +# endif } END_LONG_DOUBLE_ROUNDING (); } } -# if NEED_PRINTF_INFINITE +# if NEED_PRINTF_INFINITE_DOUBLE else # endif # endif -# if NEED_PRINTF_INFINITE +# if NEED_PRINTF_INFINITE_DOUBLE { /* Simpler than above: handle only NaN, Infinity, zero. */ double arg = a.arg[dp->arg_index].a.a_double; @@ -1832,9 +1859,9 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar *p++ = '+'; /* Produce the same number of exponent digits as the native printf implementation. */ -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ *p++ = '0'; -# endif +# endif *p++ = '0'; *p++ = '0'; } diff --git a/m4/fprintf-posix.m4 b/m4/fprintf-posix.m4 index 9242684f1..dfade559f 100644 --- a/m4/fprintf-posix.m4 +++ b/m4/fprintf-posix.m4 @@ -8,8 +8,9 @@ AC_DEFUN([gl_FUNC_FPRINTF_POSIX], [ AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) - AC_REQUIRE([gl_PRINTF_INFINITE]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) + AC_REQUIRE([gl_PRINTF_INFINITE]) + AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_A]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_F]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_N]) @@ -19,25 +20,29 @@ AC_DEFUN([gl_FUNC_FPRINTF_POSIX], gl_cv_func_fprintf_posix=no case "$gl_cv_func_printf_sizes_c99" in *yes) - case "$gl_cv_func_printf_infinite" in + case "$gl_cv_func_printf_long_double" in *yes) - case "$gl_cv_func_printf_long_double" in + case "$gl_cv_func_printf_infinite" in *yes) - case "$gl_cv_func_printf_directive_a" in + case "$gl_cv_func_printf_infinite_long_double" in *yes) - case "$gl_cv_func_printf_directive_f" in + case "$gl_cv_func_printf_directive_a" in *yes) - case "$gl_cv_func_printf_directive_n" in + case "$gl_cv_func_printf_directive_f" in *yes) - case "$gl_cv_func_printf_positions" in + case "$gl_cv_func_printf_directive_n" in *yes) - case "$gl_cv_func_printf_flag_grouping" in + case "$gl_cv_func_printf_positions" in *yes) - case "$gl_cv_func_printf_flag_zero" in + case "$gl_cv_func_printf_flag_grouping" in *yes) - # fprintf exists and is already POSIX - # compliant. - gl_cv_func_fprintf_posix=yes + case "$gl_cv_func_printf_flag_zero" in + *yes) + # fprintf exists and is already POSIX + # compliant. + gl_cv_func_fprintf_posix=yes + ;; + esac ;; esac ;; @@ -57,8 +62,9 @@ AC_DEFUN([gl_FUNC_FPRINTF_POSIX], ;; esac if test $gl_cv_func_fprintf_posix = no; then - gl_PREREQ_VASNPRINTF_INFINITE gl_PREREQ_VASNPRINTF_LONG_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE gl_PREREQ_VASNPRINTF_DIRECTIVE_A gl_PREREQ_VASNPRINTF_DIRECTIVE_F gl_PREREQ_VASNPRINTF_FLAG_GROUPING diff --git a/m4/printf.m4 b/m4/printf.m4 index 16e40ccaf..59d56c86b 100644 --- a/m4/printf.m4 +++ b/m4/printf.m4 @@ -1,4 +1,4 @@ -# printf.m4 serial 11 +# printf.m4 serial 12 dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -164,14 +164,108 @@ int main () [ changequote(,)dnl case "$host_os" in - mingw* | pw*) gl_cv_func_printf_infinite="guessing no";; - *) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on FreeBSD >= 6. + freebsd[1-5]*) gl_cv_func_printf_infinite="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";; + darwin*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on HP-UX >= 11. + hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";; + hpux*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on IRIX >= 6.5. + irix6.5) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_printf_infinite="guessing no";; + netbsd*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_printf_infinite="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_printf_infinite="guessing no";; esac changequote([,])dnl ]) ]) ]) +dnl Test whether the *printf family of functions supports infinite 'long double' +dnl arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001) +dnl Result is gl_cv_func_printf_infinite_long_double. + +AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE], +[ + AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + case "$gl_cv_func_printf_long_double" in + *yes) + AC_CACHE_CHECK([whether printf supports infinite 'long double' arguments], + [gl_cv_func_printf_infinite_long_double], + [ + AC_TRY_RUN([ +#include +#include +static char buf[100]; +int main () +{ + if (sprintf (buf, "%Lf", 1.0L / 0.0L) < 0 + || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) + return 1; + if (sprintf (buf, "%Lf", -1.0L / 0.0L) < 0 + || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) + return 1; + if (sprintf (buf, "%Le", 1.0L / 0.0L) < 0 + || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) + return 1; + if (sprintf (buf, "%Le", -1.0L / 0.0L) < 0 + || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) + return 1; + if (sprintf (buf, "%Lg", 1.0L / 0.0L) < 0 + || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) + return 1; + if (sprintf (buf, "%Lg", -1.0L / 0.0L) < 0 + || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) + return 1; + return 0; +}], + [gl_cv_func_printf_infinite_long_double=yes], + [gl_cv_func_printf_infinite_long_double=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on FreeBSD >= 6. + freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_printf_infinite_long_double="guessing no";; + darwin*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on HP-UX >= 11. + hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; + hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on IRIX >= 6.5. + irix6.5) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_printf_infinite_long_double="guessing no";; + netbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_printf_infinite_long_double="guessing no";; + esac +changequote([,])dnl + ]) + ]) + ;; + *) + gl_cv_func_printf_infinite_long_double="irrelevant" + ;; + esac +]) + dnl Test whether the *printf family of functions supports the 'a' and 'A' dnl conversion specifier for hexadecimal output of floating-point numbers. dnl (ISO C99, POSIX:2001) @@ -755,54 +849,56 @@ dnl dnl 1 = gl_PRINTF_SIZES_C99 dnl 2 = gl_PRINTF_LONG_DOUBLE dnl 3 = gl_PRINTF_INFINITE -dnl 4 = gl_PRINTF_DIRECTIVE_A -dnl 5 = gl_PRINTF_DIRECTIVE_F -dnl 6 = gl_PRINTF_DIRECTIVE_N -dnl 7 = gl_PRINTF_POSITIONS -dnl 8 = gl_PRINTF_FLAG_GROUPING -dnl 9 = gl_PRINTF_FLAG_ZERO -dnl 10 = gl_SNPRINTF_PRESENCE -dnl 11 = gl_SNPRINTF_TRUNCATION_C99 -dnl 12 = gl_SNPRINTF_RETVAL_C99 -dnl 13 = gl_SNPRINTF_DIRECTIVE_N -dnl 14 = gl_VSNPRINTF_ZEROSIZE_C99 +dnl 4 = gl_PRINTF_INFINITE_LONG_DOUBLE +dnl 5 = gl_PRINTF_DIRECTIVE_A +dnl 6 = gl_PRINTF_DIRECTIVE_F +dnl 7 = gl_PRINTF_DIRECTIVE_N +dnl 8 = gl_PRINTF_POSITIONS +dnl 9 = gl_PRINTF_FLAG_GROUPING +dnl 10 = gl_PRINTF_FLAG_ZERO +dnl 11 = gl_SNPRINTF_PRESENCE +dnl 12 = gl_SNPRINTF_TRUNCATION_C99 +dnl 13 = gl_SNPRINTF_RETVAL_C99 +dnl 14 = gl_SNPRINTF_DIRECTIVE_N +dnl 15 = gl_VSNPRINTF_ZEROSIZE_C99 dnl dnl 1 = checking whether printf supports size specifiers as in C99... dnl 2 = checking whether printf supports 'long double' arguments... dnl 3 = checking whether printf supports infinite 'double' arguments... -dnl 4 = checking whether printf supports the 'a' and 'A' directives... -dnl 5 = checking whether printf supports the 'F' directive... -dnl 6 = checking whether printf supports the 'n' directive... -dnl 7 = checking whether printf supports POSIX/XSI format strings with positions... -dnl 8 = checking whether printf supports the grouping flag... -dnl 9 = checking whether printf supports the zero flag correctly... -dnl 10 = checking for snprintf... -dnl 11 = checking whether snprintf truncates the result as in C99... -dnl 12 = checking whether snprintf returns a byte count as in C99... -dnl 13 = checking whether snprintf fully supports the 'n' directive... -dnl 14 = checking whether vsnprintf respects a zero size as in C99... +dnl 4 = checking whether printf supports infinite 'long double' arguments... +dnl 5 = checking whether printf supports the 'a' and 'A' directives... +dnl 6 = checking whether printf supports the 'F' directive... +dnl 7 = checking whether printf supports the 'n' directive... +dnl 8 = checking whether printf supports POSIX/XSI format strings with positions... +dnl 9 = checking whether printf supports the grouping flag... +dnl 10 = checking whether printf supports the zero flag correctly... +dnl 11 = checking for snprintf... +dnl 12 = checking whether snprintf truncates the result as in C99... +dnl 13 = checking whether snprintf returns a byte count as in C99... +dnl 14 = checking whether snprintf fully supports the 'n' directive... +dnl 15 = checking whether vsnprintf respects a zero size as in C99... dnl dnl . = yes, # = no. dnl -dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 -dnl glibc 2.5 . . . . . . . . . . . . . . -dnl glibc 2.3.6 . . . # . . . . . . . . . . -dnl FreeBSD 5.4, 6.1 . ? . ? . . . . # . . . . . -dnl MacOS X 10.3.9 . . . # . . . . # . . . . . -dnl OpenBSD 3.9, 4.0 . ? ? # ? . . ? ? . . . ? ? -dnl Cygwin 2007 (= Cygwin 1.5.24) . ? ? # # . . . # . . . . . -dnl Cygwin 2006 (= Cygwin 1.5.19) # ? ? # # . . # # . . . . . -dnl Solaris 10 . . ? # . . . . # . . . . . -dnl Solaris 2.6 ... 9 # . ? # # . . . # . . . . . -dnl Solaris 2.5.1 # . # # # . . . # # # # # # -dnl AIX 5.2 . . ? # . . . . # . . . . . -dnl AIX 4.3.2, 5.1 # . # # # . . . # . . . . . -dnl HP-UX 11.31 . . . # . . . . # . . # # . -dnl HP-UX 10.20, 11.{00,11,23} # . . # # . . . # . . # # # -dnl IRIX 6.5 # . . # # . . . # . . # . . -dnl OSF/1 5.1 # . ? # # . . . # . . # . # -dnl OSF/1 4.0d # . # # # . . . # # # # # # -dnl NetBSD 4.0 . ? ? ? ? . . ? ? . . . ? ? -dnl NetBSD 3.0 . ? ? # # . # # # . . . . . -dnl BeOS # # ? # # . # . . . . . . . -dnl mingw # # # # # . # # # . # # # . +dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +dnl glibc 2.5 . . . . . . . . . . . . . . . +dnl glibc 2.3.6 . . . . # . . . . . . . . . . +dnl FreeBSD 5.4, 6.1 . . . . # . . . . # . . . . . +dnl MacOS X 10.3.9 . . . . # . . . . # . . . . . +dnl OpenBSD 3.9, 4.0 . ? ? ? # ? . . ? ? . . . ? ? +dnl Cygwin 2007 (= Cygwin 1.5.24) . ? ? ? # # . . . # . . . . . +dnl Cygwin 2006 (= Cygwin 1.5.19) # ? ? ? # # . . # # . . . . . +dnl Solaris 10 . . # # # . . . . # . . . . . +dnl Solaris 2.6 ... 9 # . # # # # . . . # . . . . . +dnl Solaris 2.5.1 # . # # # # . . . # # # # # # +dnl AIX 5.2 . . # # # . . . . # . . . . . +dnl AIX 4.3.2, 5.1 # . # # # # . . . # . . . . . +dnl HP-UX 11.31 . . . . # . . . . # . . # # . +dnl HP-UX 10.20, 11.{00,11,23} # . . . # # . . . # . . # # # +dnl IRIX 6.5 # . . . # # . . . # . . # . . +dnl OSF/1 5.1 # . # # # # . . . # . . # . # +dnl OSF/1 4.0d # . # # # # . . . # # # # # # +dnl NetBSD 4.0 . ? ? ? ? ? . . ? ? . . . ? ? +dnl NetBSD 3.0 . . . . # # . # # # . . . . . +dnl BeOS # # . # # # . # . . . . . . . +dnl mingw # # # # # # . # # # . # # # . diff --git a/m4/snprintf-posix.m4 b/m4/snprintf-posix.m4 index 99f11ecd4..d7d451124 100644 --- a/m4/snprintf-posix.m4 +++ b/m4/snprintf-posix.m4 @@ -8,8 +8,9 @@ AC_DEFUN([gl_FUNC_SNPRINTF_POSIX], [ AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) - AC_REQUIRE([gl_PRINTF_INFINITE]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) + AC_REQUIRE([gl_PRINTF_INFINITE]) + AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_A]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_F]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_N]) @@ -25,33 +26,37 @@ AC_DEFUN([gl_FUNC_SNPRINTF_POSIX], gl_VSNPRINTF_ZEROSIZE_C99 case "$gl_cv_func_printf_sizes_c99" in *yes) - case "$gl_cv_func_printf_infinite" in + case "$gl_cv_func_printf_long_double" in *yes) - case "$gl_cv_func_printf_long_double" in + case "$gl_cv_func_printf_infinite" in *yes) - case "$gl_cv_func_printf_directive_a" in + case "$gl_cv_func_printf_infinite_long_double" in *yes) - case "$gl_cv_func_printf_directive_f" in + case "$gl_cv_func_printf_directive_a" in *yes) - case "$gl_cv_func_printf_directive_n" in + case "$gl_cv_func_printf_directive_f" in *yes) - case "$gl_cv_func_printf_positions" in + case "$gl_cv_func_printf_directive_n" in *yes) - case "$gl_cv_func_printf_flag_grouping" in + case "$gl_cv_func_printf_positions" in *yes) - case "$gl_cv_func_printf_flag_zero" in + case "$gl_cv_func_printf_flag_grouping" in *yes) - case "$gl_cv_func_snprintf_truncation_c99" in + case "$gl_cv_func_printf_flag_zero" in *yes) - case "$gl_cv_func_snprintf_retval_c99" in + case "$gl_cv_func_snprintf_truncation_c99" in *yes) - case "$gl_cv_func_snprintf_directive_n" in + case "$gl_cv_func_snprintf_retval_c99" in *yes) - case "$gl_cv_func_vsnprintf_zerosize_c99" in + case "$gl_cv_func_snprintf_directive_n" in *yes) - # snprintf exists and is - # already POSIX compliant. - gl_cv_func_snprintf_posix=yes + case "$gl_cv_func_vsnprintf_zerosize_c99" in + *yes) + # snprintf exists and is + # already POSIX compliant. + gl_cv_func_snprintf_posix=yes + ;; + esac ;; esac ;; @@ -80,8 +85,9 @@ AC_DEFUN([gl_FUNC_SNPRINTF_POSIX], esac fi if test $gl_cv_func_snprintf_posix = no; then - gl_PREREQ_VASNPRINTF_INFINITE gl_PREREQ_VASNPRINTF_LONG_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE gl_PREREQ_VASNPRINTF_DIRECTIVE_A gl_PREREQ_VASNPRINTF_DIRECTIVE_F gl_PREREQ_VASNPRINTF_FLAG_GROUPING diff --git a/m4/sprintf-posix.m4 b/m4/sprintf-posix.m4 index 7d844d340..6fc75231f 100644 --- a/m4/sprintf-posix.m4 +++ b/m4/sprintf-posix.m4 @@ -8,8 +8,9 @@ AC_DEFUN([gl_FUNC_SPRINTF_POSIX], [ AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) - AC_REQUIRE([gl_PRINTF_INFINITE]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) + AC_REQUIRE([gl_PRINTF_INFINITE]) + AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_A]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_F]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_N]) @@ -19,25 +20,29 @@ AC_DEFUN([gl_FUNC_SPRINTF_POSIX], gl_cv_func_sprintf_posix=no case "$gl_cv_func_printf_sizes_c99" in *yes) - case "$gl_cv_func_printf_infinite" in + case "$gl_cv_func_printf_long_double" in *yes) - case "$gl_cv_func_printf_long_double" in + case "$gl_cv_func_printf_infinite" in *yes) - case "$gl_cv_func_printf_directive_a" in + case "$gl_cv_func_printf_infinite_long_double" in *yes) - case "$gl_cv_func_printf_directive_f" in + case "$gl_cv_func_printf_directive_a" in *yes) - case "$gl_cv_func_printf_directive_n" in + case "$gl_cv_func_printf_directive_f" in *yes) - case "$gl_cv_func_printf_positions" in + case "$gl_cv_func_printf_directive_n" in *yes) - case "$gl_cv_func_printf_flag_grouping" in + case "$gl_cv_func_printf_positions" in *yes) - case "$gl_cv_func_printf_flag_zero" in + case "$gl_cv_func_printf_flag_grouping" in *yes) - # sprintf exists and is already POSIX - # compliant. - gl_cv_func_sprintf_posix=yes + case "$gl_cv_func_printf_flag_zero" in + *yes) + # sprintf exists and is already POSIX + # compliant. + gl_cv_func_sprintf_posix=yes + ;; + esac ;; esac ;; @@ -57,8 +62,9 @@ AC_DEFUN([gl_FUNC_SPRINTF_POSIX], ;; esac if test $gl_cv_func_sprintf_posix = no; then - gl_PREREQ_VASNPRINTF_INFINITE gl_PREREQ_VASNPRINTF_LONG_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE gl_PREREQ_VASNPRINTF_DIRECTIVE_A gl_PREREQ_VASNPRINTF_DIRECTIVE_F gl_PREREQ_VASNPRINTF_FLAG_GROUPING diff --git a/m4/vasnprintf-posix.m4 b/m4/vasnprintf-posix.m4 index ac56fe352..ecc075f8c 100644 --- a/m4/vasnprintf-posix.m4 +++ b/m4/vasnprintf-posix.m4 @@ -8,8 +8,9 @@ AC_DEFUN([gl_FUNC_VASNPRINTF_POSIX], [ AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) - AC_REQUIRE([gl_PRINTF_INFINITE]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) + AC_REQUIRE([gl_PRINTF_INFINITE]) + AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_A]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_F]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_N]) @@ -20,27 +21,31 @@ AC_DEFUN([gl_FUNC_VASNPRINTF_POSIX], AC_CHECK_FUNCS_ONCE([vasnprintf]) case "$gl_cv_func_printf_sizes_c99" in *yes) - case "$gl_cv_func_printf_infinite" in + case "$gl_cv_func_printf_long_double" in *yes) - case "$gl_cv_func_printf_long_double" in + case "$gl_cv_func_printf_infinite" in *yes) - case "$gl_cv_func_printf_directive_a" in + case "$gl_cv_func_printf_infinite_long_double" in *yes) - case "$gl_cv_func_printf_directive_f" in + case "$gl_cv_func_printf_directive_a" in *yes) - case "$gl_cv_func_printf_directive_n" in + case "$gl_cv_func_printf_directive_f" in *yes) - case "$gl_cv_func_printf_positions" in + case "$gl_cv_func_printf_directive_n" in *yes) - case "$gl_cv_func_printf_flag_grouping" in + case "$gl_cv_func_printf_positions" in *yes) - case "$gl_cv_func_printf_flag_zero" in + case "$gl_cv_func_printf_flag_grouping" in *yes) - if test $ac_cv_func_vasnprintf = yes; then - # vasnprintf exists and is already POSIX - # compliant. - gl_cv_func_vasnprintf_posix=yes - fi + case "$gl_cv_func_printf_flag_zero" in + *yes) + if test $ac_cv_func_vasnprintf = yes; then + # vasnprintf exists and is already + # POSIX compliant. + gl_cv_func_vasnprintf_posix=yes + fi + ;; + esac ;; esac ;; @@ -60,8 +65,9 @@ AC_DEFUN([gl_FUNC_VASNPRINTF_POSIX], ;; esac if test $gl_cv_func_vasnprintf_posix = no; then - gl_PREREQ_VASNPRINTF_INFINITE gl_PREREQ_VASNPRINTF_LONG_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE gl_PREREQ_VASNPRINTF_DIRECTIVE_A gl_PREREQ_VASNPRINTF_DIRECTIVE_F gl_PREREQ_VASNPRINTF_FLAG_GROUPING diff --git a/m4/vasnprintf.m4 b/m4/vasnprintf.m4 index ecbb28175..fa953aaf2 100644 --- a/m4/vasnprintf.m4 +++ b/m4/vasnprintf.m4 @@ -59,34 +59,57 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF], AC_CHECK_FUNCS(snprintf wcslen) ]) +# Extra prerequisites of lib/vasnprintf.c for supporting 'long double' +# arguments. +AC_DEFUN([gl_PREREQ_VASNPRINTF_LONG_DOUBLE], +[ + AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) + case "$gl_cv_func_printf_long_double" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], 1, + [Define if the vasnprintf implementation needs special code for + 'long double' arguments.]) + ;; + esac +]) + # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double' # arguments. -AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE], +AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE], [ AC_REQUIRE([gl_PRINTF_INFINITE]) case "$gl_cv_func_printf_infinite" in *yes) ;; *) - AC_DEFINE([NEED_PRINTF_INFINITE], 1, + AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], 1, [Define if the vasnprintf implementation needs special code for infinite 'double' arguments.]) ;; esac ]) -# Extra prerequisites of lib/vasnprintf.c for supporting 'long double' +# Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double' # arguments. -AC_DEFUN([gl_PREREQ_VASNPRINTF_LONG_DOUBLE], +AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE], [ - AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) + AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE]) + dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if + dnl NEED_PRINTF_LONG_DOUBLE is already set. + AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE]) case "$gl_cv_func_printf_long_double" in *yes) - ;; - *) - AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], 1, - [Define if the vasnprintf implementation needs special code for - 'long double' arguments.]) + case "$gl_cv_func_printf_infinite" in + *yes) + ;; + *) + AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], 1, + [Define if the vasnprintf implementation needs special code for + infinite 'long double' arguments.]) + ;; + esac ;; esac ]) diff --git a/m4/vasprintf-posix.m4 b/m4/vasprintf-posix.m4 index 279e0def4..ab26ef594 100644 --- a/m4/vasprintf-posix.m4 +++ b/m4/vasprintf-posix.m4 @@ -8,8 +8,9 @@ AC_DEFUN([gl_FUNC_VASPRINTF_POSIX], [ AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) - AC_REQUIRE([gl_PRINTF_INFINITE]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) + AC_REQUIRE([gl_PRINTF_INFINITE]) + AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_A]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_F]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_N]) @@ -20,27 +21,31 @@ AC_DEFUN([gl_FUNC_VASPRINTF_POSIX], AC_CHECK_FUNCS([vasprintf]) case "$gl_cv_func_printf_sizes_c99" in *yes) - case "$gl_cv_func_printf_infinite" in + case "$gl_cv_func_printf_long_double" in *yes) - case "$gl_cv_func_printf_long_double" in + case "$gl_cv_func_printf_infinite" in *yes) - case "$gl_cv_func_printf_directive_a" in + case "$gl_cv_func_printf_infinite_long_double" in *yes) - case "$gl_cv_func_printf_directive_f" in + case "$gl_cv_func_printf_directive_a" in *yes) - case "$gl_cv_func_printf_directive_n" in + case "$gl_cv_func_printf_directive_f" in *yes) - case "$gl_cv_func_printf_positions" in + case "$gl_cv_func_printf_directive_n" in *yes) - case "$gl_cv_func_printf_flag_grouping" in + case "$gl_cv_func_printf_positions" in *yes) - case "$gl_cv_func_printf_flag_zero" in + case "$gl_cv_func_printf_flag_grouping" in *yes) - if test $ac_cv_func_vasprintf = yes; then - # vasprintf exists and is already POSIX - # compliant. - gl_cv_func_vasprintf_posix=yes - fi + case "$gl_cv_func_printf_flag_zero" in + *yes) + if test $ac_cv_func_vasprintf = yes; then + # vasprintf exists and is already + # POSIX compliant. + gl_cv_func_vasprintf_posix=yes + fi + ;; + esac ;; esac ;; @@ -60,8 +65,9 @@ AC_DEFUN([gl_FUNC_VASPRINTF_POSIX], ;; esac if test $gl_cv_func_vasprintf_posix = no; then - gl_PREREQ_VASNPRINTF_INFINITE gl_PREREQ_VASNPRINTF_LONG_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE gl_PREREQ_VASNPRINTF_DIRECTIVE_A gl_PREREQ_VASNPRINTF_DIRECTIVE_F gl_PREREQ_VASNPRINTF_FLAG_GROUPING diff --git a/m4/vfprintf-posix.m4 b/m4/vfprintf-posix.m4 index bf936f14e..aefa6fdf3 100644 --- a/m4/vfprintf-posix.m4 +++ b/m4/vfprintf-posix.m4 @@ -8,8 +8,9 @@ AC_DEFUN([gl_FUNC_VFPRINTF_POSIX], [ AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) - AC_REQUIRE([gl_PRINTF_INFINITE]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) + AC_REQUIRE([gl_PRINTF_INFINITE]) + AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_A]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_F]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_N]) @@ -19,25 +20,29 @@ AC_DEFUN([gl_FUNC_VFPRINTF_POSIX], gl_cv_func_vfprintf_posix=no case "$gl_cv_func_printf_sizes_c99" in *yes) - case "$gl_cv_func_printf_infinite" in + case "$gl_cv_func_printf_long_double" in *yes) - case "$gl_cv_func_printf_long_double" in + case "$gl_cv_func_printf_infinite" in *yes) - case "$gl_cv_func_printf_directive_a" in + case "$gl_cv_func_printf_infinite_long_double" in *yes) - case "$gl_cv_func_printf_directive_f" in + case "$gl_cv_func_printf_directive_a" in *yes) - case "$gl_cv_func_printf_directive_n" in + case "$gl_cv_func_printf_directive_f" in *yes) - case "$gl_cv_func_printf_positions" in + case "$gl_cv_func_printf_directive_n" in *yes) - case "$gl_cv_func_printf_flag_grouping" in + case "$gl_cv_func_printf_positions" in *yes) - case "$gl_cv_func_printf_flag_zero" in + case "$gl_cv_func_printf_flag_grouping" in *yes) - # vfprintf exists and is already POSIX - # compliant. - gl_cv_func_vfprintf_posix=yes + case "$gl_cv_func_printf_flag_zero" in + *yes) + # vfprintf exists and is already + # POSIX compliant. + gl_cv_func_vfprintf_posix=yes + ;; + esac ;; esac ;; @@ -57,8 +62,9 @@ AC_DEFUN([gl_FUNC_VFPRINTF_POSIX], ;; esac if test $gl_cv_func_vfprintf_posix = no; then - gl_PREREQ_VASNPRINTF_INFINITE gl_PREREQ_VASNPRINTF_LONG_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE gl_PREREQ_VASNPRINTF_DIRECTIVE_A gl_PREREQ_VASNPRINTF_DIRECTIVE_F gl_PREREQ_VASNPRINTF_FLAG_GROUPING diff --git a/m4/vsnprintf-posix.m4 b/m4/vsnprintf-posix.m4 index 29189863b..a4855f3b2 100644 --- a/m4/vsnprintf-posix.m4 +++ b/m4/vsnprintf-posix.m4 @@ -8,8 +8,9 @@ AC_DEFUN([gl_FUNC_VSNPRINTF_POSIX], [ AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) - AC_REQUIRE([gl_PRINTF_INFINITE]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) + AC_REQUIRE([gl_PRINTF_INFINITE]) + AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_A]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_F]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_N]) @@ -26,33 +27,37 @@ AC_DEFUN([gl_FUNC_VSNPRINTF_POSIX], gl_VSNPRINTF_ZEROSIZE_C99 case "$gl_cv_func_printf_sizes_c99" in *yes) - case "$gl_cv_func_printf_infinite" in + case "$gl_cv_func_printf_long_double" in *yes) - case "$gl_cv_func_printf_long_double" in + case "$gl_cv_func_printf_infinite" in *yes) - case "$gl_cv_func_printf_directive_a" in + case "$gl_cv_func_printf_infinite_long_double" in *yes) - case "$gl_cv_func_printf_directive_f" in + case "$gl_cv_func_printf_directive_a" in *yes) - case "$gl_cv_func_printf_directive_n" in + case "$gl_cv_func_printf_directive_f" in *yes) - case "$gl_cv_func_printf_positions" in + case "$gl_cv_func_printf_directive_n" in *yes) - case "$gl_cv_func_printf_flag_grouping" in + case "$gl_cv_func_printf_positions" in *yes) - case "$gl_cv_func_printf_flag_zero" in + case "$gl_cv_func_printf_flag_grouping" in *yes) - case "$gl_cv_func_snprintf_truncation_c99" in + case "$gl_cv_func_printf_flag_zero" in *yes) - case "$gl_cv_func_snprintf_retval_c99" in + case "$gl_cv_func_snprintf_truncation_c99" in *yes) - case "$gl_cv_func_snprintf_directive_n" in + case "$gl_cv_func_snprintf_retval_c99" in *yes) - case "$gl_cv_func_vsnprintf_zerosize_c99" in + case "$gl_cv_func_snprintf_directive_n" in *yes) - # vsnprintf exists and is - # already POSIX compliant. - gl_cv_func_vsnprintf_posix=yes + case "$gl_cv_func_vsnprintf_zerosize_c99" in + *yes) + # vsnprintf exists and is + # already POSIX compliant. + gl_cv_func_vsnprintf_posix=yes + ;; + esac ;; esac ;; @@ -81,8 +86,9 @@ AC_DEFUN([gl_FUNC_VSNPRINTF_POSIX], esac fi if test $gl_cv_func_vsnprintf_posix = no; then - gl_PREREQ_VASNPRINTF_INFINITE gl_PREREQ_VASNPRINTF_LONG_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE gl_PREREQ_VASNPRINTF_DIRECTIVE_A gl_PREREQ_VASNPRINTF_DIRECTIVE_F gl_PREREQ_VASNPRINTF_FLAG_GROUPING diff --git a/m4/vsprintf-posix.m4 b/m4/vsprintf-posix.m4 index de4466163..144fc585a 100644 --- a/m4/vsprintf-posix.m4 +++ b/m4/vsprintf-posix.m4 @@ -8,8 +8,9 @@ AC_DEFUN([gl_FUNC_VSPRINTF_POSIX], [ AC_REQUIRE([gl_EOVERFLOW]) AC_REQUIRE([gl_PRINTF_SIZES_C99]) - AC_REQUIRE([gl_PRINTF_INFINITE]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) + AC_REQUIRE([gl_PRINTF_INFINITE]) + AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_A]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_F]) AC_REQUIRE([gl_PRINTF_DIRECTIVE_N]) @@ -19,25 +20,29 @@ AC_DEFUN([gl_FUNC_VSPRINTF_POSIX], gl_cv_func_vsprintf_posix=no case "$gl_cv_func_printf_sizes_c99" in *yes) - case "$gl_cv_func_printf_infinite" in + case "$gl_cv_func_printf_long_double" in *yes) - case "$gl_cv_func_printf_long_double" in + case "$gl_cv_func_printf_infinite" in *yes) - case "$gl_cv_func_printf_directive_a" in + case "$gl_cv_func_printf_infinite_long_double" in *yes) - case "$gl_cv_func_printf_directive_f" in + case "$gl_cv_func_printf_directive_a" in *yes) - case "$gl_cv_func_printf_directive_n" in + case "$gl_cv_func_printf_directive_f" in *yes) - case "$gl_cv_func_printf_positions" in + case "$gl_cv_func_printf_directive_n" in *yes) - case "$gl_cv_func_printf_flag_grouping" in + case "$gl_cv_func_printf_positions" in *yes) - case "$gl_cv_func_printf_flag_zero" in + case "$gl_cv_func_printf_flag_grouping" in *yes) - # vsprintf exists and is already POSIX - # compliant. - gl_cv_func_vsprintf_posix=yes + case "$gl_cv_func_printf_flag_zero" in + *yes) + # vsprintf exists and is already + # POSIX compliant. + gl_cv_func_vsprintf_posix=yes + ;; + esac ;; esac ;; @@ -57,8 +62,9 @@ AC_DEFUN([gl_FUNC_VSPRINTF_POSIX], ;; esac if test $gl_cv_func_vsprintf_posix = no; then - gl_PREREQ_VASNPRINTF_INFINITE gl_PREREQ_VASNPRINTF_LONG_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE + gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE gl_PREREQ_VASNPRINTF_DIRECTIVE_A gl_PREREQ_VASNPRINTF_DIRECTIVE_F gl_PREREQ_VASNPRINTF_FLAG_GROUPING -- 2.11.0