diff options
Diffstat (limited to '')
-rw-r--r-- | m4/printf.m4 | 538 |
1 files changed, 329 insertions, 209 deletions
diff --git a/m4/printf.m4 b/m4/printf.m4 index efb85a5..6f91777 100644 --- a/m4/printf.m4 +++ b/m4/printf.m4 @@ -1,5 +1,5 @@ -# printf.m4 serial 82 -dnl Copyright (C) 2003, 2007-2023 Free Software Foundation, Inc. +# printf.m4 serial 90 +dnl Copyright (C) 2003, 2007-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -86,7 +86,8 @@ changequote(,)dnl linux*-android*) gl_cv_func_printf_sizes_c99="guessing yes";; changequote([,])dnl # Guess yes on MSVC, no on mingw. - mingw*) AC_EGREP_CPP([Known], [ + windows*-msvc*) gl_cv_func_printf_sizes_c99="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ #ifdef _MSC_VER Known #endif @@ -179,7 +180,7 @@ int main () # Guess no on Android. linux*-android*) gl_cv_func_printf_sizes_c23="guessing no";; # Guess no on native Windows. - mingw*) gl_cv_func_printf_sizes_c23="guessing no";; + mingw* | windows*) gl_cv_func_printf_sizes_c23="guessing no";; # If we don't know, obey --enable-cross-guesses. *) gl_cv_func_printf_sizes_c23="$gl_cross_guess_normal";; esac @@ -223,20 +224,21 @@ int main () [gl_cv_func_printf_long_double=yes], [gl_cv_func_printf_long_double=no], [case "$host_os" in - # Guess no on BeOS. - beos*) gl_cv_func_printf_long_double="guessing no";; - # Guess yes on Android. - linux*-android*) gl_cv_func_printf_long_double="guessing yes";; - # Guess yes on MSVC, no on mingw. - mingw*) AC_EGREP_CPP([Known], [ + # Guess no on BeOS. + beos*) gl_cv_func_printf_long_double="guessing no";; + # Guess yes on Android. + linux*-android*) gl_cv_func_printf_long_double="guessing yes";; + # Guess yes on MSVC, no on mingw. + windows*-msvc*) gl_cv_func_printf_long_double="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ #ifdef _MSC_VER Known #endif - ], - [gl_cv_func_printf_long_double="guessing yes"], - [gl_cv_func_printf_long_double="guessing no"]) - ;; - *) gl_cv_func_printf_long_double="guessing yes";; + ], + [gl_cv_func_printf_long_double="guessing yes"], + [gl_cv_func_printf_long_double="guessing no"]) + ;; + *) gl_cv_func_printf_long_double="guessing yes";; esac ]) ]) @@ -354,7 +356,8 @@ changequote(,)dnl linux*-android*) gl_cv_func_printf_infinite="guessing no";; changequote([,])dnl # Guess yes on MSVC, no on mingw. - mingw*) AC_EGREP_CPP([Known], [ + windows*-msvc*) gl_cv_func_printf_infinite="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ #ifdef _MSC_VER Known #endif @@ -568,7 +571,8 @@ changequote(,)dnl linux*-android*) gl_cv_func_printf_infinite_long_double="guessing no";; changequote([,])dnl # Guess yes on MSVC, no on mingw. - mingw*) AC_EGREP_CPP([Known], [ + windows*-msvc*) gl_cv_func_printf_infinite_long_double="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ #ifdef _MSC_VER Known #endif @@ -681,7 +685,7 @@ int main () # Guess no on Android. linux*-android*) gl_cv_func_printf_directive_a="guessing no";; # Guess no on native Windows. - mingw*) gl_cv_func_printf_directive_a="guessing no";; + mingw* | windows*) gl_cv_func_printf_directive_a="guessing no";; # If we don't know, obey --enable-cross-guesses. *) gl_cv_func_printf_directive_a="$gl_cross_guess_normal";; esac @@ -736,7 +740,7 @@ int main () # Guess no on Android. linux*-android*) gl_cv_func_printf_directive_b="guessing no";; # Guess no on native Windows. - mingw*) gl_cv_func_printf_directive_b="guessing no";; + mingw* | windows*) gl_cv_func_printf_directive_b="guessing no";; # If we don't know, obey --enable-cross-guesses. *) gl_cv_func_printf_directive_b="$gl_cross_guess_normal";; esac @@ -791,7 +795,7 @@ int main () # Guess no on Android. linux*-android*) gl_cv_func_printf_directive_uppercase_b="guessing no";; # Guess no on native Windows. - mingw*) gl_cv_func_printf_directive_uppercase_b="guessing no";; + mingw* | windows*) gl_cv_func_printf_directive_uppercase_b="guessing no";; # If we don't know, obey --enable-cross-guesses. *) gl_cv_func_printf_directive_uppercase_b="$gl_cross_guess_normal";; esac @@ -857,7 +861,8 @@ changequote(,)dnl linux*-android*) gl_cv_func_printf_directive_f="guessing no";; changequote([,])dnl # Guess yes on MSVC, no on mingw. - mingw*) AC_EGREP_CPP([Known], [ + windows*-msvc*) gl_cv_func_printf_directive_f="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ #ifdef _MSC_VER Known #endif @@ -885,6 +890,7 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_N], [ AC_RUN_IFELSE( [AC_LANG_SOURCE([[ +#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -902,6 +908,12 @@ invalid_parameter_handler (const wchar_t *expression, exit (1); } #endif +static void +abort_handler (int sig) +{ + (void) sig; + _exit (1); +} static char fmtstring[10]; static char buf[100]; int main () @@ -910,6 +922,7 @@ int main () #ifdef _MSC_VER _set_invalid_parameter_handler (invalid_parameter_handler); #endif + signal (SIGABRT, abort_handler); /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) support %n in format strings in read-only memory but not in writable memory. */ @@ -923,21 +936,21 @@ int main () [gl_cv_func_printf_directive_n=yes], [gl_cv_func_printf_directive_n=no], [case "$host_os" in - # Guess no on glibc when _FORTIFY_SOURCE >= 2. - *-gnu* | gnu*) AC_COMPILE_IFELSE( - [AC_LANG_SOURCE( - [[#if _FORTIFY_SOURCE >= 2 - error fail - #endif - ]])], - [gl_cv_func_printf_directive_n="guessing yes"], - [gl_cv_func_printf_directive_n="guessing no"]) - ;; - # Guess no on Android. - linux*-android*) gl_cv_func_printf_directive_n="guessing no";; - # Guess no on native Windows. - mingw*) gl_cv_func_printf_directive_n="guessing no";; - *) gl_cv_func_printf_directive_n="guessing yes";; + # Guess no on glibc when _FORTIFY_SOURCE >= 2. + *-gnu* | gnu*) AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if _FORTIFY_SOURCE >= 2 + error fail + #endif + ]])], + [gl_cv_func_printf_directive_n="guessing yes"], + [gl_cv_func_printf_directive_n="guessing no"]) + ;; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_directive_n="guessing no";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_printf_directive_n="guessing no";; + *) gl_cv_func_printf_directive_n="guessing yes";; esac ]) ]) @@ -1007,18 +1020,18 @@ int main () [ changequote(,)dnl case "$host_os" in - # Guess yes on OpenBSD >= 6.0. - openbsd[1-5].*) gl_cv_func_printf_directive_ls="guessing no";; - openbsd*) gl_cv_func_printf_directive_ls="guessing yes";; - irix*) gl_cv_func_printf_directive_ls="guessing no";; - solaris*) gl_cv_func_printf_directive_ls="guessing no";; - cygwin*) gl_cv_func_printf_directive_ls="guessing no";; - beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; - # Guess no on Android. - linux*-android*) gl_cv_func_printf_directive_ls="guessing no";; - # Guess yes on native Windows. - mingw*) gl_cv_func_printf_directive_ls="guessing yes";; - *) gl_cv_func_printf_directive_ls="guessing yes";; + # Guess yes on OpenBSD >= 6.0. + openbsd[1-5].*) gl_cv_func_printf_directive_ls="guessing no";; + openbsd*) gl_cv_func_printf_directive_ls="guessing yes";; + irix*) gl_cv_func_printf_directive_ls="guessing no";; + solaris*) gl_cv_func_printf_directive_ls="guessing no";; + cygwin*) gl_cv_func_printf_directive_ls="guessing no";; + beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_directive_ls="guessing no";; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_printf_directive_ls="guessing yes";; + *) gl_cv_func_printf_directive_ls="guessing yes";; esac changequote([,])dnl ]) @@ -1027,7 +1040,8 @@ changequote([,])dnl dnl Test whether the *printf family of functions supports the %lc format dnl directive and in particular, when the argument is a null wide character, -dnl whether the functions don't produce a NUL byte. +dnl whether the functions produce a NUL byte, as specified in ISO C 23 +dnl after the issue GB-141 was fixed. dnl Result is gl_cv_func_printf_directive_lc. AC_DEFUN([gl_PRINTF_DIRECTIVE_LC], @@ -1046,13 +1060,11 @@ int main () { int result = 0; char buf[100]; - /* This test fails on glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, - macOS 12.5, AIX 7.2, Solaris 11.4. - glibc 2.35 bug: <https://sourceware.org/bugzilla/show_bug.cgi?id=30257> */ + /* This test fails on musl libc 1.2.4. */ { buf[0] = '\0'; if (sprintf (buf, "%lc%lc%lc", (wint_t) 'a', (wint_t) 0, (wint_t) 'z') < 0 - || strcmp (buf, "az") != 0) + || memcmp (buf, "a\0z", 4) != 0) result |= 1; } return result; @@ -1062,10 +1074,10 @@ int main () [ changequote(,)dnl case "$host_os" in - # Guess yes on musl libc. - *-musl* | midipix*) gl_cv_func_printf_directive_lc="guessing yes";; - # Guess no otherwise. - *) gl_cv_func_printf_directive_lc="guessing no";; + # Guess no on musl libc. + *-musl* | midipix*) gl_cv_func_printf_directive_lc="guessing no";; + # Guess yes otherwise. + *) gl_cv_func_printf_directive_lc="guessing yes";; esac changequote([,])dnl ]) @@ -1102,13 +1114,17 @@ int main () changequote(,)dnl case "$host_os" in netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) - gl_cv_func_printf_positions="guessing no";; - beos*) gl_cv_func_printf_positions="guessing no";; - # Guess yes on Android. - linux*-android*) gl_cv_func_printf_positions="guessing yes";; - # Guess no on native Windows. - mingw* | pw*) gl_cv_func_printf_positions="guessing no";; - *) gl_cv_func_printf_positions="guessing yes";; + gl_cv_func_printf_positions="guessing no";; + beos*) + gl_cv_func_printf_positions="guessing no";; + # Guess yes on Android. + linux*-android*) + gl_cv_func_printf_positions="guessing yes";; + # Guess no on native Windows. + mingw* | windows* | pw*) + gl_cv_func_printf_positions="guessing no";; + *) + gl_cv_func_printf_positions="guessing yes";; esac changequote([,])dnl ]) @@ -1143,13 +1159,13 @@ int main () [ changequote(,)dnl case "$host_os" in - cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; - netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; - # Guess no on Android. - linux*-android*) gl_cv_func_printf_flag_grouping="guessing no";; - # Guess no on native Windows. - mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; - *) gl_cv_func_printf_flag_grouping="guessing yes";; + cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; + netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_printf_flag_grouping="guessing no";; + # Guess no on native Windows. + mingw* | windows* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; + *) gl_cv_func_printf_flag_grouping="guessing yes";; esac changequote([,])dnl ]) @@ -1186,16 +1202,16 @@ int main () [ changequote(,)dnl case "$host_os" in - # Guess yes on HP-UX 11. - hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";; - # Guess no on HP-UX 10 and older. - hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";; - # Guess yes on Android. - linux*-android*) gl_cv_func_printf_flag_leftadjust="guessing yes";; - # Guess yes on native Windows. - mingw*) gl_cv_func_printf_flag_leftadjust="guessing yes";; - # Guess yes otherwise. - *) gl_cv_func_printf_flag_leftadjust="guessing yes";; + # Guess yes on HP-UX 11. + hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";; + # Guess no on HP-UX 10 and older. + hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";; + # Guess yes on Android. + linux*-android*) gl_cv_func_printf_flag_leftadjust="guessing yes";; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_printf_flag_leftadjust="guessing yes";; + # Guess yes otherwise. + *) gl_cv_func_printf_flag_leftadjust="guessing yes";; esac changequote([,])dnl ]) @@ -1242,7 +1258,7 @@ changequote(,)dnl # Guess no on Android. linux*-android*) gl_cv_func_printf_flag_zero="guessing no";; # Guess no on native Windows. - mingw*) gl_cv_func_printf_flag_zero="guessing no";; + mingw* | windows*) gl_cv_func_printf_flag_zero="guessing no";; # If we don't know, obey --enable-cross-guesses. *) gl_cv_func_printf_flag_zero="$gl_cross_guess_normal";; esac @@ -1251,6 +1267,50 @@ changequote([,])dnl ]) ]) +dnl Test whether the *printf family of functions supports the # flag with a +dnl zero precision and a zero value in the 'x' and 'X' directives correctly. +dnl ISO C and POSIX specify that for the 'd', 'i', 'b', 'o', 'u', 'x', 'X' +dnl directives: "The result of converting a zero value with a precision of +dnl zero is no characters." But on Mac OS X 10.5, for the 'x', 'X' directives, +dnl when a # flag is present, the output is "0" instead of "". +dnl Result is gl_cv_func_printf_flag_alt_precision_zero. + +AC_DEFUN([gl_PRINTF_FLAG_ALT_PRECISION_ZERO], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether printf supports the alternative flag with a zero precision], + [gl_cv_func_printf_flag_alt_precision_zero], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include <stdio.h> +static char buf[10]; +int main () +{ + int result = 0; + if (sprintf (buf, "%#.0x %d", 0, 33, 44) > 0 + 3) + result |= 1; + return result; +}]])], + [gl_cv_func_printf_flag_alt_precision_zero=yes], + [gl_cv_func_printf_flag_alt_precision_zero=no], + [ +changequote(,)dnl + case "$host_os" in + # Guess no only on macOS 10..12 systems. + darwin[0-9] | darwin[0-9].* | \ + darwin1[0-9] | darwin1[0-9].* | \ + darwin2[0-1] | darwin2[0-1].*) + gl_cv_func_printf_flag_alt_precision_zero="guessing no" ;; + darwin*) gl_cv_func_printf_flag_alt_precision_zero="guessing yes" ;; + *) gl_cv_func_printf_flag_alt_precision_zero="guessing yes" ;; + esac +changequote([,])dnl + ]) + ]) +]) + dnl Test whether the *printf family of functions supports large precisions. dnl On mingw, precisions larger than 512 are treated like 512, in integer, dnl floating-point or pointer output. On Solaris 10/x86, precisions larger @@ -1297,12 +1357,12 @@ int main () changequote(,)dnl case "$host_os" in # Guess no only on Solaris, native Windows, and BeOS systems. - solaris*) gl_cv_func_printf_precision="guessing no" ;; - mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; - beos*) gl_cv_func_printf_precision="guessing no" ;; - # Guess yes on Android. - linux*-android*) gl_cv_func_printf_precision="guessing yes" ;; - *) gl_cv_func_printf_precision="guessing yes" ;; + solaris*) gl_cv_func_printf_precision="guessing no" ;; + mingw* | windows* | pw*) gl_cv_func_printf_precision="guessing no" ;; + beos*) gl_cv_func_printf_precision="guessing no" ;; + # Guess yes on Android. + linux*-android*) gl_cv_func_printf_precision="guessing yes" ;; + *) gl_cv_func_printf_precision="guessing yes" ;; esac changequote([,])dnl ]) @@ -1518,7 +1578,7 @@ changequote(,)dnl # Guess yes on Android. linux*-android*) gl_cv_func_snprintf_truncation_c99="guessing yes";; # Guess no on native Windows. - mingw*) gl_cv_func_snprintf_truncation_c99="guessing no";; + mingw* | windows*) gl_cv_func_snprintf_truncation_c99="guessing no";; # If we don't know, obey --enable-cross-guesses. *) gl_cv_func_snprintf_truncation_c99="$gl_cross_guess_normal";; esac @@ -1615,7 +1675,8 @@ changequote(,)dnl linux*-android*) gl_cv_func_snprintf_retval_c99="guessing yes";; changequote([,])dnl # Guess yes on MSVC, no on mingw. - mingw*) AC_EGREP_CPP([Known], [ + windows*-msvc*) gl_cv_func_snprintf_retval_c99="guessing yes" ;; + mingw* | windows*) AC_EGREP_CPP([Known], [ #ifdef _MSC_VER Known #endif @@ -1644,6 +1705,7 @@ AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N], [ AC_RUN_IFELSE( [AC_LANG_SOURCE([[ +#include <signal.h> #include <stdio.h> #include <string.h> #if HAVE_SNPRINTF @@ -1660,11 +1722,18 @@ static int my_snprintf (char *buf, int size, const char *format, ...) return ret; } #endif +static void +abort_handler (int sig) +{ + (void) sig; + _exit (1); +} static char fmtstring[10]; static char buf[100]; int main () { int count = -1; + signal (SIGABRT, abort_handler); /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) support %n in format strings in read-only memory but not in writable memory. */ @@ -1719,7 +1788,7 @@ changequote(,)dnl # Guess no on Android. linux*-android*) gl_cv_func_snprintf_directive_n="guessing no";; # Guess no on native Windows. - mingw*) gl_cv_func_snprintf_directive_n="guessing no";; + mingw* | windows*) gl_cv_func_snprintf_directive_n="guessing no";; # If we don't know, obey --enable-cross-guesses. *) gl_cv_func_snprintf_directive_n="$gl_cross_guess_normal";; changequote([,])dnl @@ -1767,11 +1836,11 @@ int main() [gl_cv_func_snprintf_size1=yes], [gl_cv_func_snprintf_size1=no], [case "$host_os" in - # Guess yes on Android. - linux*-android*) gl_cv_func_snprintf_size1="guessing yes" ;; - # Guess yes on native Windows. - mingw*) gl_cv_func_snprintf_size1="guessing yes" ;; - *) gl_cv_func_snprintf_size1="guessing yes" ;; + # Guess yes on Android. + linux*-android*) gl_cv_func_snprintf_size1="guessing yes" ;; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_snprintf_size1="guessing yes" ;; + *) gl_cv_func_snprintf_size1="guessing yes" ;; esac ]) ]) @@ -1844,40 +1913,40 @@ int main() [ changequote(,)dnl case "$host_os" in - # Guess yes on glibc systems. - *-gnu* | gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on musl systems. - *-musl* | midipix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - midnightbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Mac OS X >= 10.3. - darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Cygwin. - cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Solaris >= 2.6. + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + midnightbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Mac OS X >= 10.3. + darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Cygwin. + cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Solaris >= 2.6. solaris2.[0-5] | solaris2.[0-5].*) - gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on AIX >= 4. - aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on IRIX >= 6.5. - irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on NetBSD >= 3. + gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on AIX >= 4. + aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on IRIX >= 6.5. + irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on NetBSD >= 3. netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Android. - linux*-android*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on native Windows. - mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_vsnprintf_zerosize_c99="$gl_cross_guess_normal";; + gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Android. + linux*-android*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on native Windows. + mingw* | windows* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_vsnprintf_zerosize_c99="$gl_cross_guess_normal";; esac changequote([,])dnl ]) @@ -1906,7 +1975,7 @@ AC_DEFUN([gl_SWPRINTF_WORKS], int main() { int result = 0; - { /* This test fails on musl, FreeBSD, NetBSD, OpenBSD, macOS, AIX. */ + { /* This test fails on musl libc 1.2.3, FreeBSD, NetBSD, OpenBSD, macOS, AIX. */ wchar_t buf[5] = { 0xBEEF, 0xBEEF, 0xBEEF, 0xBEEF, 0xBEEF }; int ret = swprintf (buf, 4, L"%cz", '\0'); /* Expected result: @@ -1934,17 +2003,17 @@ int main() [gl_cv_func_swprintf_works=yes], [gl_cv_func_swprintf_works=no], [case "$host_os" in - # Guess yes on glibc systems. - *-gnu* | gnu*) gl_cv_func_swprintf_works="guessing yes";; - # Guess no on musl systems. - *-musl* | midipix*) gl_cv_func_swprintf_works="guessing yes";; - # Guess no on FreeBSD, NetBSD, OpenBSD, macOS, AIX. + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_swprintf_works="guessing yes";; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_swprintf_works="guessing no";; + # Guess no on FreeBSD, NetBSD, OpenBSD, macOS, AIX. freebsd* | midnightbsd* | netbsd* | openbsd* | darwin* | aix*) - gl_cv_func_swprintf_works="guessing no";; - # Guess no on native Windows. - mingw* | pw*) gl_cv_func_swprintf_works="guessing no";; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_swprintf_works="$gl_cross_guess_normal";; + gl_cv_func_swprintf_works="guessing no";; + # Guess no on native Windows. + mingw* | windows* | pw*) gl_cv_func_swprintf_works="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_swprintf_works="$gl_cross_guess_normal";; esac ]) ]) @@ -1983,7 +2052,7 @@ int main () [gl_cv_func_swprintf_directive_la=yes], [gl_cv_func_swprintf_directive_la=no], [case "$host_os" in - # Guess yes on glibc >= 2.17 systems. + # Guess yes on glibc >= 2.17 systems. *-gnu* | gnu*) AC_EGREP_CPP([Unlucky], [ #include <features.h> @@ -1996,14 +2065,60 @@ int main () [gl_cv_func_swprintf_directive_la="guessing yes"], [gl_cv_func_swprintf_directive_la="guessing no"]) ;; - # Guess yes on musl systems. - *-musl* | midipix*) gl_cv_func_swprintf_directive_la="guessing yes";; - # Guess yes on Android. - linux*-android*) gl_cv_func_swprintf_directive_la="guessing no";; - # Guess yes on native Windows. - mingw*) gl_cv_func_swprintf_directive_la="guessing no";; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_swprintf_directive_la="$gl_cross_guess_normal";; + # Guess yes on musl systems. + *-musl* | midipix*) gl_cv_func_swprintf_directive_la="guessing yes";; + # Guess yes on Android. + linux*-android*) gl_cv_func_swprintf_directive_la="guessing yes";; + # Guess no on native Windows. + mingw* | windows*) gl_cv_func_swprintf_directive_la="guessing no";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_swprintf_directive_la="$gl_cross_guess_normal";; + esac + ]) + ]) +]) + +dnl Test whether the *wprintf family of functions supports the 'lc' conversion +dnl specifier for all wide characters. +dnl (ISO C11, POSIX:2001) +dnl Result is gl_cv_func_swprintf_directive_lc. + +AC_DEFUN([gl_SWPRINTF_DIRECTIVE_LC], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether swprintf supports the 'lc' directive], + [gl_cv_func_swprintf_directive_lc], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include <stdio.h> +#include <wchar.h> +static wchar_t buf[100]; +static wint_t L_invalid = (wchar_t) 0x76543210; +int main () +{ + int result = 0; + /* This catches a musl libc 1.2.4, Android bug. + Reported at <https://www.openwall.com/lists/musl/2023/06/12/3>. */ + if (swprintf (buf, sizeof (buf) / sizeof (wchar_t), + L"%lc %d", L_invalid, 33, 44, 55) < 0) + result |= 1; + return result; +}]])], + [gl_cv_func_swprintf_directive_lc=yes], + [gl_cv_func_swprintf_directive_lc=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_swprintf_directive_lc="guessing yes";; + # Guess no on musl systems. + *-musl* | midipix*) gl_cv_func_swprintf_directive_lc="guessing no";; + # Guess no on Android. + linux*-android*) gl_cv_func_swprintf_directive_lc="guessing no";; + # Guess yes on native Windows. + mingw* | windows*) gl_cv_func_swprintf_directive_lc="guessing yes";; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_swprintf_directive_lc="$gl_cross_guess_normal";; esac ]) ]) @@ -2027,16 +2142,18 @@ dnl 13 = gl_PRINTF_POSITIONS dnl 14 = gl_PRINTF_FLAG_GROUPING dnl 15 = gl_PRINTF_FLAG_LEFTADJUST dnl 16 = gl_PRINTF_FLAG_ZERO -dnl 17 = gl_PRINTF_PRECISION -dnl 18 = gl_PRINTF_ENOMEM -dnl 19 = gl_SNPRINTF_PRESENCE -dnl 20 = gl_SNPRINTF_TRUNCATION_C99 -dnl 21 = gl_SNPRINTF_RETVAL_C99 -dnl 22 = gl_SNPRINTF_DIRECTIVE_N -dnl 23 = gl_SNPRINTF_SIZE1 -dnl 24 = gl_VSNPRINTF_ZEROSIZE_C99 -dnl 25 = gl_SWPRINTF_WORKS -dnl 26 = gl_SWPRINTF_DIRECTIVE_LA +dnl 17 = gl_PRINTF_FLAG_ALT_PRECISION_ZERO +dnl 18 = gl_PRINTF_PRECISION +dnl 19 = gl_PRINTF_ENOMEM +dnl 20 = gl_SNPRINTF_PRESENCE +dnl 21 = gl_SNPRINTF_TRUNCATION_C99 +dnl 22 = gl_SNPRINTF_RETVAL_C99 +dnl 23 = gl_SNPRINTF_DIRECTIVE_N +dnl 24 = gl_SNPRINTF_SIZE1 +dnl 25 = gl_VSNPRINTF_ZEROSIZE_C99 +dnl 26 = gl_SWPRINTF_WORKS +dnl 27 = gl_SWPRINTF_DIRECTIVE_LA +dnl 28 = gl_SWPRINTF_DIRECTIVE_LC dnl dnl 1 = checking whether printf supports size specifiers as in C99... dnl 2 = checking whether printf supports size specifiers as in C23... @@ -2054,57 +2171,60 @@ dnl 13 = checking whether printf supports POSIX/XSI format strings with position dnl 14 = checking whether printf supports the grouping flag... dnl 15 = checking whether printf supports the left-adjust flag correctly... dnl 16 = checking whether printf supports the zero flag correctly... -dnl 17 = checking whether printf supports large precisions... -dnl 18 = checking whether printf survives out-of-memory conditions... -dnl 19 = checking for snprintf... -dnl 20 = checking whether snprintf truncates the result as in C99... -dnl 21 = checking whether snprintf returns a byte count as in C99... -dnl 22 = checking whether snprintf fully supports the 'n' directive... -dnl 23 = checking whether snprintf respects a size of 1... -dnl 24 = checking whether vsnprintf respects a zero size as in C99... -dnl 25 = checking whether swprintf works... -dnl 26 = checking whether swprintf supports the 'La' and 'LA' directives... +dnl 17 = checking whether printf supports the alternative flag with a zero precision... +dnl 18 = checking whether printf supports large precisions... +dnl 19 = checking whether printf survives out-of-memory conditions... +dnl 20 = checking for snprintf... +dnl 21 = checking whether snprintf truncates the result as in C99... +dnl 22 = checking whether snprintf returns a byte count as in C99... +dnl 23 = checking whether snprintf fully supports the 'n' directive... +dnl 24 = checking whether snprintf respects a size of 1... +dnl 25 = checking whether vsnprintf respects a zero size as in C99... +dnl 26 = checking whether swprintf works... +dnl 27 = checking whether swprintf supports the 'La' and 'LA' directives... +dnl 28 = checking whether swprintf supports the 'lc' directive... dnl dnl . = yes, # = no. dnl -dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 -dnl musl libc 1.2.3 . # . . . . # # . . . . . . . . . . . . . . . . # . -dnl glibc 2.35 . # . . . . . . . . . # . . . . . . . . . . . . . . -dnl glibc 2.5 . # . . . . # # . . . # . . . . . . . . . . . . . # -dnl glibc 2.3.6 . # . . . # # # . . . # . . . . . . . . . . . . . # -dnl FreeBSD 13.0 . # . . . # # # . . . # . . . . . # . . . . . . # . -dnl FreeBSD 5.4, 6.1 . # . . . # # # . . . # . . . # . # . . . . . . # ? -dnl Mac OS X 10.13.5 . # . . # # # # . # . # . . . . . . . . . # . . # ? -dnl Mac OS X 10.5.8 . # . . # # # # . . . # . . . # . . . . . . . . # ? -dnl Mac OS X 10.3.9 . # . . . # # # . . . # . . . # . # . . . . . . # ? -dnl OpenBSD 6.0, 6.7 . # . . . # # # . . . # . . . . . # . . . . . . # . -dnl OpenBSD 3.9, 4.0 . # . # # # # # # . # # . # . # . # . . . . . . # ? -dnl Cygwin 1.7.0 (2009) . # . . # . # # . . ? ? . . . . . ? . . . . . . ? ? -dnl Cygwin 1.5.25 (2008) . # . . # # # # . . # ? . . . . . # . . . . . . ? ? -dnl Cygwin 1.5.19 (2006) # # . . # # # # # . # ? . # . # # # . . . . . . ? ? -dnl Solaris 11.4 . # . # # # # # . . # # . . . # . . . . . . . . . ? -dnl Solaris 11.3 . # . . . # # # . . # # . . . . . . . . . . . . . ? -dnl Solaris 11.0 . # . # # # # # . . # # . . . # . . . . . . . . ? ? -dnl Solaris 10 . # . # # # # # . . # # . . . # # . . . . . . . ? ? -dnl Solaris 2.6 ... 9 # # . # # # # # # . # # . . . # # . . . # . . . ? ? -dnl Solaris 2.5.1 # # . # # # # # # . # # . . . # . . # # # # # # ? ? -dnl AIX 7.1 . # . # # # # # . . . # . . . # # . . . . . . . # . -dnl AIX 5.2 . # . # # # # # . . . # . . . # . . . . . . . . # ? -dnl AIX 4.3.2, 5.1 # # . # # # # # # . . # . . . # . . . . # . . . # ? -dnl HP-UX 11.31 . # . . . # # # . . . ? . . . # . . . . # # . . ? ? -dnl HP-UX 11.{00,11,23} # # . . . # # # # . . ? . . . # . . . . # # . # ? ? -dnl HP-UX 10.20 # # . # . # # # # . ? ? . . # # . . . . # # ? # ? ? -dnl IRIX 6.5 # # . # # # # # # . # # . . . # . . . . # . . . # ? -dnl OSF/1 5.1 # # . # # # # # # . . ? . . . # . . . . # . . # ? ? -dnl OSF/1 4.0d # # . # # # # # # . . ? . . . # . . # # # # # # ? ? -dnl NetBSD 9.0 . # . . . # # # . . . # . . . . . . . . . . . . # . -dnl NetBSD 5.0 . # . . # # # # . . . # . . . # . # . . . . . . # ? -dnl NetBSD 4.0 . # ? ? ? ? # # ? . ? # . ? ? ? ? ? . . . ? ? ? # ? -dnl NetBSD 3.0 . # . . . # # # # . ? # # # ? # . # . . . . . . # ? -dnl Haiku . # . . # # # # # . # ? . . . . . ? . . ? . . . . # -dnl BeOS # # # . # # # # # . ? ? # . ? . # ? . . ? . . . ? ? -dnl Android 4.3 . # . # # # # # # # # ? . # . # . # . . . # . . ? ? -dnl old mingw / msvcrt # # # # # # # # # . . ? # # . # # ? . # # # . . # ? -dnl MSVC 9 # # # # # # # # # # . ? # # . # # ? # # # # . . # ? -dnl mingw 2009-2011 . # # . # . # # . . . ? # # . . . ? . . . . . . # ? -dnl mingw-w64 2011 # # # # # # # # # . . ? # # . # # ? . # # # . . # ? +dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 +dnl musl libc 1.2.3 . # . . . . # # . . . # . . . . ? . . . . . . . . # . # +dnl glibc 2.35 . # . . . . . . . . . . . . . . . . . . . . . . . . . . +dnl glibc 2.5 . # . . . . # # . . . . . . . . . . . . . . . . . . # . +dnl glibc 2.3.6 . # . . . # # # . . . . . . . . . . . . . . . . . . # . +dnl FreeBSD 14.0 . . . . . # . . . . . . . . . . . . # . . . . . . # . # +dnl FreeBSD 13.0 . # . . . # # # . . . . . . . . . . # . . . . . . # . # +dnl FreeBSD 5.4, 6.1 . # . . . # # # . . . . . . . # ? . # . . . . . . # ? ? +dnl Mac OS X 10.13.5 . # . . # # # # . # . . . . . . . . . . . . # . . # ? ? +dnl Mac OS X 10.5.8 . # . . # # # # . . . . . . . # # . . . . . . . . # ? ? +dnl Mac OS X 10.3.9 . # . . . # # # . . . . . . . # # . # . . . . . . # ? ? +dnl OpenBSD 6.0, 6.7 . # . . . # # # . . . . . . . . . . # . . . . . . # . # +dnl OpenBSD 3.9, 4.0 . # . # # # # # # . # . . # . # ? . # . . . . . . # ? ? +dnl Cygwin 1.7.0 (2009) . # . . # . # # . . ? ? . . . . ? . ? . . . . . . ? ? ? +dnl Cygwin 1.5.25 (2008) . # . . # # # # . . # ? . . . . ? . # . . . . . . ? ? ? +dnl Cygwin 1.5.19 (2006) # # . . # # # # # . # ? . # . # ? # # . . . . . . ? ? ? +dnl Solaris 11.4 . # . # # # # # . . # . . . . # . . . . . . . . . . # . +dnl Solaris 11.3 . # . . . # # # . . # . . . . . . . . . . . . . . . # . +dnl Solaris 11.0 . # . # # # # # . . # . . . . # . . . . . . . . . ? ? ? +dnl Solaris 10 . # . # # # # # . . # . . . . # . # . . . . . . . . # . +dnl Solaris 2.6 ... 9 # # . # # # # # # . # . . . . # ? # . . . # . . . ? ? ? +dnl Solaris 2.5.1 # # . # # # # # # . # . . . . # ? . . # # # # # # ? ? ? +dnl AIX 7.1 . # . # # # # # . . . . . . . # . # . . . . . . . # . . +dnl AIX 5.2 . # . # # # # # . . . . . . . # ? . . . . . . . . # ? ? +dnl AIX 4.3.2, 5.1 # # . # # # # # # . . . . . . # ? . . . . # . . . # ? ? +dnl HP-UX 11.31 . # . . . # # # . . . ? . . . # ? . . . . # # . . ? ? ? +dnl HP-UX 11.{00,11,23} # # . . . # # # # . . ? . . . # ? . . . . # # . # ? ? ? +dnl HP-UX 10.20 # # . # . # # # # . ? ? . . # # ? . . . . # # ? # ? ? ? +dnl IRIX 6.5 # # . # # # # # # . # . . . . # ? . . . . # . . . # ? ? +dnl OSF/1 5.1 # # . # # # # # # . . ? . . . # ? . . . . # . . # ? ? ? +dnl OSF/1 4.0d # # . # # # # # # . . ? . . . # ? . . # # # # # # ? ? ? +dnl NetBSD 9.0 . # . . . # # # . . . . . . . . . . . . . . . . . # . # +dnl NetBSD 5.0 . # . . # # # # . . . . . . . # ? . # . . . . . . # ? ? +dnl NetBSD 4.0 . # ? ? ? ? # # ? . ? . . ? ? ? ? ? ? . . . ? ? ? # ? ? +dnl NetBSD 3.0 . # . . . # # # # . ? . # # ? # ? . # . . . . . . # ? ? +dnl Haiku . # . . # # # # # . # ? . . . . ? . ? . . ? . . . . # . +dnl BeOS # # # . # # # # # . ? ? # . ? . ? # ? . . ? . . . ? ? ? +dnl Android 4.3 . # . # # # # # # # # ? . # . # ? . # . . . # . . ? ? ? +dnl old mingw / msvcrt # # # # # # # # # . . ? # # . # ? # ? . # # # . . # ? ? +dnl MSVC 9 # # # # # # # # # # . ? # # . # ? # ? # # # # . . # ? ? +dnl mingw 2009-2011 . # # . # . # # . . . ? # # . . ? . ? . . . . . . # ? ? +dnl mingw-w64 2011 # # # # # # # # # . . ? # # . # ? # ? . # # # . . # ? ? |