2 dnl Copyright (C) 2003, 2007-2009 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 dnl Test whether the *printf family of functions supports the 'j', 'z', 't',
8 dnl 'L' size specifiers. (ISO C99, POSIX:2001)
9 dnl Result is gl_cv_func_printf_sizes_c99.
11 AC_DEFUN([gl_PRINTF_SIZES_C99],
13 AC_REQUIRE([AC_PROG_CC])
14 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
15 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
16 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
17 AC_CACHE_CHECK([whether printf supports size specifiers as in C99],
18 [gl_cv_func_printf_sizes_c99],
24 #include <sys/types.h>
25 #if HAVE_STDINT_H_WITH_UINTMAX
28 #if HAVE_INTTYPES_H_WITH_UINTMAX
29 # include <inttypes.h>
34 #if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX
36 if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0
37 || strcmp (buf, "12345671 33") != 0)
41 if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0
42 || strcmp (buf, "12345672 33") != 0)
45 if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0
46 || strcmp (buf, "12345673 33") != 0)
49 if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0
50 || strcmp (buf, "1.5 33") != 0)
53 }], [gl_cv_func_printf_sizes_c99=yes], [gl_cv_func_printf_sizes_c99=no],
57 # Guess yes on glibc systems.
58 *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";;
59 # Guess yes on FreeBSD >= 5.
60 freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";;
61 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
62 # Guess yes on MacOS X >= 10.3.
63 darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";;
64 darwin*) gl_cv_func_printf_sizes_c99="guessing yes";;
65 # Guess yes on OpenBSD >= 3.9.
66 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
67 gl_cv_func_printf_sizes_c99="guessing no";;
68 openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
69 # Guess yes on Solaris >= 2.10.
70 solaris2.[0-9]*) gl_cv_func_printf_sizes_c99="guessing no";;
71 solaris*) gl_cv_func_printf_sizes_c99="guessing yes";;
72 # Guess yes on NetBSD >= 3.
73 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
74 gl_cv_func_printf_sizes_c99="guessing no";;
75 netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
76 # If we don't know, assume the worst.
77 *) gl_cv_func_printf_sizes_c99="guessing no";;
84 dnl Test whether the *printf family of functions supports 'long double'
85 dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001)
86 dnl Result is gl_cv_func_printf_long_double.
88 AC_DEFUN([gl_PRINTF_LONG_DOUBLE],
90 AC_REQUIRE([AC_PROG_CC])
91 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
92 AC_CACHE_CHECK([whether printf supports 'long double' arguments],
93 [gl_cv_func_printf_long_double],
98 static char buf[10000];
102 if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0
103 || strcmp (buf, "1.750000 33") != 0)
106 if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0
107 || strcmp (buf, "1.750000e+00 33") != 0)
110 if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0
111 || strcmp (buf, "1.75 33") != 0)
114 }], [gl_cv_func_printf_long_double=yes], [gl_cv_func_printf_long_double=no],
118 beos*) gl_cv_func_printf_long_double="guessing no";;
119 mingw* | pw*) gl_cv_func_printf_long_double="guessing no";;
120 *) gl_cv_func_printf_long_double="guessing yes";;
127 dnl Test whether the *printf family of functions supports infinite and NaN
128 dnl 'double' arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001)
129 dnl Result is gl_cv_func_printf_infinite.
131 AC_DEFUN([gl_PRINTF_INFINITE],
133 AC_REQUIRE([AC_PROG_CC])
134 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
135 AC_CACHE_CHECK([whether printf supports infinite 'double' arguments],
136 [gl_cv_func_printf_infinite],
142 strisnan (const char *string, size_t start_index, size_t end_index)
144 if (start_index < end_index)
146 if (string[start_index] == '-')
148 if (start_index + 3 <= end_index
149 && memcmp (string + start_index, "nan", 3) == 0)
152 if (start_index == end_index
153 || (string[start_index] == '(' && string[end_index - 1] == ')'))
159 static char buf[10000];
160 static double zero = 0.0;
163 if (sprintf (buf, "%f", 1.0 / 0.0) < 0
164 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
166 if (sprintf (buf, "%f", -1.0 / 0.0) < 0
167 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
169 if (sprintf (buf, "%f", zero / zero) < 0
170 || !strisnan (buf, 0, strlen (buf)))
172 if (sprintf (buf, "%e", 1.0 / 0.0) < 0
173 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
175 if (sprintf (buf, "%e", -1.0 / 0.0) < 0
176 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
178 if (sprintf (buf, "%e", zero / zero) < 0
179 || !strisnan (buf, 0, strlen (buf)))
181 if (sprintf (buf, "%g", 1.0 / 0.0) < 0
182 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
184 if (sprintf (buf, "%g", -1.0 / 0.0) < 0
185 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
187 if (sprintf (buf, "%g", zero / zero) < 0
188 || !strisnan (buf, 0, strlen (buf)))
191 }], [gl_cv_func_printf_infinite=yes], [gl_cv_func_printf_infinite=no],
195 # Guess yes on glibc systems.
196 *-gnu*) gl_cv_func_printf_infinite="guessing yes";;
197 # Guess yes on FreeBSD >= 6.
198 freebsd[1-5]*) gl_cv_func_printf_infinite="guessing no";;
199 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";;
200 # Guess yes on MacOS X >= 10.3.
201 darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";;
202 darwin*) gl_cv_func_printf_infinite="guessing yes";;
203 # Guess yes on HP-UX >= 11.
204 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";;
205 hpux*) gl_cv_func_printf_infinite="guessing yes";;
206 # Guess yes on NetBSD >= 3.
207 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
208 gl_cv_func_printf_infinite="guessing no";;
209 netbsd*) gl_cv_func_printf_infinite="guessing yes";;
211 beos*) gl_cv_func_printf_infinite="guessing yes";;
212 # If we don't know, assume the worst.
213 *) gl_cv_func_printf_infinite="guessing no";;
220 dnl Test whether the *printf family of functions supports infinite and NaN
221 dnl 'long double' arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001)
222 dnl Result is gl_cv_func_printf_infinite_long_double.
224 AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE],
226 AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
227 AC_REQUIRE([AC_PROG_CC])
228 AC_REQUIRE([gl_BIGENDIAN])
229 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
230 dnl The user can set or unset the variable gl_printf_safe to indicate
231 dnl that he wishes a safe handling of non-IEEE-754 'long double' values.
232 if test -n "$gl_printf_safe"; then
233 AC_DEFINE([CHECK_PRINTF_SAFE], [1],
234 [Define if you wish *printf() functions that have a safe handling of
235 non-IEEE-754 'long double' values.])
237 case "$gl_cv_func_printf_long_double" in
239 AC_CACHE_CHECK([whether printf supports infinite 'long double' arguments],
240 [gl_cv_func_printf_infinite_long_double],
248 strisnan (const char *string, size_t start_index, size_t end_index)
250 if (start_index < end_index)
252 if (string[start_index] == '-')
254 if (start_index + 3 <= end_index
255 && memcmp (string + start_index, "nan", 3) == 0)
258 if (start_index == end_index
259 || (string[start_index] == '(' && string[end_index - 1] == ')'))
265 static char buf[10000];
266 static long double zeroL = 0.0L;
270 if (sprintf (buf, "%Lf", 1.0L / 0.0L) < 0
271 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
273 if (sprintf (buf, "%Lf", -1.0L / 0.0L) < 0
274 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
276 if (sprintf (buf, "%Lf", zeroL / zeroL) < 0
277 || !strisnan (buf, 0, strlen (buf)))
279 if (sprintf (buf, "%Le", 1.0L / 0.0L) < 0
280 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
282 if (sprintf (buf, "%Le", -1.0L / 0.0L) < 0
283 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
285 if (sprintf (buf, "%Le", zeroL / zeroL) < 0
286 || !strisnan (buf, 0, strlen (buf)))
288 if (sprintf (buf, "%Lg", 1.0L / 0.0L) < 0
289 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
291 if (sprintf (buf, "%Lg", -1.0L / 0.0L) < 0
292 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
294 if (sprintf (buf, "%Lg", zeroL / zeroL) < 0
295 || !strisnan (buf, 0, strlen (buf)))
297 #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_))
298 /* Representation of an 80-bit 'long double' as an initializer for a sequence
299 of 'unsigned int' words. */
300 # ifdef WORDS_BIGENDIAN
301 # define LDBL80_WORDS(exponent,manthi,mantlo) \
302 { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \
303 ((unsigned int) (manthi) << 16) | (unsigned int) (mantlo) >> 16), \
304 (unsigned int) (mantlo) << 16 \
307 # define LDBL80_WORDS(exponent,manthi,mantlo) \
308 { mantlo, manthi, exponent }
311 static union { unsigned int word[4]; long double value; } x =
312 { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) };
313 if (sprintf (buf, "%Lf", x.value) < 0
314 || !strisnan (buf, 0, strlen (buf)))
316 if (sprintf (buf, "%Le", x.value) < 0
317 || !strisnan (buf, 0, strlen (buf)))
319 if (sprintf (buf, "%Lg", x.value) < 0
320 || !strisnan (buf, 0, strlen (buf)))
324 /* Signalling NaN. */
325 static union { unsigned int word[4]; long double value; } x =
326 { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) };
327 if (sprintf (buf, "%Lf", x.value) < 0
328 || !strisnan (buf, 0, strlen (buf)))
330 if (sprintf (buf, "%Le", x.value) < 0
331 || !strisnan (buf, 0, strlen (buf)))
333 if (sprintf (buf, "%Lg", x.value) < 0
334 || !strisnan (buf, 0, strlen (buf)))
338 static union { unsigned int word[4]; long double value; } x =
339 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) };
340 if (sprintf (buf, "%Lf", x.value) < 0
341 || !strisnan (buf, 0, strlen (buf)))
343 if (sprintf (buf, "%Le", x.value) < 0
344 || !strisnan (buf, 0, strlen (buf)))
346 if (sprintf (buf, "%Lg", x.value) < 0
347 || !strisnan (buf, 0, strlen (buf)))
350 { /* Pseudo-Infinity. */
351 static union { unsigned int word[4]; long double value; } x =
352 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) };
353 if (sprintf (buf, "%Lf", x.value) < 0
354 || !strisnan (buf, 0, strlen (buf)))
356 if (sprintf (buf, "%Le", x.value) < 0
357 || !strisnan (buf, 0, strlen (buf)))
359 if (sprintf (buf, "%Lg", x.value) < 0
360 || !strisnan (buf, 0, strlen (buf)))
364 static union { unsigned int word[4]; long double value; } x =
365 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) };
366 if (sprintf (buf, "%Lf", x.value) < 0
367 || !strisnan (buf, 0, strlen (buf)))
369 if (sprintf (buf, "%Le", x.value) < 0
370 || !strisnan (buf, 0, strlen (buf)))
372 if (sprintf (buf, "%Lg", x.value) < 0
373 || !strisnan (buf, 0, strlen (buf)))
376 { /* Unnormalized number. */
377 static union { unsigned int word[4]; long double value; } x =
378 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) };
379 if (sprintf (buf, "%Lf", x.value) < 0
380 || !strisnan (buf, 0, strlen (buf)))
382 if (sprintf (buf, "%Le", x.value) < 0
383 || !strisnan (buf, 0, strlen (buf)))
385 if (sprintf (buf, "%Lg", x.value) < 0
386 || !strisnan (buf, 0, strlen (buf)))
389 { /* Pseudo-Denormal. */
390 static union { unsigned int word[4]; long double value; } x =
391 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) };
392 if (sprintf (buf, "%Lf", x.value) < 0
393 || !strisnan (buf, 0, strlen (buf)))
395 if (sprintf (buf, "%Le", x.value) < 0
396 || !strisnan (buf, 0, strlen (buf)))
398 if (sprintf (buf, "%Lg", x.value) < 0
399 || !strisnan (buf, 0, strlen (buf)))
405 [gl_cv_func_printf_infinite_long_double=yes],
406 [gl_cv_func_printf_infinite_long_double=no],
410 # Guess no on ia64, x86_64, i386.
411 ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";;
414 # Guess yes on glibc systems.
415 *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";;
416 # Guess yes on FreeBSD >= 6.
417 freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";;
418 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
419 # Guess yes on MacOS X >= 10.3.
420 darwin[1-6].*) gl_cv_func_printf_infinite_long_double="guessing no";;
421 darwin*) gl_cv_func_printf_infinite_long_double="guessing yes";;
422 # Guess yes on HP-UX >= 11.
423 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";;
424 hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";;
425 # Guess yes on NetBSD >= 3.
426 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
427 gl_cv_func_printf_infinite_long_double="guessing no";;
428 netbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
429 # If we don't know, assume the worst.
430 *) gl_cv_func_printf_infinite_long_double="guessing no";;
439 gl_cv_func_printf_infinite_long_double="irrelevant"
444 dnl Test whether the *printf family of functions supports the 'a' and 'A'
445 dnl conversion specifier for hexadecimal output of floating-point numbers.
446 dnl (ISO C99, POSIX:2001)
447 dnl Result is gl_cv_func_printf_directive_a.
449 AC_DEFUN([gl_PRINTF_DIRECTIVE_A],
451 AC_REQUIRE([AC_PROG_CC])
452 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
453 AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives],
454 [gl_cv_func_printf_directive_a],
459 static char buf[100];
462 if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0
463 || (strcmp (buf, "0x1.922p+1 33") != 0
464 && strcmp (buf, "0x3.244p+0 33") != 0
465 && strcmp (buf, "0x6.488p-1 33") != 0
466 && strcmp (buf, "0xc.91p-2 33") != 0))
468 if (sprintf (buf, "%A %d", -3.1416015625, 33, 44, 55) < 0
469 || (strcmp (buf, "-0X1.922P+1 33") != 0
470 && strcmp (buf, "-0X3.244P+0 33") != 0
471 && strcmp (buf, "-0X6.488P-1 33") != 0
472 && strcmp (buf, "-0XC.91P-2 33") != 0))
474 /* This catches a FreeBSD 6.1 bug: it doesn't round. */
475 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0
476 || (strcmp (buf, "0x1.83p+0 33") != 0
477 && strcmp (buf, "0x3.05p-1 33") != 0
478 && strcmp (buf, "0x6.0ap-2 33") != 0
479 && strcmp (buf, "0xc.14p-3 33") != 0))
481 /* This catches a FreeBSD 6.1 bug. See
482 <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
483 if (sprintf (buf, "%010a %d", 1.0 / 0.0, 33, 44, 55) < 0
486 /* This catches a MacOS X 10.3.9 (Darwin 7.9) bug. */
487 if (sprintf (buf, "%.1a", 1.999) < 0
488 || (strcmp (buf, "0x1.0p+1") != 0
489 && strcmp (buf, "0x2.0p+0") != 0
490 && strcmp (buf, "0x4.0p-1") != 0
491 && strcmp (buf, "0x8.0p-2") != 0))
493 /* This catches the same MacOS X 10.3.9 (Darwin 7.9) bug and also a
494 glibc 2.4 bug <http://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */
495 if (sprintf (buf, "%.1La", 1.999L) < 0
496 || (strcmp (buf, "0x1.0p+1") != 0
497 && strcmp (buf, "0x2.0p+0") != 0
498 && strcmp (buf, "0x4.0p-1") != 0
499 && strcmp (buf, "0x8.0p-2") != 0))
502 }], [gl_cv_func_printf_directive_a=yes], [gl_cv_func_printf_directive_a=no],
505 # Guess yes on glibc >= 2.5 systems.
507 AC_EGREP_CPP([BZ2908], [
508 #include <features.h>
509 #ifdef __GNU_LIBRARY__
510 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2)
515 [gl_cv_func_printf_directive_a="guessing yes"],
516 [gl_cv_func_printf_directive_a="guessing no"])
518 # If we don't know, assume the worst.
519 *) gl_cv_func_printf_directive_a="guessing no";;
525 dnl Test whether the *printf family of functions supports the %F format
526 dnl directive. (ISO C99, POSIX:2001)
527 dnl Result is gl_cv_func_printf_directive_f.
529 AC_DEFUN([gl_PRINTF_DIRECTIVE_F],
531 AC_REQUIRE([AC_PROG_CC])
532 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
533 AC_CACHE_CHECK([whether printf supports the 'F' directive],
534 [gl_cv_func_printf_directive_f],
539 static char buf[100];
542 if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0
543 || strcmp (buf, "1234567.000000 33") != 0)
545 if (sprintf (buf, "%F", 1.0 / 0.0) < 0
546 || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0))
548 /* This catches a Cygwin 2007 bug. */
549 if (sprintf (buf, "%.F", 1234.0) < 0
550 || strcmp (buf, "1234") != 0)
553 }], [gl_cv_func_printf_directive_f=yes], [gl_cv_func_printf_directive_f=no],
557 # Guess yes on glibc systems.
558 *-gnu*) gl_cv_func_printf_directive_f="guessing yes";;
559 # Guess yes on FreeBSD >= 6.
560 freebsd[1-5]*) gl_cv_func_printf_directive_f="guessing no";;
561 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";;
562 # Guess yes on MacOS X >= 10.3.
563 darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";;
564 darwin*) gl_cv_func_printf_directive_f="guessing yes";;
565 # Guess yes on Solaris >= 2.10.
566 solaris2.[0-9]*) gl_cv_func_printf_directive_f="guessing no";;
567 solaris*) gl_cv_func_printf_directive_f="guessing yes";;
568 # If we don't know, assume the worst.
569 *) gl_cv_func_printf_directive_f="guessing no";;
576 dnl Test whether the *printf family of functions supports the %n format
577 dnl directive. (ISO C99, POSIX:2001)
578 dnl Result is gl_cv_func_printf_directive_n.
580 AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
582 AC_REQUIRE([AC_PROG_CC])
583 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
584 AC_CACHE_CHECK([whether printf supports the 'n' directive],
585 [gl_cv_func_printf_directive_n],
590 static char fmtstring[10];
591 static char buf[100];
595 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2)
596 support %n in format strings in read-only memory but not in writable
598 strcpy (fmtstring, "%d %n");
599 if (sprintf (buf, fmtstring, 123, &count, 33, 44, 55) < 0
600 || strcmp (buf, "123 ") != 0
604 }], [gl_cv_func_printf_directive_n=yes], [gl_cv_func_printf_directive_n=no],
608 *) gl_cv_func_printf_directive_n="guessing yes";;
615 dnl Test whether the *printf family of functions supports the %ls format
617 dnl Result is gl_cv_func_printf_directive_ls.
619 AC_DEFUN([gl_PRINTF_DIRECTIVE_LS],
621 AC_REQUIRE([AC_PROG_CC])
622 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
623 AC_CACHE_CHECK([whether printf supports the 'ls' directive],
624 [gl_cv_func_printf_directive_ls],
627 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
629 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
630 included before <wchar.h>. */
636 static wchar_t wstring[] = { 'a', 'b', 'c', 0 };
641 sprintf (buf, "%ls", wstring);
642 return strcmp (buf, "abc") != 0;
643 }], [gl_cv_func_printf_directive_ls=yes], [gl_cv_func_printf_directive_ls=no],
647 openbsd*) gl_cv_func_printf_directive_ls="guessing no";;
648 solaris2.[1-6]*) gl_cv_func_printf_directive_ls="guessing no";;
649 irix*) gl_cv_func_printf_directive_ls="guessing no";;
650 beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";;
651 *) gl_cv_func_printf_directive_ls="guessing yes";;
658 dnl Test whether the *printf family of functions supports POSIX/XSI format
659 dnl strings with positions. (POSIX:2001)
660 dnl Result is gl_cv_func_printf_positions.
662 AC_DEFUN([gl_PRINTF_POSITIONS],
664 AC_REQUIRE([AC_PROG_CC])
665 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
666 AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions],
667 [gl_cv_func_printf_positions],
672 /* The string "%2$d %1$d", with dollar characters protected from the shell's
673 dollar expansion (possibly an autoconf bug). */
674 static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' };
675 static char buf[100];
678 sprintf (buf, format, 33, 55);
679 return (strcmp (buf, "55 33") != 0);
680 }], [gl_cv_func_printf_positions=yes], [gl_cv_func_printf_positions=no],
684 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
685 gl_cv_func_printf_positions="guessing no";;
686 beos*) gl_cv_func_printf_positions="guessing no";;
687 mingw* | pw*) gl_cv_func_printf_positions="guessing no";;
688 *) gl_cv_func_printf_positions="guessing yes";;
695 dnl Test whether the *printf family of functions supports POSIX/XSI format
696 dnl strings with the ' flag for grouping of decimal digits. (POSIX:2001)
697 dnl Result is gl_cv_func_printf_flag_grouping.
699 AC_DEFUN([gl_PRINTF_FLAG_GROUPING],
701 AC_REQUIRE([AC_PROG_CC])
702 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
703 AC_CACHE_CHECK([whether printf supports the grouping flag],
704 [gl_cv_func_printf_flag_grouping],
709 static char buf[100];
712 if (sprintf (buf, "%'d %d", 1234567, 99) < 0
713 || buf[strlen (buf) - 1] != '9')
716 }], [gl_cv_func_printf_flag_grouping=yes], [gl_cv_func_printf_flag_grouping=no],
720 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";;
721 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";;
722 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
723 *) gl_cv_func_printf_flag_grouping="guessing yes";;
730 dnl Test whether the *printf family of functions supports the - flag correctly.
732 dnl <http://lists.gnu.org/archive/html/bug-coreutils/2008-02/msg00035.html>
733 dnl Result is gl_cv_func_printf_flag_leftadjust.
735 AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST],
737 AC_REQUIRE([AC_PROG_CC])
738 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
739 AC_CACHE_CHECK([whether printf supports the left-adjust flag correctly],
740 [gl_cv_func_printf_flag_leftadjust],
745 static char buf[100];
748 /* Check that a '-' flag is not annihilated by a negative width. */
749 if (sprintf (buf, "a%-*sc", -3, "b") < 0
750 || strcmp (buf, "ab c") != 0)
754 [gl_cv_func_printf_flag_leftadjust=yes],
755 [gl_cv_func_printf_flag_leftadjust=no],
759 # Guess yes on HP-UX 11.
760 hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
761 # Guess no on HP-UX 10 and older.
762 hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";;
763 # Guess yes otherwise.
764 *) gl_cv_func_printf_flag_leftadjust="guessing yes";;
771 dnl Test whether the *printf family of functions supports padding of non-finite
772 dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See
773 dnl <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html>
774 dnl Result is gl_cv_func_printf_flag_zero.
776 AC_DEFUN([gl_PRINTF_FLAG_ZERO],
778 AC_REQUIRE([AC_PROG_CC])
779 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
780 AC_CACHE_CHECK([whether printf supports the zero flag correctly],
781 [gl_cv_func_printf_flag_zero],
786 static char buf[100];
789 if (sprintf (buf, "%010f", 1.0 / 0.0, 33, 44, 55) < 0
790 || (strcmp (buf, " inf") != 0
791 && strcmp (buf, " infinity") != 0))
794 }], [gl_cv_func_printf_flag_zero=yes], [gl_cv_func_printf_flag_zero=no],
798 # Guess yes on glibc systems.
799 *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";;
801 beos*) gl_cv_func_printf_flag_zero="guessing yes";;
802 # If we don't know, assume the worst.
803 *) gl_cv_func_printf_flag_zero="guessing no";;
810 dnl Test whether the *printf family of functions supports large precisions.
811 dnl On mingw, precisions larger than 512 are treated like 512, in integer,
812 dnl floating-point or pointer output. On BeOS, precisions larger than 1044
813 dnl crash the program.
814 dnl Result is gl_cv_func_printf_precision.
816 AC_DEFUN([gl_PRINTF_PRECISION],
818 AC_REQUIRE([AC_PROG_CC])
819 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
820 AC_CACHE_CHECK([whether printf supports large precisions],
821 [gl_cv_func_printf_precision],
826 static char buf[5000];
830 /* On BeOS, this would crash and show a dialog box. Avoid the crash. */
833 if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3)
836 }], [gl_cv_func_printf_precision=yes], [gl_cv_func_printf_precision=no],
840 # Guess no only on native Win32 and BeOS systems.
841 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;;
842 beos*) gl_cv_func_printf_precision="guessing no" ;;
843 *) gl_cv_func_printf_precision="guessing yes" ;;
850 dnl Test whether the *printf family of functions recovers gracefully in case
851 dnl of an out-of-memory condition, or whether it crashes the entire program.
852 dnl Result is gl_cv_func_printf_enomem.
854 AC_DEFUN([gl_PRINTF_ENOMEM],
856 AC_REQUIRE([AC_PROG_CC])
857 AC_REQUIRE([gl_MULTIARCH])
858 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
859 AC_CACHE_CHECK([whether printf survives out-of-memory conditions],
860 [gl_cv_func_printf_enomem],
862 gl_cv_func_printf_enomem="guessing no"
863 if test "$cross_compiling" = no; then
864 if test $APPLE_UNIVERSAL_BUILD = 0; then
865 AC_LANG_CONFTEST([AC_LANG_SOURCE([
869 #include <sys/types.h>
870 #include <sys/time.h>
871 #include <sys/resource.h>
878 /* Some printf implementations allocate temporary space with malloc. */
879 /* On BSD systems, malloc() is limited by RLIMIT_DATA. */
881 if (getrlimit (RLIMIT_DATA, &limit) < 0)
883 if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
884 limit.rlim_max = 5000000;
885 limit.rlim_cur = limit.rlim_max;
886 if (setrlimit (RLIMIT_DATA, &limit) < 0)
889 /* On Linux systems, malloc() is limited by RLIMIT_AS. */
891 if (getrlimit (RLIMIT_AS, &limit) < 0)
893 if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
894 limit.rlim_max = 5000000;
895 limit.rlim_cur = limit.rlim_max;
896 if (setrlimit (RLIMIT_AS, &limit) < 0)
899 /* Some printf implementations allocate temporary space on the stack. */
901 if (getrlimit (RLIMIT_STACK, &limit) < 0)
903 if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
904 limit.rlim_max = 5000000;
905 limit.rlim_cur = limit.rlim_max;
906 if (setrlimit (RLIMIT_STACK, &limit) < 0)
909 ret = printf ("%.5000000f", 1.0);
910 return !(ret == 5000002 || (ret < 0 && errno == ENOMEM));
914 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
917 if test $result != 0 && test $result != 77; then result=1; fi
919 ) >/dev/null 2>/dev/null
921 0) gl_cv_func_printf_enomem="yes" ;;
922 77) gl_cv_func_printf_enomem="guessing no" ;;
923 *) gl_cv_func_printf_enomem="no" ;;
926 gl_cv_func_printf_enomem="guessing no"
930 dnl A universal build on Apple MacOS X platforms.
931 dnl The result would be 'no' in 32-bit mode and 'yes' in 64-bit mode.
932 dnl But we need a configuration result that is valid in both modes.
933 gl_cv_func_printf_enomem="guessing no"
936 if test "$gl_cv_func_printf_enomem" = "guessing no"; then
939 # Guess yes on glibc systems.
940 *-gnu*) gl_cv_func_printf_enomem="guessing yes";;
941 # Guess yes on Solaris.
942 solaris*) gl_cv_func_printf_enomem="guessing yes";;
944 aix*) gl_cv_func_printf_enomem="guessing yes";;
945 # Guess yes on HP-UX/hppa.
946 hpux*) case "$host_cpu" in
947 hppa*) gl_cv_func_printf_enomem="guessing yes";;
948 *) gl_cv_func_printf_enomem="guessing no";;
952 irix*) gl_cv_func_printf_enomem="guessing yes";;
953 # Guess yes on OSF/1.
954 osf*) gl_cv_func_printf_enomem="guessing yes";;
956 beos*) gl_cv_func_printf_enomem="guessing yes";;
957 # Guess yes on Haiku.
958 haiku*) gl_cv_func_printf_enomem="guessing yes";;
959 # If we don't know, assume the worst.
960 *) gl_cv_func_printf_enomem="guessing no";;
967 dnl Test whether the snprintf function exists. (ISO C99, POSIX:2001)
968 dnl Result is ac_cv_func_snprintf.
970 AC_DEFUN([gl_SNPRINTF_PRESENCE],
972 AC_CHECK_FUNCS_ONCE([snprintf])
975 dnl Test whether the string produced by the snprintf function is always NUL
976 dnl terminated. (ISO C99, POSIX:2001)
977 dnl Result is gl_cv_func_snprintf_truncation_c99.
979 AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99],
981 AC_REQUIRE([AC_PROG_CC])
982 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
983 AC_CACHE_CHECK([whether snprintf truncates the result as in C99],
984 [gl_cv_func_snprintf_truncation_c99],
989 static char buf[100];
992 strcpy (buf, "ABCDEF");
993 snprintf (buf, 3, "%d %d", 4567, 89);
994 if (memcmp (buf, "45\0DEF", 6) != 0)
997 }], [gl_cv_func_snprintf_truncation_c99=yes], [gl_cv_func_snprintf_truncation_c99=no],
1001 # Guess yes on glibc systems.
1002 *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1003 # Guess yes on FreeBSD >= 5.
1004 freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1005 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1006 # Guess yes on MacOS X >= 10.3.
1007 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1008 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1009 # Guess yes on OpenBSD >= 3.9.
1010 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
1011 gl_cv_func_snprintf_truncation_c99="guessing no";;
1012 openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1013 # Guess yes on Solaris >= 2.6.
1014 solaris2.[0-5]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1015 solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1016 # Guess yes on AIX >= 4.
1017 aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1018 aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1019 # Guess yes on HP-UX >= 11.
1020 hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1021 hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1022 # Guess yes on IRIX >= 6.5.
1023 irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1024 # Guess yes on OSF/1 >= 5.
1025 osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1026 osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1027 # Guess yes on NetBSD >= 3.
1028 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1029 gl_cv_func_snprintf_truncation_c99="guessing no";;
1030 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1031 # Guess yes on BeOS.
1032 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1033 # If we don't know, assume the worst.
1034 *) gl_cv_func_snprintf_truncation_c99="guessing no";;
1041 dnl Test whether the return value of the snprintf function is the number
1042 dnl of bytes (excluding the terminating NUL) that would have been produced
1043 dnl if the buffer had been large enough. (ISO C99, POSIX:2001)
1044 dnl For example, this test program fails on IRIX 6.5:
1045 dnl ---------------------------------------------------------------------
1046 dnl #include <stdio.h>
1049 dnl static char buf[8];
1050 dnl int retval = snprintf (buf, 3, "%d", 12345);
1051 dnl return retval >= 0 && retval < 3;
1053 dnl ---------------------------------------------------------------------
1054 dnl Result is gl_cv_func_snprintf_retval_c99.
1056 AC_DEFUN([gl_SNPRINTF_RETVAL_C99],
1058 AC_REQUIRE([AC_PROG_CC])
1059 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1060 AC_CACHE_CHECK([whether snprintf returns a byte count as in C99],
1061 [gl_cv_func_snprintf_retval_c99],
1066 static char buf[100];
1069 strcpy (buf, "ABCDEF");
1070 if (snprintf (buf, 3, "%d %d", 4567, 89) != 7)
1073 }], [gl_cv_func_snprintf_retval_c99=yes], [gl_cv_func_snprintf_retval_c99=no],
1077 # Guess yes on glibc systems.
1078 *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1079 # Guess yes on FreeBSD >= 5.
1080 freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";;
1081 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1082 # Guess yes on MacOS X >= 10.3.
1083 darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";;
1084 darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1085 # Guess yes on OpenBSD >= 3.9.
1086 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
1087 gl_cv_func_snprintf_retval_c99="guessing no";;
1088 openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1089 # Guess yes on Solaris >= 2.6.
1090 solaris2.[0-5]*) gl_cv_func_snprintf_retval_c99="guessing no";;
1091 solaris*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1092 # Guess yes on AIX >= 4.
1093 aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";;
1094 aix*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1095 # Guess yes on NetBSD >= 3.
1096 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1097 gl_cv_func_snprintf_retval_c99="guessing no";;
1098 netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1099 # Guess yes on BeOS.
1100 beos*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1101 # If we don't know, assume the worst.
1102 *) gl_cv_func_snprintf_retval_c99="guessing no";;
1109 dnl Test whether the snprintf function supports the %n format directive
1110 dnl also in truncated portions of the format string. (ISO C99, POSIX:2001)
1111 dnl Result is gl_cv_func_snprintf_directive_n.
1113 AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N],
1115 AC_REQUIRE([AC_PROG_CC])
1116 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1117 AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive],
1118 [gl_cv_func_snprintf_directive_n],
1123 static char fmtstring[10];
1124 static char buf[100];
1128 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2)
1129 support %n in format strings in read-only memory but not in writable
1131 strcpy (fmtstring, "%d %n");
1132 snprintf (buf, 4, fmtstring, 12345, &count, 33, 44, 55);
1136 }], [gl_cv_func_snprintf_directive_n=yes], [gl_cv_func_snprintf_directive_n=no],
1140 # Guess yes on glibc systems.
1141 *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";;
1142 # Guess yes on FreeBSD >= 5.
1143 freebsd[1-4]*) gl_cv_func_snprintf_directive_n="guessing no";;
1144 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1145 # Guess yes on MacOS X >= 10.3.
1146 darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";;
1147 darwin*) gl_cv_func_snprintf_directive_n="guessing yes";;
1148 # Guess yes on Solaris >= 2.6.
1149 solaris2.[0-5]*) gl_cv_func_snprintf_directive_n="guessing no";;
1150 solaris*) gl_cv_func_snprintf_directive_n="guessing yes";;
1151 # Guess yes on AIX >= 4.
1152 aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";;
1153 aix*) gl_cv_func_snprintf_directive_n="guessing yes";;
1154 # Guess yes on IRIX >= 6.5.
1155 irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";;
1156 # Guess yes on OSF/1 >= 5.
1157 osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";;
1158 osf*) gl_cv_func_snprintf_directive_n="guessing yes";;
1159 # Guess yes on NetBSD >= 3.
1160 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1161 gl_cv_func_snprintf_directive_n="guessing no";;
1162 netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1163 # Guess yes on BeOS.
1164 beos*) gl_cv_func_snprintf_directive_n="guessing yes";;
1165 # If we don't know, assume the worst.
1166 *) gl_cv_func_snprintf_directive_n="guessing no";;
1173 dnl Test whether the snprintf function, when passed a size = 1, writes any
1174 dnl output without bounds in this case, behaving like sprintf. This is the
1175 dnl case on Linux libc5.
1176 dnl Result is gl_cv_func_snprintf_size1.
1178 AC_DEFUN([gl_SNPRINTF_SIZE1],
1180 AC_REQUIRE([AC_PROG_CC])
1181 AC_CACHE_CHECK([whether snprintf respects a size of 1],
1182 [gl_cv_func_snprintf_size1],
1188 static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
1189 snprintf (buf, 1, "%d", 12345);
1190 return buf[1] != 'E';
1192 [gl_cv_func_snprintf_size1=yes],
1193 [gl_cv_func_snprintf_size1=no],
1194 [gl_cv_func_snprintf_size1="guessing yes"])
1198 dnl Test whether the vsnprintf function, when passed a zero size, produces no
1199 dnl output. (ISO C99, POSIX:2001)
1200 dnl For example, snprintf nevertheless writes a NUL byte in this case
1202 dnl ---------------------------------------------------------------------
1203 dnl #include <stdio.h>
1206 dnl static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
1207 dnl snprintf (buf, 0, "%d", 12345);
1208 dnl return buf[0] != 'D';
1210 dnl ---------------------------------------------------------------------
1211 dnl And vsnprintf writes any output without bounds in this case, behaving like
1212 dnl vsprintf, on HP-UX 11 and OSF/1 5.1:
1213 dnl ---------------------------------------------------------------------
1214 dnl #include <stdarg.h>
1215 dnl #include <stdio.h>
1216 dnl static int my_snprintf (char *buf, int size, const char *format, ...)
1220 dnl va_start (args, format);
1221 dnl ret = vsnprintf (buf, size, format, args);
1227 dnl static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
1228 dnl my_snprintf (buf, 0, "%d", 12345);
1229 dnl return buf[0] != 'D';
1231 dnl ---------------------------------------------------------------------
1232 dnl Result is gl_cv_func_vsnprintf_zerosize_c99.
1234 AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99],
1236 AC_REQUIRE([AC_PROG_CC])
1237 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1238 AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99],
1239 [gl_cv_func_vsnprintf_zerosize_c99],
1244 static int my_snprintf (char *buf, int size, const char *format, ...)
1248 va_start (args, format);
1249 ret = vsnprintf (buf, size, format, args);
1255 static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
1256 my_snprintf (buf, 0, "%d", 12345);
1257 return buf[0] != 'D';
1259 [gl_cv_func_vsnprintf_zerosize_c99=yes],
1260 [gl_cv_func_vsnprintf_zerosize_c99=no],
1264 # Guess yes on glibc systems.
1265 *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1266 # Guess yes on FreeBSD >= 5.
1267 freebsd[1-4]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1268 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1269 # Guess yes on MacOS X >= 10.3.
1270 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1271 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1272 # Guess yes on Cygwin.
1273 cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1274 # Guess yes on Solaris >= 2.6.
1275 solaris2.[0-5]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1276 solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1277 # Guess yes on AIX >= 4.
1278 aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1279 aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1280 # Guess yes on IRIX >= 6.5.
1281 irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1282 # Guess yes on NetBSD >= 3.
1283 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1284 gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1285 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1286 # Guess yes on BeOS.
1287 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1288 # Guess yes on mingw.
1289 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1290 # If we don't know, assume the worst.
1291 *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1298 dnl The results of these tests on various platforms are:
1300 dnl 1 = gl_PRINTF_SIZES_C99
1301 dnl 2 = gl_PRINTF_LONG_DOUBLE
1302 dnl 3 = gl_PRINTF_INFINITE
1303 dnl 4 = gl_PRINTF_INFINITE_LONG_DOUBLE
1304 dnl 5 = gl_PRINTF_DIRECTIVE_A
1305 dnl 6 = gl_PRINTF_DIRECTIVE_F
1306 dnl 7 = gl_PRINTF_DIRECTIVE_N
1307 dnl 8 = gl_PRINTF_DIRECTIVE_LS
1308 dnl 9 = gl_PRINTF_POSITIONS
1309 dnl 10 = gl_PRINTF_FLAG_GROUPING
1310 dnl 11 = gl_PRINTF_FLAG_LEFTADJUST
1311 dnl 12 = gl_PRINTF_FLAG_ZERO
1312 dnl 13 = gl_PRINTF_PRECISION
1313 dnl 14 = gl_PRINTF_ENOMEM
1314 dnl 15 = gl_SNPRINTF_PRESENCE
1315 dnl 16 = gl_SNPRINTF_TRUNCATION_C99
1316 dnl 17 = gl_SNPRINTF_RETVAL_C99
1317 dnl 18 = gl_SNPRINTF_DIRECTIVE_N
1318 dnl 19 = gl_SNPRINTF_SIZE1
1319 dnl 20 = gl_VSNPRINTF_ZEROSIZE_C99
1321 dnl 1 = checking whether printf supports size specifiers as in C99...
1322 dnl 2 = checking whether printf supports 'long double' arguments...
1323 dnl 3 = checking whether printf supports infinite 'double' arguments...
1324 dnl 4 = checking whether printf supports infinite 'long double' arguments...
1325 dnl 5 = checking whether printf supports the 'a' and 'A' directives...
1326 dnl 6 = checking whether printf supports the 'F' directive...
1327 dnl 7 = checking whether printf supports the 'n' directive...
1328 dnl 8 = checking whether printf supports the 'ls' directive...
1329 dnl 9 = checking whether printf supports POSIX/XSI format strings with positions...
1330 dnl 10 = checking whether printf supports the grouping flag...
1331 dnl 11 = checking whether printf supports the left-adjust flag correctly...
1332 dnl 12 = checking whether printf supports the zero flag correctly...
1333 dnl 13 = checking whether printf supports large precisions...
1334 dnl 14 = checking whether printf survives out-of-memory conditions...
1335 dnl 15 = checking for snprintf...
1336 dnl 16 = checking whether snprintf truncates the result as in C99...
1337 dnl 17 = checking whether snprintf returns a byte count as in C99...
1338 dnl 18 = checking whether snprintf fully supports the 'n' directive...
1339 dnl 19 = checking whether snprintf respects a size of 1...
1340 dnl 20 = checking whether vsnprintf respects a zero size as in C99...
1342 dnl . = yes, # = no.
1344 dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1345 dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . .
1346 dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . .
1347 dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . .
1348 dnl MacOS X 10.3.9 . . . . # . . . . . . # . # . . . . . .
1349 dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . .
1350 dnl Cygwin 2007 (= Cygwin 1.5.24) . . . . # # . . . . ? # ? ? . . . . . .
1351 dnl Cygwin 2006 (= Cygwin 1.5.19) # . . . # # . ? . # ? # ? ? . . . . . .
1352 dnl Solaris 10 . . # # # . . . . . . # . . . . . . . .
1353 dnl Solaris 7 ... 9 # . # # # # . . . . . # . . . . . . . .
1354 dnl Solaris 2.6 # . # # # # . # . . . # . . . . . . . .
1355 dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # #
1356 dnl AIX 5.2 . . # # # . . . . . . # . . . . . . . .
1357 dnl AIX 4.3.2, 5.1 # . # # # # . . . . . # . . . . . . . .
1358 dnl HP-UX 11.31 . . . . # . . . . . . # . . . . # # . .
1359 dnl HP-UX 11.{00,11,23} # . . . # # . . . . . # . . . . # # . #
1360 dnl HP-UX 10.20 # . . . # # . ? . . # # . . . . # # ? #
1361 dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . .
1362 dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . #
1363 dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # #
1364 dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ?
1365 dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . .
1366 dnl Haiku . . . # # # . # . . . . . ? . . . . . .
1367 dnl BeOS # # . # # # . ? # . ? . # ? . . . . . .
1368 dnl mingw # # # # # # . . # # . # # ? . # # # . .