summaryrefslogtreecommitdiffstats
path: root/gl/m4/printf.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/printf.m4')
-rw-r--r--gl/m4/printf.m41075
1 files changed, 854 insertions, 221 deletions
diff --git a/gl/m4/printf.m4 b/gl/m4/printf.m4
index 4e65abc6..4619a402 100644
--- a/gl/m4/printf.m4
+++ b/gl/m4/printf.m4
@@ -1,8 +1,10 @@
1# printf.m4 serial 73 1# printf.m4
2dnl Copyright (C) 2003, 2007-2023 Free Software Foundation, Inc. 2# serial 96
3dnl Copyright (C) 2003, 2007-2025 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl Test whether the *printf family of functions supports the 'j', 'z', 't', 9dnl Test whether the *printf family of functions supports the 'j', 'z', 't',
8dnl 'L' size specifiers. (ISO C99, POSIX:2001) 10dnl 'L' size specifiers. (ISO C99, POSIX:2001)
@@ -63,7 +65,7 @@ changequote(,)dnl
63 # Guess yes on glibc systems. 65 # Guess yes on glibc systems.
64 *-gnu* | gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; 66 *-gnu* | gnu*) gl_cv_func_printf_sizes_c99="guessing yes";;
65 # Guess yes on musl systems. 67 # Guess yes on musl systems.
66 *-musl*) gl_cv_func_printf_sizes_c99="guessing yes";; 68 *-musl* | midipix*) gl_cv_func_printf_sizes_c99="guessing yes";;
67 # Guess yes on FreeBSD >= 5. 69 # Guess yes on FreeBSD >= 5.
68 freebsd[1-4].*) gl_cv_func_printf_sizes_c99="guessing no";; 70 freebsd[1-4].*) gl_cv_func_printf_sizes_c99="guessing no";;
69 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; 71 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
@@ -86,7 +88,8 @@ changequote(,)dnl
86 linux*-android*) gl_cv_func_printf_sizes_c99="guessing yes";; 88 linux*-android*) gl_cv_func_printf_sizes_c99="guessing yes";;
87changequote([,])dnl 89changequote([,])dnl
88 # Guess yes on MSVC, no on mingw. 90 # Guess yes on MSVC, no on mingw.
89 mingw*) AC_EGREP_CPP([Known], [ 91 windows*-msvc*) gl_cv_func_printf_sizes_c99="guessing yes" ;;
92 mingw* | windows*) AC_EGREP_CPP([Known], [
90#ifdef _MSC_VER 93#ifdef _MSC_VER
91 Known 94 Known
92#endif 95#endif
@@ -101,6 +104,92 @@ changequote([,])dnl
101 ]) 104 ])
102]) 105])
103 106
107dnl Test whether the *printf family of functions supports the 'w8', 'w16',
108dnl 'w32', 'w64', 'wf8', 'wf16', 'wf32', 'wf64' size specifiers. (ISO C23)
109dnl Result is gl_cv_func_printf_sizes_c23.
110
111AC_DEFUN([gl_PRINTF_SIZES_C23],
112[
113 AC_REQUIRE([AC_PROG_CC])
114 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
115 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
116 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
117 AC_CACHE_CHECK([whether printf supports size specifiers as in C23],
118 [gl_cv_func_printf_sizes_c23],
119 [
120 AC_RUN_IFELSE(
121 [AC_LANG_SOURCE([[
122#include <stddef.h>
123#include <stdio.h>
124#include <string.h>
125#include <sys/types.h>
126#if HAVE_STDINT_H_WITH_UINTMAX
127# include <stdint.h>
128#endif
129#if HAVE_INTTYPES_H_WITH_UINTMAX
130# include <inttypes.h>
131#endif
132static char buf[100];
133int main ()
134{
135 int result = 0;
136 buf[0] = '\0';
137 if (sprintf (buf, "%w8u %d", (uint8_t) 123, 33, 44, 55) < 0
138 || strcmp (buf, "123 33") != 0)
139 result |= 1;
140 buf[0] = '\0';
141 if (sprintf (buf, "%wf8u %d", (uint_fast8_t) 123, 33, 44, 55) < 0
142 || strcmp (buf, "123 33") != 0)
143 result |= 1;
144 buf[0] = '\0';
145 if (sprintf (buf, "%w16u %d", (uint16_t) 12345, 33, 44, 55) < 0
146 || strcmp (buf, "12345 33") != 0)
147 result |= 2;
148 buf[0] = '\0';
149 if (sprintf (buf, "%wf16u %d", (uint_fast16_t) 12345, 33, 44, 55) < 0
150 || strcmp (buf, "12345 33") != 0)
151 result |= 2;
152 buf[0] = '\0';
153 if (sprintf (buf, "%w32u %d", (uint32_t) 12345671, 33, 44, 55) < 0
154 || strcmp (buf, "12345671 33") != 0)
155 result |= 4;
156 buf[0] = '\0';
157 if (sprintf (buf, "%wf32u %d", (uint_fast32_t) 12345671, 33, 44, 55) < 0
158 || strcmp (buf, "12345671 33") != 0)
159 result |= 4;
160#if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX
161 buf[0] = '\0';
162 if (sprintf (buf, "%w64u %d", (uint64_t) 12345671, 33, 44, 55) < 0
163 || strcmp (buf, "12345671 33") != 0)
164 result |= 8;
165 buf[0] = '\0';
166 if (sprintf (buf, "%wf64u %d", (uint_fast64_t) 12345671, 33, 44, 55) < 0
167 || strcmp (buf, "12345671 33") != 0)
168 result |= 8;
169#else
170 result |= 8;
171#endif
172 return result;
173}]])],
174 [gl_cv_func_printf_sizes_c23=yes],
175 [gl_cv_func_printf_sizes_c23=no],
176 [
177 case "$host_os" in
178 # Guess no on glibc systems.
179 *-gnu* | gnu*) gl_cv_func_printf_sizes_c23="guessing no";;
180 # Guess no on musl systems.
181 *-musl* | midipix*) gl_cv_func_printf_sizes_c23="guessing no";;
182 # Guess no on Android.
183 linux*-android*) gl_cv_func_printf_sizes_c23="guessing no";;
184 # Guess no on native Windows.
185 mingw* | windows*) gl_cv_func_printf_sizes_c23="guessing no";;
186 # If we don't know, obey --enable-cross-guesses.
187 *) gl_cv_func_printf_sizes_c23="$gl_cross_guess_normal";;
188 esac
189 ])
190 ])
191])
192
104dnl Test whether the *printf family of functions supports 'long double' 193dnl Test whether the *printf family of functions supports 'long double'
105dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001) 194dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001)
106dnl Result is gl_cv_func_printf_long_double. 195dnl Result is gl_cv_func_printf_long_double.
@@ -137,20 +226,21 @@ int main ()
137 [gl_cv_func_printf_long_double=yes], 226 [gl_cv_func_printf_long_double=yes],
138 [gl_cv_func_printf_long_double=no], 227 [gl_cv_func_printf_long_double=no],
139 [case "$host_os" in 228 [case "$host_os" in
140 # Guess no on BeOS. 229 # Guess no on BeOS.
141 beos*) gl_cv_func_printf_long_double="guessing no";; 230 beos*) gl_cv_func_printf_long_double="guessing no";;
142 # Guess yes on Android. 231 # Guess yes on Android.
143 linux*-android*) gl_cv_func_printf_long_double="guessing yes";; 232 linux*-android*) gl_cv_func_printf_long_double="guessing yes";;
144 # Guess yes on MSVC, no on mingw. 233 # Guess yes on MSVC, no on mingw.
145 mingw*) AC_EGREP_CPP([Known], [ 234 windows*-msvc*) gl_cv_func_printf_long_double="guessing yes" ;;
235 mingw* | windows*) AC_EGREP_CPP([Known], [
146#ifdef _MSC_VER 236#ifdef _MSC_VER
147 Known 237 Known
148#endif 238#endif
149 ], 239 ],
150 [gl_cv_func_printf_long_double="guessing yes"], 240 [gl_cv_func_printf_long_double="guessing yes"],
151 [gl_cv_func_printf_long_double="guessing no"]) 241 [gl_cv_func_printf_long_double="guessing no"])
152 ;; 242 ;;
153 *) gl_cv_func_printf_long_double="guessing yes";; 243 *) gl_cv_func_printf_long_double="guessing yes";;
154 esac 244 esac
155 ]) 245 ])
156 ]) 246 ])
@@ -244,7 +334,7 @@ changequote(,)dnl
244 # Guess yes on glibc systems. 334 # Guess yes on glibc systems.
245 *-gnu* | gnu*) gl_cv_func_printf_infinite="guessing yes";; 335 *-gnu* | gnu*) gl_cv_func_printf_infinite="guessing yes";;
246 # Guess yes on musl systems. 336 # Guess yes on musl systems.
247 *-musl*) gl_cv_func_printf_infinite="guessing yes";; 337 *-musl* | midipix*) gl_cv_func_printf_infinite="guessing yes";;
248 # Guess yes on FreeBSD >= 6. 338 # Guess yes on FreeBSD >= 6.
249 freebsd[1-5].*) gl_cv_func_printf_infinite="guessing no";; 339 freebsd[1-5].*) gl_cv_func_printf_infinite="guessing no";;
250 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; 340 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";;
@@ -268,7 +358,8 @@ changequote(,)dnl
268 linux*-android*) gl_cv_func_printf_infinite="guessing no";; 358 linux*-android*) gl_cv_func_printf_infinite="guessing no";;
269changequote([,])dnl 359changequote([,])dnl
270 # Guess yes on MSVC, no on mingw. 360 # Guess yes on MSVC, no on mingw.
271 mingw*) AC_EGREP_CPP([Known], [ 361 windows*-msvc*) gl_cv_func_printf_infinite="guessing yes" ;;
362 mingw* | windows*) AC_EGREP_CPP([Known], [
272#ifdef _MSC_VER 363#ifdef _MSC_VER
273 Known 364 Known
274#endif 365#endif
@@ -467,7 +558,7 @@ changequote(,)dnl
467 # Guess yes on glibc systems. 558 # Guess yes on glibc systems.
468 *-gnu* | gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; 559 *-gnu* | gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";;
469 # Guess yes on musl systems. 560 # Guess yes on musl systems.
470 *-musl*) gl_cv_func_printf_infinite_long_double="guessing yes";; 561 *-musl* | midipix*) gl_cv_func_printf_infinite_long_double="guessing yes";;
471 # Guess yes on FreeBSD >= 6. 562 # Guess yes on FreeBSD >= 6.
472 freebsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";; 563 freebsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";;
473 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; 564 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
@@ -482,7 +573,8 @@ changequote(,)dnl
482 linux*-android*) gl_cv_func_printf_infinite_long_double="guessing no";; 573 linux*-android*) gl_cv_func_printf_infinite_long_double="guessing no";;
483changequote([,])dnl 574changequote([,])dnl
484 # Guess yes on MSVC, no on mingw. 575 # Guess yes on MSVC, no on mingw.
485 mingw*) AC_EGREP_CPP([Known], [ 576 windows*-msvc*) gl_cv_func_printf_infinite_long_double="guessing yes" ;;
577 mingw* | windows*) AC_EGREP_CPP([Known], [
486#ifdef _MSC_VER 578#ifdef _MSC_VER
487 Known 579 Known
488#endif 580#endif
@@ -525,6 +617,7 @@ static double zero = 0.0;
525int main () 617int main ()
526{ 618{
527 int result = 0; 619 int result = 0;
620 /* This fails on FreeBSD 5.2.1, Solaris 11.4. */
528 if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0 621 if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0
529 || (strcmp (buf, "0x1.922p+1 33") != 0 622 || (strcmp (buf, "0x1.922p+1 33") != 0
530 && strcmp (buf, "0x3.244p+0 33") != 0 623 && strcmp (buf, "0x3.244p+0 33") != 0
@@ -536,27 +629,29 @@ int main ()
536 && strcmp (buf, "-0X3.244P+0 33") != 0 629 && strcmp (buf, "-0X3.244P+0 33") != 0
537 && strcmp (buf, "-0X6.488P-1 33") != 0 630 && strcmp (buf, "-0X6.488P-1 33") != 0
538 && strcmp (buf, "-0XC.91P-2 33") != 0)) 631 && strcmp (buf, "-0XC.91P-2 33") != 0))
539 result |= 2; 632 result |= 1;
540 /* This catches a FreeBSD 13.0 bug: it doesn't round. */ 633 /* This catches a Mac OS X 10.5, FreeBSD 6.4, NetBSD 10.0 bug:
634 it doesn't round. */
541 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0 635 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0
542 || (strcmp (buf, "0x1.83p+0 33") != 0 636 || (strcmp (buf, "0x1.83p+0 33") != 0
543 && strcmp (buf, "0x3.05p-1 33") != 0 637 && strcmp (buf, "0x3.05p-1 33") != 0
544 && strcmp (buf, "0x6.0ap-2 33") != 0 638 && strcmp (buf, "0x6.0ap-2 33") != 0
545 && strcmp (buf, "0xc.14p-3 33") != 0)) 639 && strcmp (buf, "0xc.14p-3 33") != 0))
546 result |= 4; 640 result |= 2;
547 /* This catches a Mac OS X 10.12.4 (Darwin 16.5) bug: it doesn't round. */ 641 /* This catches a macOS 14 (Darwin 23), FreeBSD 14.0, OpenBSD 7.5, AIX 7.3,
642 Solaris 11.4 bug: it doesn't round. */
548 if (sprintf (buf, "%.0a %d", 1.51, 33, 44, 55) < 0 643 if (sprintf (buf, "%.0a %d", 1.51, 33, 44, 55) < 0
549 || (strcmp (buf, "0x2p+0 33") != 0 644 || (strcmp (buf, "0x2p+0 33") != 0
550 && strcmp (buf, "0x3p-1 33") != 0 645 && strcmp (buf, "0x3p-1 33") != 0
551 && strcmp (buf, "0x6p-2 33") != 0 646 && strcmp (buf, "0x6p-2 33") != 0
552 && strcmp (buf, "0xcp-3 33") != 0)) 647 && strcmp (buf, "0xcp-3 33") != 0))
553 result |= 4; 648 result |= 4;
554 /* This catches a FreeBSD 6.1 bug. See 649 /* This catches a Mac OS X 10.5, FreeBSD 6.4 bug. See
555 <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html> */ 650 <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html> */
556 if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0 651 if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0
557 || buf[0] == '0') 652 || buf[0] == '0')
558 result |= 8; 653 result |= 8;
559 /* This catches a Mac OS X 10.3.9 (Darwin 7.9) bug. */ 654 /* This catches a Mac OS X 10.3.9 (Darwin 7.9), FreeBSD 6.4 bug. */
560 if (sprintf (buf, "%.1a", 1.999) < 0 655 if (sprintf (buf, "%.1a", 1.999) < 0
561 || (strcmp (buf, "0x1.0p+1") != 0 656 || (strcmp (buf, "0x1.0p+1") != 0
562 && strcmp (buf, "0x2.0p+0") != 0 657 && strcmp (buf, "0x2.0p+0") != 0
@@ -564,7 +659,8 @@ int main ()
564 && strcmp (buf, "0x8.0p-2") != 0)) 659 && strcmp (buf, "0x8.0p-2") != 0))
565 result |= 16; 660 result |= 16;
566 /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a 661 /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a
567 glibc 2.4 bug <https://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */ 662 glibc 2.4 bug <https://sourceware.org/bugzilla/show_bug.cgi?id=2908>
663 and a FreeBSD 6.4, NetBSD 10.0 bug. */
568 if (sprintf (buf, "%.1La", 1.999L) < 0 664 if (sprintf (buf, "%.1La", 1.999L) < 0
569 || (strcmp (buf, "0x1.0p+1") != 0 665 || (strcmp (buf, "0x1.0p+1") != 0
570 && strcmp (buf, "0x2.0p+0") != 0 666 && strcmp (buf, "0x2.0p+0") != 0
@@ -591,11 +687,11 @@ int main ()
591 [gl_cv_func_printf_directive_a="guessing no"]) 687 [gl_cv_func_printf_directive_a="guessing no"])
592 ;; 688 ;;
593 # Guess yes on musl systems. 689 # Guess yes on musl systems.
594 *-musl*) gl_cv_func_printf_directive_a="guessing yes";; 690 *-musl* | midipix*) gl_cv_func_printf_directive_a="guessing yes";;
595 # Guess no on Android. 691 # Guess no on Android.
596 linux*-android*) gl_cv_func_printf_directive_a="guessing no";; 692 linux*-android*) gl_cv_func_printf_directive_a="guessing no";;
597 # Guess no on native Windows. 693 # Guess no on native Windows.
598 mingw*) gl_cv_func_printf_directive_a="guessing no";; 694 mingw* | windows*) gl_cv_func_printf_directive_a="guessing no";;
599 # If we don't know, obey --enable-cross-guesses. 695 # If we don't know, obey --enable-cross-guesses.
600 *) gl_cv_func_printf_directive_a="$gl_cross_guess_normal";; 696 *) gl_cv_func_printf_directive_a="$gl_cross_guess_normal";;
601 esac 697 esac
@@ -603,6 +699,116 @@ int main ()
603 ]) 699 ])
604]) 700])
605 701
702dnl Test whether the *printf family of functions supports the 'b' conversion
703dnl specifier for binary output of integers.
704dnl (ISO C23)
705dnl Result is gl_cv_func_printf_directive_b.
706
707AC_DEFUN([gl_PRINTF_DIRECTIVE_B],
708[
709 AC_REQUIRE([AC_PROG_CC])
710 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
711 AC_CACHE_CHECK([whether printf supports the 'b' directive],
712 [gl_cv_func_printf_directive_b],
713 [
714 AC_RUN_IFELSE(
715 [AC_LANG_SOURCE([[
716#include <stdio.h>
717#include <string.h>
718static char buf[100];
719int main ()
720{
721 int result = 0;
722 if (sprintf (buf, "%b %d", 12345, 33, 44, 55) < 0
723 || strcmp (buf, "11000000111001 33") != 0)
724 result |= 1;
725 return result;
726}]])],
727 [gl_cv_func_printf_directive_b=yes],
728 [gl_cv_func_printf_directive_b=no],
729 [
730 case "$host_os" in
731 # Guess yes on glibc >= 2.35 systems.
732 *-gnu* | gnu*)
733 AC_EGREP_CPP([Lucky], [
734 #include <features.h>
735 #ifdef __GNU_LIBRARY__
736 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 35) || (__GLIBC__ > 2)
737 Lucky user
738 #endif
739 #endif
740 ],
741 [gl_cv_func_printf_directive_uppercase_b="guessing yes"],
742 [gl_cv_func_printf_directive_uppercase_b="guessing no"])
743 ;;
744 # Guess no on musl systems.
745 *-musl* | midipix*) gl_cv_func_printf_directive_b="guessing no";;
746 # Guess no on Android.
747 linux*-android*) gl_cv_func_printf_directive_b="guessing no";;
748 # Guess no on native Windows.
749 mingw* | windows*) gl_cv_func_printf_directive_b="guessing no";;
750 # If we don't know, obey --enable-cross-guesses.
751 *) gl_cv_func_printf_directive_b="$gl_cross_guess_normal";;
752 esac
753 ])
754 ])
755])
756
757dnl Test whether the *printf family of functions supports the 'B' conversion
758dnl specifier for binary output of integers.
759dnl (GNU, encouraged by ISO C23 § 7.23.6.1)
760dnl Result is gl_cv_func_printf_directive_uppercase_b.
761
762AC_DEFUN([gl_PRINTF_DIRECTIVE_UPPERCASE_B],
763[
764 AC_REQUIRE([AC_PROG_CC])
765 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
766 AC_CACHE_CHECK([whether printf supports the 'B' directive],
767 [gl_cv_func_printf_directive_uppercase_b],
768 [
769 AC_RUN_IFELSE(
770 [AC_LANG_SOURCE([[
771#include <stdio.h>
772#include <string.h>
773static char buf[100];
774int main ()
775{
776 int result = 0;
777 if (sprintf (buf, "%#B %d", 12345, 33, 44, 55) < 0
778 || strcmp (buf, "0B11000000111001 33") != 0)
779 result |= 1;
780 return result;
781}]])],
782 [gl_cv_func_printf_directive_uppercase_b=yes],
783 [gl_cv_func_printf_directive_uppercase_b=no],
784 [
785 case "$host_os" in
786 # Guess yes on glibc >= 2.35 systems.
787 *-gnu* | gnu*)
788 AC_EGREP_CPP([Lucky], [
789 #include <features.h>
790 #ifdef __GNU_LIBRARY__
791 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 35) || (__GLIBC__ > 2)
792 Lucky user
793 #endif
794 #endif
795 ],
796 [gl_cv_func_printf_directive_uppercase_b="guessing yes"],
797 [gl_cv_func_printf_directive_uppercase_b="guessing no"])
798 ;;
799 # Guess no on musl systems.
800 *-musl* | midipix*) gl_cv_func_printf_directive_uppercase_b="guessing no";;
801 # Guess no on Android.
802 linux*-android*) gl_cv_func_printf_directive_uppercase_b="guessing no";;
803 # Guess no on native Windows.
804 mingw* | windows*) gl_cv_func_printf_directive_uppercase_b="guessing no";;
805 # If we don't know, obey --enable-cross-guesses.
806 *) gl_cv_func_printf_directive_uppercase_b="$gl_cross_guess_normal";;
807 esac
808 ])
809 ])
810])
811
606dnl Test whether the *printf family of functions supports the %F format 812dnl Test whether the *printf family of functions supports the %F format
607dnl directive. (ISO C99, POSIX:2001) 813dnl directive. (ISO C99, POSIX:2001)
608dnl Result is gl_cv_func_printf_directive_f. 814dnl Result is gl_cv_func_printf_directive_f.
@@ -643,7 +849,7 @@ changequote(,)dnl
643 # Guess yes on glibc systems. 849 # Guess yes on glibc systems.
644 *-gnu* | gnu*) gl_cv_func_printf_directive_f="guessing yes";; 850 *-gnu* | gnu*) gl_cv_func_printf_directive_f="guessing yes";;
645 # Guess yes on musl systems. 851 # Guess yes on musl systems.
646 *-musl*) gl_cv_func_printf_directive_f="guessing yes";; 852 *-musl* | midipix*) gl_cv_func_printf_directive_f="guessing yes";;
647 # Guess yes on FreeBSD >= 6. 853 # Guess yes on FreeBSD >= 6.
648 freebsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";; 854 freebsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";;
649 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; 855 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";;
@@ -661,7 +867,8 @@ changequote(,)dnl
661 linux*-android*) gl_cv_func_printf_directive_f="guessing no";; 867 linux*-android*) gl_cv_func_printf_directive_f="guessing no";;
662changequote([,])dnl 868changequote([,])dnl
663 # Guess yes on MSVC, no on mingw. 869 # Guess yes on MSVC, no on mingw.
664 mingw*) AC_EGREP_CPP([Known], [ 870 windows*-msvc*) gl_cv_func_printf_directive_f="guessing yes" ;;
871 mingw* | windows*) AC_EGREP_CPP([Known], [
665#ifdef _MSC_VER 872#ifdef _MSC_VER
666 Known 873 Known
667#endif 874#endif
@@ -689,10 +896,16 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
689 [ 896 [
690 AC_RUN_IFELSE( 897 AC_RUN_IFELSE(
691 [AC_LANG_SOURCE([[ 898 [AC_LANG_SOURCE([[
899#include <signal.h>
692#include <stdio.h> 900#include <stdio.h>
693#include <stdlib.h>
694#include <string.h> 901#include <string.h>
902#if defined _WIN32 && !defined __CYGWIN__
903# include <stdlib.h>
904#else
905# include <unistd.h>
906#endif
695#ifdef _MSC_VER 907#ifdef _MSC_VER
908#include <crtdbg.h>
696#include <inttypes.h> 909#include <inttypes.h>
697/* See page about "Parameter Validation" on msdn.microsoft.com. 910/* See page about "Parameter Validation" on msdn.microsoft.com.
698 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/parameter-validation> 911 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/parameter-validation>
@@ -706,6 +919,12 @@ invalid_parameter_handler (const wchar_t *expression,
706 exit (1); 919 exit (1);
707} 920}
708#endif 921#endif
922static void
923abort_handler (int sig)
924{
925 (void) sig;
926 _exit (1);
927}
709static char fmtstring[10]; 928static char fmtstring[10];
710static char buf[100]; 929static char buf[100];
711int main () 930int main ()
@@ -713,7 +932,11 @@ int main ()
713 int count = -1; 932 int count = -1;
714#ifdef _MSC_VER 933#ifdef _MSC_VER
715 _set_invalid_parameter_handler (invalid_parameter_handler); 934 _set_invalid_parameter_handler (invalid_parameter_handler);
935 /* Also avoid an Abort/Retry/Ignore dialog in debug builds.
936 <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/crtsetreportmode> */
937 _CrtSetReportMode (_CRT_ASSERT, 0);
716#endif 938#endif
939 signal (SIGABRT, abort_handler);
717 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) 940 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2)
718 support %n in format strings in read-only memory but not in writable 941 support %n in format strings in read-only memory but not in writable
719 memory. */ 942 memory. */
@@ -727,21 +950,21 @@ int main ()
727 [gl_cv_func_printf_directive_n=yes], 950 [gl_cv_func_printf_directive_n=yes],
728 [gl_cv_func_printf_directive_n=no], 951 [gl_cv_func_printf_directive_n=no],
729 [case "$host_os" in 952 [case "$host_os" in
730 # Guess no on glibc when _FORTIFY_SOURCE >= 2. 953 # Guess no on glibc when _FORTIFY_SOURCE >= 2.
731 *-gnu* | gnu*) AC_COMPILE_IFELSE( 954 *-gnu* | gnu*) AC_COMPILE_IFELSE(
732 [AC_LANG_SOURCE( 955 [AC_LANG_SOURCE(
733 [[#if _FORTIFY_SOURCE >= 2 956 [[#if _FORTIFY_SOURCE >= 2
734 error fail 957 error fail
735 #endif 958 #endif
736 ]])], 959 ]])],
737 [gl_cv_func_printf_directive_n="guessing yes"], 960 [gl_cv_func_printf_directive_n="guessing yes"],
738 [gl_cv_func_printf_directive_n="guessing no"]) 961 [gl_cv_func_printf_directive_n="guessing no"])
739 ;; 962 ;;
740 # Guess no on Android. 963 # Guess no on Android.
741 linux*-android*) gl_cv_func_printf_directive_n="guessing no";; 964 linux*-android*) gl_cv_func_printf_directive_n="guessing no";;
742 # Guess no on native Windows. 965 # Guess no on native Windows.
743 mingw*) gl_cv_func_printf_directive_n="guessing no";; 966 mingw* | windows*) gl_cv_func_printf_directive_n="guessing no";;
744 *) gl_cv_func_printf_directive_n="guessing yes";; 967 *) gl_cv_func_printf_directive_n="guessing yes";;
745 esac 968 esac
746 ]) 969 ])
747 ]) 970 ])
@@ -811,18 +1034,64 @@ int main ()
811 [ 1034 [
812changequote(,)dnl 1035changequote(,)dnl
813 case "$host_os" in 1036 case "$host_os" in
814 # Guess yes on OpenBSD >= 6.0. 1037 # Guess yes on OpenBSD >= 6.0.
815 openbsd[1-5].*) gl_cv_func_printf_directive_ls="guessing no";; 1038 openbsd[1-5].*) gl_cv_func_printf_directive_ls="guessing no";;
816 openbsd*) gl_cv_func_printf_directive_ls="guessing yes";; 1039 openbsd*) gl_cv_func_printf_directive_ls="guessing yes";;
817 irix*) gl_cv_func_printf_directive_ls="guessing no";; 1040 irix*) gl_cv_func_printf_directive_ls="guessing no";;
818 solaris*) gl_cv_func_printf_directive_ls="guessing no";; 1041 solaris*) gl_cv_func_printf_directive_ls="guessing no";;
819 cygwin*) gl_cv_func_printf_directive_ls="guessing no";; 1042 cygwin*) gl_cv_func_printf_directive_ls="guessing no";;
820 beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; 1043 beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";;
821 # Guess no on Android. 1044 # Guess no on Android.
822 linux*-android*) gl_cv_func_printf_directive_ls="guessing no";; 1045 linux*-android*) gl_cv_func_printf_directive_ls="guessing no";;
823 # Guess yes on native Windows. 1046 # Guess yes on native Windows.
824 mingw*) gl_cv_func_printf_directive_ls="guessing yes";; 1047 mingw* | windows*) gl_cv_func_printf_directive_ls="guessing yes";;
825 *) gl_cv_func_printf_directive_ls="guessing yes";; 1048 *) gl_cv_func_printf_directive_ls="guessing yes";;
1049 esac
1050changequote([,])dnl
1051 ])
1052 ])
1053])
1054
1055dnl Test whether the *printf family of functions supports the %lc format
1056dnl directive and in particular, when the argument is a null wide character,
1057dnl whether the functions produce a NUL byte, as specified in ISO C 23
1058dnl after the issue GB-141 was fixed.
1059dnl Result is gl_cv_func_printf_directive_lc.
1060
1061AC_DEFUN([gl_PRINTF_DIRECTIVE_LC],
1062[
1063 AC_REQUIRE([AC_PROG_CC])
1064 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1065 AC_CACHE_CHECK([whether printf supports the 'lc' directive correctly],
1066 [gl_cv_func_printf_directive_lc],
1067 [
1068 AC_RUN_IFELSE(
1069 [AC_LANG_SOURCE([[
1070#include <stdio.h>
1071#include <wchar.h>
1072#include <string.h>
1073int main ()
1074{
1075 int result = 0;
1076 char buf[100];
1077 /* This test fails on musl libc 1.2.4. */
1078 {
1079 buf[0] = '\0';
1080 if (sprintf (buf, "%lc%lc%lc", (wint_t) 'a', (wint_t) 0, (wint_t) 'z') < 0
1081 || memcmp (buf, "a\0z", 4) != 0)
1082 result |= 1;
1083 }
1084 return result;
1085}]])],
1086 [gl_cv_func_printf_directive_lc=yes],
1087 [gl_cv_func_printf_directive_lc=no],
1088 [
1089changequote(,)dnl
1090 case "$host_os" in
1091 # Guess no on musl libc.
1092 *-musl* | midipix*) gl_cv_func_printf_directive_lc="guessing no";;
1093 # Guess yes otherwise.
1094 *) gl_cv_func_printf_directive_lc="guessing yes";;
826 esac 1095 esac
827changequote([,])dnl 1096changequote([,])dnl
828 ]) 1097 ])
@@ -833,7 +1102,7 @@ dnl Test whether the *printf family of functions supports POSIX/XSI format
833dnl strings with positions. (POSIX:2001) 1102dnl strings with positions. (POSIX:2001)
834dnl Result is gl_cv_func_printf_positions. 1103dnl Result is gl_cv_func_printf_positions.
835 1104
836AC_DEFUN([gl_PRINTF_POSITIONS], 1105AC_DEFUN_ONCE([gl_PRINTF_POSITIONS],
837[ 1106[
838 AC_REQUIRE([AC_PROG_CC]) 1107 AC_REQUIRE([AC_PROG_CC])
839 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1108 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
@@ -859,13 +1128,17 @@ int main ()
859changequote(,)dnl 1128changequote(,)dnl
860 case "$host_os" in 1129 case "$host_os" in
861 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) 1130 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
862 gl_cv_func_printf_positions="guessing no";; 1131 gl_cv_func_printf_positions="guessing no";;
863 beos*) gl_cv_func_printf_positions="guessing no";; 1132 beos*)
864 # Guess yes on Android. 1133 gl_cv_func_printf_positions="guessing no";;
865 linux*-android*) gl_cv_func_printf_positions="guessing yes";; 1134 # Guess yes on Android.
866 # Guess no on native Windows. 1135 linux*-android*)
867 mingw* | pw*) gl_cv_func_printf_positions="guessing no";; 1136 gl_cv_func_printf_positions="guessing yes";;
868 *) gl_cv_func_printf_positions="guessing yes";; 1137 # Guess no on native Windows.
1138 mingw* | windows* | pw*)
1139 gl_cv_func_printf_positions="guessing no";;
1140 *)
1141 gl_cv_func_printf_positions="guessing yes";;
869 esac 1142 esac
870changequote([,])dnl 1143changequote([,])dnl
871 ]) 1144 ])
@@ -900,19 +1173,125 @@ int main ()
900 [ 1173 [
901changequote(,)dnl 1174changequote(,)dnl
902 case "$host_os" in 1175 case "$host_os" in
903 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; 1176 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";;
904 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; 1177 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";;
905 # Guess no on Android. 1178 # Guess no on Android.
906 linux*-android*) gl_cv_func_printf_flag_grouping="guessing no";; 1179 linux*-android*) gl_cv_func_printf_flag_grouping="guessing no";;
907 # Guess no on native Windows. 1180 # Guess no on native Windows.
908 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; 1181 mingw* | windows* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
909 *) gl_cv_func_printf_flag_grouping="guessing yes";; 1182 *) gl_cv_func_printf_flag_grouping="guessing yes";;
910 esac 1183 esac
911changequote([,])dnl 1184changequote([,])dnl
912 ]) 1185 ])
913 ]) 1186 ])
914]) 1187])
915 1188
1189dnl Test whether the *printf family of functions supports POSIX/XSI format
1190dnl strings with the ' flag for grouping of decimal digits on integers,
1191dnl together with a precision.
1192dnl Result is gl_cv_func_printf_flag_grouping_int_precision.
1193
1194AC_DEFUN([gl_PRINTF_FLAG_GROUPING_INT_PRECISION],
1195[
1196 AC_REQUIRE([AC_PROG_CC])
1197 AC_REQUIRE([AC_CANONICAL_HOST])
1198 AC_CACHE_CHECK([whether printf supports grouping on integers with a precision],
1199 [gl_cv_func_printf_flag_grouping_int_precision],
1200 [
1201 dnl Prepare a guess, used when cross-compiling or when specific locales
1202 dnl are not available.
1203 case "$host_os" in
1204 # Guess no on FreeBSD, NetBSD, Solaris, Cygwin, Haiku.
1205 freebsd* | dragonfly* | netbsd* | solaris* | cygwin* | haiku*)
1206 gl_cv_func_printf_flag_grouping_int_precision="guessing no";;
1207 *)
1208 gl_cv_func_printf_flag_grouping_int_precision="guessing yes";;
1209 esac
1210 AC_RUN_IFELSE(
1211 [AC_LANG_SOURCE([[
1212#include <locale.h>
1213#include <stdio.h>
1214#include <string.h>
1215static char buf[100];
1216int main ()
1217{
1218 if (setlocale (LC_ALL, "fr_FR.UTF-8") != NULL
1219 || setlocale (LC_ALL, "fr_FR") != NULL
1220 || setlocale (LC_ALL, "fr_FR.ISO-8859-1") != NULL
1221 || setlocale (LC_ALL, "fr_FR.ISO8859-1") != NULL)
1222 {
1223 if (sprintf (buf, "%'.10d", 1000) < 0)
1224 return 1;
1225 if (strlen (buf) == 10 && strcmp (buf, "0000001000") != 0)
1226 /* The sprintf implementation has produced fewer than 10 digits. */
1227 return 2;
1228 else
1229 return 0;
1230 }
1231 return 3;
1232}]])],
1233 [gl_cv_func_printf_flag_grouping_int_precision=yes],
1234 [if test $? = 2; then
1235 gl_cv_func_printf_flag_grouping_int_precision=no
1236 fi
1237 ],
1238 [:])
1239 ])
1240])
1241
1242dnl Test whether the *printf family of functions supports POSIX/XSI format
1243dnl strings with the ' flag for grouping of decimal digits, when the thousands
1244dnl separator is a multibyte character (such as U+00A0 or U+202F in a UTF-8
1245dnl locale).
1246dnl Result is gl_cv_func_printf_flag_grouping_multibyte.
1247
1248AC_DEFUN([gl_PRINTF_FLAG_GROUPING_MULTIBYTE],
1249[
1250 AC_REQUIRE([AC_PROG_CC])
1251 AC_REQUIRE([AC_CANONICAL_HOST])
1252 AC_CACHE_CHECK([whether printf supports grouping with a multibyte separator],
1253 [gl_cv_func_printf_flag_grouping_multibyte],
1254 [
1255 dnl Prepare a guess, used when cross-compiling or when specific locales
1256 dnl are not available.
1257 case "$host_os" in
1258 # Guess no on NetBSD and Solaris 11 OpenIndiana.
1259 netbsd* | solaris*)
1260 gl_cv_func_printf_flag_grouping_multibyte="guessing no";;
1261 *)
1262 gl_cv_func_printf_flag_grouping_multibyte="guessing yes";;
1263 esac
1264 AC_RUN_IFELSE(
1265 [AC_LANG_SOURCE([[
1266#include <locale.h>
1267#include <stdio.h>
1268#include <string.h>
1269static char buf[100];
1270int main ()
1271{
1272 if (setlocale (LC_ALL, "fr_FR.UTF-8") == NULL)
1273 return 0;
1274 if (sprintf (buf, "%'.0f", 1000.0) < 0)
1275 return 1;
1276 if (strlen (localeconv ()->thousands_sep) > 1)
1277 {
1278 if (strlen (buf) <= 4 + 1)
1279 return 2;
1280 else
1281 return 3;
1282 }
1283 return 0;
1284}]])],
1285 [:],
1286 [case $? in
1287 2) gl_cv_func_printf_flag_grouping_multibyte=no ;;
1288 3) gl_cv_func_printf_flag_grouping_multibyte=yes ;;
1289 esac
1290 ],
1291 [:])
1292 ])
1293])
1294
916dnl Test whether the *printf family of functions supports the - flag correctly. 1295dnl Test whether the *printf family of functions supports the - flag correctly.
917dnl (ISO C99.) See 1296dnl (ISO C99.) See
918dnl <https://lists.gnu.org/r/bug-coreutils/2008-02/msg00035.html> 1297dnl <https://lists.gnu.org/r/bug-coreutils/2008-02/msg00035.html>
@@ -943,16 +1322,16 @@ int main ()
943 [ 1322 [
944changequote(,)dnl 1323changequote(,)dnl
945 case "$host_os" in 1324 case "$host_os" in
946 # Guess yes on HP-UX 11. 1325 # Guess yes on HP-UX 11.
947 hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";; 1326 hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
948 # Guess no on HP-UX 10 and older. 1327 # Guess no on HP-UX 10 and older.
949 hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";; 1328 hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";;
950 # Guess yes on Android. 1329 # Guess yes on Android.
951 linux*-android*) gl_cv_func_printf_flag_leftadjust="guessing yes";; 1330 linux*-android*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
952 # Guess yes on native Windows. 1331 # Guess yes on native Windows.
953 mingw*) gl_cv_func_printf_flag_leftadjust="guessing yes";; 1332 mingw* | windows*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
954 # Guess yes otherwise. 1333 # Guess yes otherwise.
955 *) gl_cv_func_printf_flag_leftadjust="guessing yes";; 1334 *) gl_cv_func_printf_flag_leftadjust="guessing yes";;
956 esac 1335 esac
957changequote([,])dnl 1336changequote([,])dnl
958 ]) 1337 ])
@@ -990,18 +1369,62 @@ int main ()
990 [ 1369 [
991changequote(,)dnl 1370changequote(,)dnl
992 case "$host_os" in 1371 case "$host_os" in
993 # Guess yes on glibc systems. 1372 # Guess yes on glibc systems.
994 *-gnu* | gnu*) gl_cv_func_printf_flag_zero="guessing yes";; 1373 *-gnu* | gnu*) gl_cv_func_printf_flag_zero="guessing yes";;
995 # Guess yes on musl systems. 1374 # Guess yes on musl systems.
996 *-musl*) gl_cv_func_printf_flag_zero="guessing yes";; 1375 *-musl* | midipix*) gl_cv_func_printf_flag_zero="guessing yes";;
997 # Guess yes on BeOS. 1376 # Guess yes on BeOS.
998 beos*) gl_cv_func_printf_flag_zero="guessing yes";; 1377 beos*) gl_cv_func_printf_flag_zero="guessing yes";;
999 # Guess no on Android. 1378 # Guess no on Android.
1000 linux*-android*) gl_cv_func_printf_flag_zero="guessing no";; 1379 linux*-android*) gl_cv_func_printf_flag_zero="guessing no";;
1001 # Guess no on native Windows. 1380 # Guess no on native Windows.
1002 mingw*) gl_cv_func_printf_flag_zero="guessing no";; 1381 mingw* | windows*) gl_cv_func_printf_flag_zero="guessing no";;
1003 # If we don't know, obey --enable-cross-guesses. 1382 # If we don't know, obey --enable-cross-guesses.
1004 *) gl_cv_func_printf_flag_zero="$gl_cross_guess_normal";; 1383 *) gl_cv_func_printf_flag_zero="$gl_cross_guess_normal";;
1384 esac
1385changequote([,])dnl
1386 ])
1387 ])
1388])
1389
1390dnl Test whether the *printf family of functions supports the # flag with a
1391dnl zero precision and a zero value in the 'x' and 'X' directives correctly.
1392dnl ISO C and POSIX specify that for the 'd', 'i', 'b', 'o', 'u', 'x', 'X'
1393dnl directives: "The result of converting a zero value with a precision of
1394dnl zero is no characters." But on Mac OS X 10.5, for the 'x', 'X' directives,
1395dnl when a # flag is present, the output is "0" instead of "".
1396dnl Result is gl_cv_func_printf_flag_alt_precision_zero.
1397
1398AC_DEFUN([gl_PRINTF_FLAG_ALT_PRECISION_ZERO],
1399[
1400 AC_REQUIRE([AC_PROG_CC])
1401 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1402 AC_CACHE_CHECK([whether printf supports the alternative flag with a zero precision],
1403 [gl_cv_func_printf_flag_alt_precision_zero],
1404 [
1405 AC_RUN_IFELSE(
1406 [AC_LANG_SOURCE([[
1407#include <stdio.h>
1408static char buf[10];
1409int main ()
1410{
1411 int result = 0;
1412 if (sprintf (buf, "%#.0x %d", 0, 33, 44) > 0 + 3)
1413 result |= 1;
1414 return result;
1415}]])],
1416 [gl_cv_func_printf_flag_alt_precision_zero=yes],
1417 [gl_cv_func_printf_flag_alt_precision_zero=no],
1418 [
1419changequote(,)dnl
1420 case "$host_os" in
1421 # Guess no only on macOS 10..12 systems.
1422 darwin[0-9] | darwin[0-9].* | \
1423 darwin1[0-9] | darwin1[0-9].* | \
1424 darwin2[0-1] | darwin2[0-1].*)
1425 gl_cv_func_printf_flag_alt_precision_zero="guessing no" ;;
1426 darwin*) gl_cv_func_printf_flag_alt_precision_zero="guessing yes" ;;
1427 *) gl_cv_func_printf_flag_alt_precision_zero="guessing yes" ;;
1005 esac 1428 esac
1006changequote([,])dnl 1429changequote([,])dnl
1007 ]) 1430 ])
@@ -1054,12 +1477,12 @@ int main ()
1054changequote(,)dnl 1477changequote(,)dnl
1055 case "$host_os" in 1478 case "$host_os" in
1056 # Guess no only on Solaris, native Windows, and BeOS systems. 1479 # Guess no only on Solaris, native Windows, and BeOS systems.
1057 solaris*) gl_cv_func_printf_precision="guessing no" ;; 1480 solaris*) gl_cv_func_printf_precision="guessing no" ;;
1058 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; 1481 mingw* | windows* | pw*) gl_cv_func_printf_precision="guessing no" ;;
1059 beos*) gl_cv_func_printf_precision="guessing no" ;; 1482 beos*) gl_cv_func_printf_precision="guessing no" ;;
1060 # Guess yes on Android. 1483 # Guess yes on Android.
1061 linux*-android*) gl_cv_func_printf_precision="guessing yes" ;; 1484 linux*-android*) gl_cv_func_printf_precision="guessing yes" ;;
1062 *) gl_cv_func_printf_precision="guessing yes" ;; 1485 *) gl_cv_func_printf_precision="guessing yes" ;;
1063 esac 1486 esac
1064changequote([,])dnl 1487changequote([,])dnl
1065 ]) 1488 ])
@@ -1239,7 +1662,7 @@ changequote(,)dnl
1239 # Guess yes on glibc systems. 1662 # Guess yes on glibc systems.
1240 *-gnu* | gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1663 *-gnu* | gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1241 # Guess yes on musl systems. 1664 # Guess yes on musl systems.
1242 *-musl*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1665 *-musl* | midipix*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1243 # Guess yes on FreeBSD >= 5. 1666 # Guess yes on FreeBSD >= 5.
1244 freebsd[1-4].*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1667 freebsd[1-4].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1245 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1668 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
@@ -1275,7 +1698,7 @@ changequote(,)dnl
1275 # Guess yes on Android. 1698 # Guess yes on Android.
1276 linux*-android*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1699 linux*-android*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1277 # Guess no on native Windows. 1700 # Guess no on native Windows.
1278 mingw*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1701 mingw* | windows*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1279 # If we don't know, obey --enable-cross-guesses. 1702 # If we don't know, obey --enable-cross-guesses.
1280 *) gl_cv_func_snprintf_truncation_c99="$gl_cross_guess_normal";; 1703 *) gl_cv_func_snprintf_truncation_c99="$gl_cross_guess_normal";;
1281 esac 1704 esac
@@ -1344,7 +1767,7 @@ changequote(,)dnl
1344 # Guess yes on glibc systems. 1767 # Guess yes on glibc systems.
1345 *-gnu* | gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1768 *-gnu* | gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1346 # Guess yes on musl systems. 1769 # Guess yes on musl systems.
1347 *-musl*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1770 *-musl* | midipix*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1348 # Guess yes on FreeBSD >= 5. 1771 # Guess yes on FreeBSD >= 5.
1349 freebsd[1-4].*) gl_cv_func_snprintf_retval_c99="guessing no";; 1772 freebsd[1-4].*) gl_cv_func_snprintf_retval_c99="guessing no";;
1350 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1773 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
@@ -1372,7 +1795,8 @@ changequote(,)dnl
1372 linux*-android*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1795 linux*-android*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1373changequote([,])dnl 1796changequote([,])dnl
1374 # Guess yes on MSVC, no on mingw. 1797 # Guess yes on MSVC, no on mingw.
1375 mingw*) AC_EGREP_CPP([Known], [ 1798 windows*-msvc*) gl_cv_func_snprintf_retval_c99="guessing yes" ;;
1799 mingw* | windows*) AC_EGREP_CPP([Known], [
1376#ifdef _MSC_VER 1800#ifdef _MSC_VER
1377 Known 1801 Known
1378#endif 1802#endif
@@ -1401,8 +1825,14 @@ AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N],
1401 [ 1825 [
1402 AC_RUN_IFELSE( 1826 AC_RUN_IFELSE(
1403 [AC_LANG_SOURCE([[ 1827 [AC_LANG_SOURCE([[
1828#include <signal.h>
1404#include <stdio.h> 1829#include <stdio.h>
1405#include <string.h> 1830#include <string.h>
1831#if defined _WIN32 && !defined __CYGWIN__
1832# include <stdlib.h>
1833#else
1834# include <unistd.h>
1835#endif
1406#if HAVE_SNPRINTF 1836#if HAVE_SNPRINTF
1407# define my_snprintf snprintf 1837# define my_snprintf snprintf
1408#else 1838#else
@@ -1417,11 +1847,18 @@ static int my_snprintf (char *buf, int size, const char *format, ...)
1417 return ret; 1847 return ret;
1418} 1848}
1419#endif 1849#endif
1850static void
1851abort_handler (int sig)
1852{
1853 (void) sig;
1854 _exit (1);
1855}
1420static char fmtstring[10]; 1856static char fmtstring[10];
1421static char buf[100]; 1857static char buf[100];
1422int main () 1858int main ()
1423{ 1859{
1424 int count = -1; 1860 int count = -1;
1861 signal (SIGABRT, abort_handler);
1425 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) 1862 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2)
1426 support %n in format strings in read-only memory but not in writable 1863 support %n in format strings in read-only memory but not in writable
1427 memory. */ 1864 memory. */
@@ -1447,7 +1884,7 @@ int main ()
1447 ;; 1884 ;;
1448changequote(,)dnl 1885changequote(,)dnl
1449 # Guess yes on musl systems. 1886 # Guess yes on musl systems.
1450 *-musl*) gl_cv_func_snprintf_directive_n="guessing yes";; 1887 *-musl* | midipix*) gl_cv_func_snprintf_directive_n="guessing yes";;
1451 # Guess yes on FreeBSD >= 5. 1888 # Guess yes on FreeBSD >= 5.
1452 freebsd[1-4].*) gl_cv_func_snprintf_directive_n="guessing no";; 1889 freebsd[1-4].*) gl_cv_func_snprintf_directive_n="guessing no";;
1453 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; 1890 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
@@ -1476,7 +1913,7 @@ changequote(,)dnl
1476 # Guess no on Android. 1913 # Guess no on Android.
1477 linux*-android*) gl_cv_func_snprintf_directive_n="guessing no";; 1914 linux*-android*) gl_cv_func_snprintf_directive_n="guessing no";;
1478 # Guess no on native Windows. 1915 # Guess no on native Windows.
1479 mingw*) gl_cv_func_snprintf_directive_n="guessing no";; 1916 mingw* | windows*) gl_cv_func_snprintf_directive_n="guessing no";;
1480 # If we don't know, obey --enable-cross-guesses. 1917 # If we don't know, obey --enable-cross-guesses.
1481 *) gl_cv_func_snprintf_directive_n="$gl_cross_guess_normal";; 1918 *) gl_cv_func_snprintf_directive_n="$gl_cross_guess_normal";;
1482changequote([,])dnl 1919changequote([,])dnl
@@ -1524,11 +1961,11 @@ int main()
1524 [gl_cv_func_snprintf_size1=yes], 1961 [gl_cv_func_snprintf_size1=yes],
1525 [gl_cv_func_snprintf_size1=no], 1962 [gl_cv_func_snprintf_size1=no],
1526 [case "$host_os" in 1963 [case "$host_os" in
1527 # Guess yes on Android. 1964 # Guess yes on Android.
1528 linux*-android*) gl_cv_func_snprintf_size1="guessing yes" ;; 1965 linux*-android*) gl_cv_func_snprintf_size1="guessing yes" ;;
1529 # Guess yes on native Windows. 1966 # Guess yes on native Windows.
1530 mingw*) gl_cv_func_snprintf_size1="guessing yes" ;; 1967 mingw* | windows*) gl_cv_func_snprintf_size1="guessing yes" ;;
1531 *) gl_cv_func_snprintf_size1="guessing yes" ;; 1968 *) gl_cv_func_snprintf_size1="guessing yes" ;;
1532 esac 1969 esac
1533 ]) 1970 ])
1534 ]) 1971 ])
@@ -1601,128 +2038,324 @@ int main()
1601 [ 2038 [
1602changequote(,)dnl 2039changequote(,)dnl
1603 case "$host_os" in 2040 case "$host_os" in
1604 # Guess yes on glibc systems. 2041 # Guess yes on glibc systems.
1605 *-gnu* | gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2042 *-gnu* | gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1606 # Guess yes on musl systems. 2043 # Guess yes on musl systems.
1607 *-musl*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2044 *-musl* | midipix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1608 # Guess yes on FreeBSD >= 5. 2045 # Guess yes on FreeBSD >= 5.
1609 freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 2046 freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1610 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2047 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1611 midnightbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2048 midnightbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1612 # Guess yes on Mac OS X >= 10.3. 2049 # Guess yes on Mac OS X >= 10.3.
1613 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 2050 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1614 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2051 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1615 # Guess yes on Cygwin. 2052 # Guess yes on Cygwin.
1616 cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2053 cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1617 # Guess yes on Solaris >= 2.6. 2054 # Guess yes on Solaris >= 2.6.
1618 solaris2.[0-5] | solaris2.[0-5].*) 2055 solaris2.[0-5] | solaris2.[0-5].*)
1619 gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 2056 gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1620 solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2057 solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1621 # Guess yes on AIX >= 4. 2058 # Guess yes on AIX >= 4.
1622 aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 2059 aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1623 aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2060 aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1624 # Guess yes on IRIX >= 6.5. 2061 # Guess yes on IRIX >= 6.5.
1625 irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2062 irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1626 # Guess yes on NetBSD >= 3. 2063 # Guess yes on NetBSD >= 3.
1627 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 2064 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1628 gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 2065 gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1629 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2066 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1630 # Guess yes on BeOS. 2067 # Guess yes on BeOS.
1631 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2068 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1632 # Guess yes on Android. 2069 # Guess yes on Android.
1633 linux*-android*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2070 linux*-android*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1634 # Guess yes on native Windows. 2071 # Guess yes on native Windows.
1635 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2072 mingw* | windows* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1636 # If we don't know, obey --enable-cross-guesses. 2073 # If we don't know, obey --enable-cross-guesses.
1637 *) gl_cv_func_vsnprintf_zerosize_c99="$gl_cross_guess_normal";; 2074 *) gl_cv_func_vsnprintf_zerosize_c99="$gl_cross_guess_normal";;
1638 esac 2075 esac
1639changequote([,])dnl 2076changequote([,])dnl
1640 ]) 2077 ])
1641 ]) 2078 ])
1642]) 2079])
1643 2080
2081dnl Test whether the swprintf function works correctly when it produces output
2082dnl that contains null wide characters.
2083dnl Result is gl_cv_func_swprintf_works.
2084
2085AC_DEFUN([gl_SWPRINTF_WORKS],
2086[
2087 AC_REQUIRE([AC_PROG_CC])
2088 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
2089 AC_CHECK_FUNCS_ONCE([swprintf])
2090 AC_CACHE_CHECK([whether swprintf works],
2091 [gl_cv_func_swprintf_works],
2092 [
2093 AC_RUN_IFELSE(
2094 [AC_LANG_SOURCE([[
2095#ifndef __USE_MINGW_ANSI_STDIO
2096# define __USE_MINGW_ANSI_STDIO 1
2097#endif
2098#include <stdio.h>
2099#include <wchar.h>
2100int main()
2101{
2102 int result = 0;
2103 { /* This test fails on musl libc 1.2.3, FreeBSD, NetBSD, OpenBSD, macOS, AIX. */
2104 wchar_t buf[5] = { 0xBEEF, 0xBEEF, 0xBEEF, 0xBEEF, 0xBEEF };
2105 int ret = swprintf (buf, 4, L"%cz", '\0');
2106 /* Expected result:
2107 ret = 2, buf[0] = 0x0, buf[1] = 0x7a, buf[2] = 0x0, buf[3] = 0xbeef
2108 musl libc 1.2.3:
2109 ret = 2, buf[0] = 0x0, buf[1] = 0x0, buf[2] = 0x0, buf[3] = 0x0
2110 Reported at <https://www.openwall.com/lists/musl/2023/03/22/9>.
2111 FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2:
2112 ret = 2, buf[0] = 0x0, buf[1] = 0xbeef, buf[2] = 0xbeef, buf[3] = 0xbeef
2113 */
2114 if (ret < 0 || buf[1] != 'z')
2115 result |= 1;
2116 }
2117 { /* This test fails on mingw. */
2118 wchar_t buf[2];
2119 int ret = swprintf (buf, 2, L"%lc", (wint_t)0);
2120 /* Expected: ret = 1
2121 mingw: ret = 0
2122 */
2123 if (ret != 1)
2124 result |= 2;
2125 }
2126 return result;
2127}]])],
2128 [gl_cv_func_swprintf_works=yes],
2129 [gl_cv_func_swprintf_works=no],
2130 [case "$host_os" in
2131 # Guess yes on glibc systems.
2132 *-gnu* | gnu*) gl_cv_func_swprintf_works="guessing yes";;
2133 # Guess no on musl systems.
2134 *-musl* | midipix*) gl_cv_func_swprintf_works="guessing no";;
2135 # Guess no on FreeBSD, NetBSD, OpenBSD, macOS, AIX.
2136 freebsd* | midnightbsd* | netbsd* | openbsd* | darwin* | aix*)
2137 gl_cv_func_swprintf_works="guessing no";;
2138 # Guess no on native Windows.
2139 mingw* | windows* | pw*) gl_cv_func_swprintf_works="guessing no";;
2140 # If we don't know, obey --enable-cross-guesses.
2141 *) gl_cv_func_swprintf_works="$gl_cross_guess_normal";;
2142 esac
2143 ])
2144 ])
2145])
2146
2147dnl Test whether the *wprintf family of functions supports the 'a' and 'A'
2148dnl conversion specifier for hexadecimal output of 'long double' numbers.
2149dnl (ISO C99, POSIX:2001)
2150dnl Result is gl_cv_func_swprintf_directive_la.
2151
2152AC_DEFUN([gl_SWPRINTF_DIRECTIVE_LA],
2153[
2154 AC_REQUIRE([AC_PROG_CC])
2155 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
2156 AC_CACHE_CHECK([whether swprintf supports the 'La' and 'LA' directives],
2157 [gl_cv_func_swprintf_directive_la],
2158 [
2159 AC_RUN_IFELSE(
2160 [AC_LANG_SOURCE([[
2161#include <stdio.h>
2162#include <wchar.h>
2163static wchar_t buf[100];
2164int main ()
2165{
2166 int result = 0;
2167 /* This catches a glibc 2.15, Haiku 2022, NetBSD 10.0 bug. */
2168 if (swprintf (buf, sizeof (buf) / sizeof (wchar_t),
2169 L"%La %d", 3.1416015625L, 33, 44, 55) < 0
2170 || (wcscmp (buf, L"0x1.922p+1 33") != 0
2171 && wcscmp (buf, L"0x3.244p+0 33") != 0
2172 && wcscmp (buf, L"0x6.488p-1 33") != 0
2173 && wcscmp (buf, L"0xc.91p-2 33") != 0))
2174 result |= 1;
2175 return result;
2176}]])],
2177 [gl_cv_func_swprintf_directive_la=yes],
2178 [gl_cv_func_swprintf_directive_la=no],
2179 [case "$host_os" in
2180 # Guess yes on glibc >= 2.17 systems.
2181 *-gnu* | gnu*)
2182 AC_EGREP_CPP([Unlucky], [
2183 #include <features.h>
2184 #ifdef __GNU_LIBRARY__
2185 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16) || (__GLIBC__ > 2)) && !defined __UCLIBC__
2186 Unlucky
2187 #endif
2188 #endif
2189 ],
2190 [gl_cv_func_swprintf_directive_la="guessing yes"],
2191 [gl_cv_func_swprintf_directive_la="guessing no"])
2192 ;;
2193 # Guess yes on musl systems.
2194 *-musl* | midipix*) gl_cv_func_swprintf_directive_la="guessing yes";;
2195 # Guess yes on Android.
2196 linux*-android*) gl_cv_func_swprintf_directive_la="guessing yes";;
2197 # Guess no on NetBSD.
2198 netbsd*) gl_cv_func_swprintf_directive_la="guessing no";;
2199 # Guess no on native Windows.
2200 mingw* | windows*) gl_cv_func_swprintf_directive_la="guessing no";;
2201 # If we don't know, obey --enable-cross-guesses.
2202 *) gl_cv_func_swprintf_directive_la="$gl_cross_guess_normal";;
2203 esac
2204 ])
2205 ])
2206])
2207
2208dnl Test whether the *wprintf family of functions supports the 'lc' conversion
2209dnl specifier for all wide characters.
2210dnl (ISO C11, POSIX:2001)
2211dnl Result is gl_cv_func_swprintf_directive_lc.
2212
2213AC_DEFUN([gl_SWPRINTF_DIRECTIVE_LC],
2214[
2215 AC_REQUIRE([AC_PROG_CC])
2216 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
2217 AC_CACHE_CHECK([whether swprintf supports the 'lc' directive],
2218 [gl_cv_func_swprintf_directive_lc],
2219 [
2220 AC_RUN_IFELSE(
2221 [AC_LANG_SOURCE([[
2222#include <stdio.h>
2223#include <wchar.h>
2224static wchar_t buf[100];
2225static wint_t L_invalid = (wchar_t) 0x76543210;
2226int main ()
2227{
2228 int result = 0;
2229 /* This catches a musl libc 1.2.4, Android bug.
2230 Reported at <https://www.openwall.com/lists/musl/2023/06/12/3>. */
2231 if (swprintf (buf, sizeof (buf) / sizeof (wchar_t),
2232 L"%lc %d", L_invalid, 33, 44, 55) < 0)
2233 result |= 1;
2234 return result;
2235}]])],
2236 [gl_cv_func_swprintf_directive_lc=yes],
2237 [gl_cv_func_swprintf_directive_lc=no],
2238 [case "$host_os" in
2239 # Guess yes on glibc systems.
2240 *-gnu* | gnu*) gl_cv_func_swprintf_directive_lc="guessing yes";;
2241 # Guess no on musl systems.
2242 *-musl* | midipix*) gl_cv_func_swprintf_directive_lc="guessing no";;
2243 # Guess no on Android.
2244 linux*-android*) gl_cv_func_swprintf_directive_lc="guessing no";;
2245 # Guess yes on native Windows.
2246 mingw* | windows*) gl_cv_func_swprintf_directive_lc="guessing yes";;
2247 # If we don't know, obey --enable-cross-guesses.
2248 *) gl_cv_func_swprintf_directive_lc="$gl_cross_guess_normal";;
2249 esac
2250 ])
2251 ])
2252])
2253
1644dnl The results of these tests on various platforms are: 2254dnl The results of these tests on various platforms are:
1645dnl 2255dnl
1646dnl 1 = gl_PRINTF_SIZES_C99 2256dnl 1 = gl_PRINTF_SIZES_C99
1647dnl 2 = gl_PRINTF_LONG_DOUBLE 2257dnl 2 = gl_PRINTF_SIZES_C23
1648dnl 3 = gl_PRINTF_INFINITE 2258dnl 3 = gl_PRINTF_LONG_DOUBLE
1649dnl 4 = gl_PRINTF_INFINITE_LONG_DOUBLE 2259dnl 4 = gl_PRINTF_INFINITE
1650dnl 5 = gl_PRINTF_DIRECTIVE_A 2260dnl 5 = gl_PRINTF_INFINITE_LONG_DOUBLE
1651dnl 6 = gl_PRINTF_DIRECTIVE_F 2261dnl 6 = gl_PRINTF_DIRECTIVE_A
1652dnl 7 = gl_PRINTF_DIRECTIVE_N 2262dnl 7 = gl_PRINTF_DIRECTIVE_B
1653dnl 8 = gl_PRINTF_DIRECTIVE_LS 2263dnl 8 = gl_PRINTF_DIRECTIVE_UPPERCASE_B
1654dnl 9 = gl_PRINTF_POSITIONS 2264dnl 9 = gl_PRINTF_DIRECTIVE_F
1655dnl 10 = gl_PRINTF_FLAG_GROUPING 2265dnl 10 = gl_PRINTF_DIRECTIVE_N
1656dnl 11 = gl_PRINTF_FLAG_LEFTADJUST 2266dnl 11 = gl_PRINTF_DIRECTIVE_LS
1657dnl 12 = gl_PRINTF_FLAG_ZERO 2267dnl 12 = gl_PRINTF_DIRECTIVE_LC
1658dnl 13 = gl_PRINTF_PRECISION 2268dnl 13 = gl_PRINTF_POSITIONS
1659dnl 14 = gl_PRINTF_ENOMEM 2269dnl 14 = gl_PRINTF_FLAG_GROUPING
1660dnl 15 = gl_SNPRINTF_PRESENCE 2270dnl 15 = gl_PRINTF_FLAG_GROUPING_INT_PRECISION
1661dnl 16 = gl_SNPRINTF_TRUNCATION_C99 2271dnl 16 = gl_PRINTF_FLAG_GROUPING_MULTIBYTE
1662dnl 17 = gl_SNPRINTF_RETVAL_C99 2272dnl 17 = gl_PRINTF_FLAG_LEFTADJUST
1663dnl 18 = gl_SNPRINTF_DIRECTIVE_N 2273dnl 18 = gl_PRINTF_FLAG_ZERO
1664dnl 19 = gl_SNPRINTF_SIZE1 2274dnl 19 = gl_PRINTF_FLAG_ALT_PRECISION_ZERO
1665dnl 20 = gl_VSNPRINTF_ZEROSIZE_C99 2275dnl 20 = gl_PRINTF_PRECISION
2276dnl 21 = gl_PRINTF_ENOMEM
2277dnl 22 = gl_SNPRINTF_PRESENCE
2278dnl 23 = gl_SNPRINTF_TRUNCATION_C99
2279dnl 24 = gl_SNPRINTF_RETVAL_C99
2280dnl 25 = gl_SNPRINTF_DIRECTIVE_N
2281dnl 26 = gl_SNPRINTF_SIZE1
2282dnl 27 = gl_VSNPRINTF_ZEROSIZE_C99
2283dnl 28 = gl_SWPRINTF_WORKS
2284dnl 29 = gl_SWPRINTF_DIRECTIVE_LA
2285dnl 30 = gl_SWPRINTF_DIRECTIVE_LC
1666dnl 2286dnl
1667dnl 1 = checking whether printf supports size specifiers as in C99... 2287dnl 1 = checking whether printf supports size specifiers as in C99...
1668dnl 2 = checking whether printf supports 'long double' arguments... 2288dnl 2 = checking whether printf supports size specifiers as in C23...
1669dnl 3 = checking whether printf supports infinite 'double' arguments... 2289dnl 3 = checking whether printf supports 'long double' arguments...
1670dnl 4 = checking whether printf supports infinite 'long double' arguments... 2290dnl 4 = checking whether printf supports infinite 'double' arguments...
1671dnl 5 = checking whether printf supports the 'a' and 'A' directives... 2291dnl 5 = checking whether printf supports infinite 'long double' arguments...
1672dnl 6 = checking whether printf supports the 'F' directive... 2292dnl 6 = checking whether printf supports the 'a' and 'A' directives...
1673dnl 7 = checking whether printf supports the 'n' directive... 2293dnl 7 = checking whether printf supports the 'b' directive...
1674dnl 8 = checking whether printf supports the 'ls' directive... 2294dnl 8 = checking whether printf supports the 'B' directive...
1675dnl 9 = checking whether printf supports POSIX/XSI format strings with positions... 2295dnl 9 = checking whether printf supports the 'F' directive...
1676dnl 10 = checking whether printf supports the grouping flag... 2296dnl 10 = checking whether printf supports the 'n' directive...
1677dnl 11 = checking whether printf supports the left-adjust flag correctly... 2297dnl 11 = checking whether printf supports the 'ls' directive...
1678dnl 12 = checking whether printf supports the zero flag correctly... 2298dnl 12 = checking whether printf supports the 'lc' directive correctly...
1679dnl 13 = checking whether printf supports large precisions... 2299dnl 13 = checking whether printf supports POSIX/XSI format strings with positions...
1680dnl 14 = checking whether printf survives out-of-memory conditions... 2300dnl 14 = checking whether printf supports the grouping flag...
1681dnl 15 = checking for snprintf... 2301dnl 15 = checking whether printf supports grouping on integers with a precision...
1682dnl 16 = checking whether snprintf truncates the result as in C99... 2302dnl 16 = checking whether printf supports grouping with a multibyte separator...
1683dnl 17 = checking whether snprintf returns a byte count as in C99... 2303dnl 17 = checking whether printf supports the left-adjust flag correctly...
1684dnl 18 = checking whether snprintf fully supports the 'n' directive... 2304dnl 18 = checking whether printf supports the zero flag correctly...
1685dnl 19 = checking whether snprintf respects a size of 1... 2305dnl 19 = checking whether printf supports the alternative flag with a zero precision...
1686dnl 20 = checking whether vsnprintf respects a zero size as in C99... 2306dnl 20 = checking whether printf supports large precisions...
2307dnl 21 = checking whether printf survives out-of-memory conditions...
2308dnl 22 = checking for snprintf...
2309dnl 23 = checking whether snprintf truncates the result as in C99...
2310dnl 24 = checking whether snprintf returns a byte count as in C99...
2311dnl 25 = checking whether snprintf fully supports the 'n' directive...
2312dnl 26 = checking whether snprintf respects a size of 1...
2313dnl 27 = checking whether vsnprintf respects a zero size as in C99...
2314dnl 28 = checking whether swprintf works...
2315dnl 29 = checking whether swprintf supports the 'La' and 'LA' directives...
2316dnl 30 = checking whether swprintf supports the 'lc' directive...
1687dnl 2317dnl
1688dnl . = yes, # = no. 2318dnl . = yes, # = no.
1689dnl 2319dnl
1690dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2320dnl 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 29 30
1691dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . . 2321dnl musl libc 1.2.3 . # . . . . # # . . . # . . . . . . . . . . . . . . . # . #
1692dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . . 2322dnl glibc 2.35 . # . . . . . . . . . . . . # . . . . . . . . . . . . . . .
1693dnl FreeBSD 13.0 . . . . # . . . . . . . . # . . . . . . 2323dnl glibc 2.5 . # . . . . # # . . . . . . # . . . . . . . . . . . . . # .
1694dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . . 2324dnl glibc 2.3.6 . # . . . # # # . . . . . . . . . . . . . . . . . . . . # .
1695dnl Mac OS X 10.13.5 . . . # # . # . . . . . . . . . . # . . 2325dnl FreeBSD 14.0 . . . . . # . . . . . . . . # . . . . . # . . . . . . # . #
1696dnl Mac OS X 10.5.8 . . . # # . . . . . . # . . . . . . . . 2326dnl FreeBSD 13.0 . # . . . # # # . . . . . . # . . . . . # . . . . . . # . #
1697dnl Mac OS X 10.3.9 . . . . # . . . . . . # . # . . . . . . 2327dnl FreeBSD 5.4, 6.1 . # . . . # # # . . . . . . . . . # ? . # . . . . . . # ? ?
1698dnl OpenBSD 6.0, 6.7 . . . . # . . . . . . . . # . . . . . . 2328dnl Mac OS X 10.13.5 . # . . # # # # . # . . . . ? ? . . . . . . . . # . . # ? ?
1699dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . . 2329dnl Mac OS X 10.5.8 . # . . # # # # . . . . . . ? ? . # # . . . . . . . . # ? ?
1700dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . . 2330dnl Mac OS X 10.3.9 . # . . . # # # . . . . . . ? ? . # # . # . . . . . . # ? ?
1701dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . . 2331dnl OpenBSD 6.0, 6.7 . # . . . # # # . . . . . . . . . . . . # . . . . . . # . #
1702dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . . 2332dnl OpenBSD 3.9, 4.0 . # . # # # # # # . # . . # ? ? . # ? . # . . . . . . # ? ?
1703dnl Solaris 11.4 . . # # # . . # . . . # . . . . . . . . 2333dnl Cygwin 1.7.0 (2009) . # . . # . # # . . ? ? . . ? ? . . ? . ? . . . . . . ? ? ?
1704dnl Solaris 11.3 . . . . # . . # . . . . . . . . . . . . 2334dnl Cygwin 1.5.25 (2008) . # . . # # # # . . # ? . . ? ? . . ? . # . . . . . . ? ? ?
1705dnl Solaris 11.0 . . # # # . . # . . . # . . . . . . . . 2335dnl Cygwin 1.5.19 (2006) # # . . # # # # # . # ? . # ? ? . # ? # # . . . . . . ? ? ?
1706dnl Solaris 10 . . # # # . . # . . . # # . . . . . . . 2336dnl Solaris 11.4 . # . # # # # # . . # . . . # # . # . . . . . . . . . . # .
1707dnl Solaris 2.6 ... 9 # . # # # # . # . . . # # . . . # . . . 2337dnl Solaris 11.3 . # . . . # # # . . # . . . ? ? . . . . . . . . . . . . # .
1708dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # # 2338dnl Solaris 11.0 . # . # # # # # . . # . . . ? ? . # . . . . . . . . . ? ? ?
1709dnl AIX 7.1 . . # # # . . . . . . # # . . . . . . . 2339dnl Solaris 10 . # . # # # # # . . # . . . # # . # . # . . . . . . . . # .
1710dnl AIX 5.2 . . # # # . . . . . . # . . . . . . . . 2340dnl Solaris 2.6 ... 9 # # . # # # # # # . # . . . ? ? . # ? # . . . # . . . ? ? ?
1711dnl AIX 4.3.2, 5.1 # . # # # # . . . . . # . . . . # . . . 2341dnl Solaris 2.5.1 # # . # # # # # # . # . . . ? ? . # ? . . # # # # # # ? ? ?
1712dnl HP-UX 11.31 . . . . # . . . . . . # . . . . # # . . 2342dnl AIX 7.1 . # . # # # # # . . . . . . . . . # . # . . . . . . . # . .
1713dnl HP-UX 11.{00,11,23} # . . . # # . . . . . # . . . . # # . # 2343dnl AIX 5.2 . # . # # # # # . . . . . . ? ? . # ? . . . . . . . . # ? ?
1714dnl HP-UX 10.20 # . # . # # . ? . . # # . . . . # # ? # 2344dnl AIX 4.3.2, 5.1 # # . # # # # # # . . . . . ? ? . # ? . . . . # . . . # ? ?
1715dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . . 2345dnl HP-UX 11.31 . # . . . # # # . . . ? . . ? ? . # ? . . . . # # . . ? ? ?
1716dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . # 2346dnl HP-UX 11.{00,11,23} # # . . . # # # # . . ? . . ? ? . # ? . . . . # # . # ? ? ?
1717dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # # 2347dnl HP-UX 10.20 # # . # . # # # # . ? ? . . ? ? # # ? . . . . # # ? # ? ? ?
1718dnl NetBSD 9.0 . . . . # . . . . . . . . . . . . . . . 2348dnl IRIX 6.5 # # . # # # # # # . # . . . ? ? . # ? . . . . # . . . # ? ?
1719dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . . 2349dnl OSF/1 5.1 # # . # # # # # # . . ? . . ? ? . # ? . . . . # . . # ? ? ?
1720dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ? 2350dnl OSF/1 4.0d # # . # # # # # # . . ? . . ? ? . # ? . . # # # # # # ? ? ?
1721dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . . 2351dnl NetBSD 9.0 . # . . . # # # . . . . . . # # . . . . . . . . . . . # . #
1722dnl Haiku . . . # # # . # . . . . . ? . . ? . . . 2352dnl NetBSD 5.0 . # . . # # # # . . . . . . ? ? . # ? . # . . . . . . # ? ?
1723dnl BeOS # # . # # # . ? # . ? . # ? . . ? . . . 2353dnl NetBSD 4.0 . # ? ? ? ? # # ? . ? . . ? ? ? ? ? ? ? ? . . . ? ? ? # ? ?
1724dnl Android 4.3 . . # # # # # # . # . # . # . . . # . . 2354dnl NetBSD 3.0 . # . . . # # # # . ? . # # ? ? ? # ? . # . . . . . . # ? ?
1725dnl old mingw / msvcrt # # # # # # . . # # . # # ? . # # # . . 2355dnl Haiku . # . . # # # # # . # ? . . # . . . ? . ? . . ? . . . . # .
1726dnl MSVC 9 # # # # # # # . # # . # # ? # # # # . . 2356dnl BeOS # # # . # # # # # . ? ? # . ? ? ? . ? # ? . . ? . . . ? ? ?
1727dnl mingw 2009-2011 . # . # . . . . # # . . . ? . . . . . . 2357dnl Android 4.3 . # . # # # # # # # # ? . # ? ? . # ? . # . . . # . . ? ? ?
1728dnl mingw-w64 2011 # # # # # # . . # # . # # ? . # # # . . 2358dnl old mingw / msvcrt # # # # # # # # # . . ? # # ? ? . # ? # ? . # # # . . # ? ?
2359dnl MSVC 9 # # # # # # # # # # . ? # # ? ? . # ? # ? # # # # . . # ? ?
2360dnl mingw 2009-2011 . # # . # . # # . . . ? # # ? ? . . ? . ? . . . . . . # ? ?
2361dnl mingw-w64 2011 # # # # # # # # # . . ? # # ? ? . # ? # ? . # # # . . # ? ?