2 dnl Copyright (C) 2003, 2007 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 the 'a' and 'A'
85 dnl conversion specifier for hexadecimal output of floating-point numbers.
86 dnl (ISO C99, POSIX:2001)
87 dnl Result is gl_cv_func_printf_directive_a.
89 AC_DEFUN([gl_PRINTF_DIRECTIVE_A],
91 AC_REQUIRE([AC_PROG_CC])
92 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
93 AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives],
94 [gl_cv_func_printf_directive_a],
102 if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0
103 || (strcmp (buf, "0x1.922p+1 33") != 0
104 && strcmp (buf, "0x3.244p+0 33") != 0
105 && strcmp (buf, "0x6.488p-1 33") != 0
106 && strcmp (buf, "0xc.91p-2 33") != 0))
108 if (sprintf (buf, "%A %d", -3.1416015625, 33, 44, 55) < 0
109 || (strcmp (buf, "-0X1.922P+1 33") != 0
110 && strcmp (buf, "-0X3.244P+0 33") != 0
111 && strcmp (buf, "-0X6.488P-1 33") != 0
112 && strcmp (buf, "-0XC.91P-2 33") != 0))
114 /* This catches a FreeBSD 6.1 bug: it doesn't round. */
115 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0
116 || (strcmp (buf, "0x1.83p+0 33") != 0
117 && strcmp (buf, "0x3.05p-1 33") != 0
118 && strcmp (buf, "0x6.0ap-2 33") != 0
119 && strcmp (buf, "0xc.14p-3 33") != 0))
121 /* This catches a FreeBSD 6.1 bug. See
122 <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
123 if (sprintf (buf, "%010a %d", 1.0 / 0.0, 33, 44, 55) < 0
126 /* This catches a MacOS X 10.3.9 (Darwin 7.9) bug. */
127 if (sprintf (buf, "%.1a", 1.999) < 0
128 || (strcmp (buf, "0x1.0p+1") != 0
129 && strcmp (buf, "0x2.0p+0") != 0
130 && strcmp (buf, "0x4.0p-1") != 0
131 && strcmp (buf, "0x8.0p-2") != 0))
133 /* This catches the same MacOS X 10.3.9 (Darwin 7.9) bug and also a
134 glibc 2.4 bug <http://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */
135 if (sprintf (buf, "%.1La", 1.999L) < 0
136 || (strcmp (buf, "0x1.0p+1") != 0
137 && strcmp (buf, "0x2.0p+0") != 0
138 && strcmp (buf, "0x4.0p-1") != 0
139 && strcmp (buf, "0x8.0p-2") != 0))
142 }], [gl_cv_func_printf_directive_a=yes], [gl_cv_func_printf_directive_a=no],
145 # Guess yes on glibc >= 2.5 systems.
147 AC_EGREP_CPP([BZ2908], [
148 #include <features.h>
149 #ifdef __GNU_LIBRARY__
150 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2)
155 [gl_cv_func_printf_directive_a="guessing yes"],
156 [gl_cv_func_printf_directive_a="guessing no"])
158 # If we don't know, assume the worst.
159 *) gl_cv_func_printf_directive_a="guessing no";;
165 dnl Test whether the *printf family of functions supports the %F format
166 dnl directive. (ISO C99, POSIX:2001)
167 dnl Result is gl_cv_func_printf_directive_f.
169 AC_DEFUN([gl_PRINTF_DIRECTIVE_F],
171 AC_REQUIRE([AC_PROG_CC])
172 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
173 AC_CACHE_CHECK([whether printf supports the 'F' directive],
174 [gl_cv_func_printf_directive_f],
179 static char buf[100];
182 if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0
183 || strcmp (buf, "1234567.000000 33") != 0)
185 if (sprintf (buf, "%F", 1.0 / 0.0) < 0
186 || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0))
188 /* This catches a Cygwin 2007 bug. */
189 if (sprintf (buf, "%.F", 1234.0) < 0
190 || strcmp (buf, "1234") != 0)
193 }], [gl_cv_func_printf_directive_f=yes], [gl_cv_func_printf_directive_f=no],
197 # Guess yes on glibc systems.
198 *-gnu*) gl_cv_func_printf_directive_f="guessing yes";;
199 # Guess yes on FreeBSD >= 6.
200 freebsd[1-5]*) gl_cv_func_printf_directive_f="guessing no";;
201 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";;
202 # Guess yes on MacOS X >= 10.3.
203 darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";;
204 darwin*) gl_cv_func_printf_directive_f="guessing yes";;
205 # Guess yes on Solaris >= 2.10.
206 solaris2.[0-9]*) gl_cv_func_printf_directive_f="guessing no";;
207 solaris*) gl_cv_func_printf_directive_f="guessing yes";;
208 # If we don't know, assume the worst.
209 *) gl_cv_func_printf_directive_f="guessing no";;
216 dnl Test whether the *printf family of functions supports the %n format
217 dnl directive. (ISO C99, POSIX:2001)
218 dnl Result is gl_cv_func_printf_directive_n.
220 AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
222 AC_REQUIRE([AC_PROG_CC])
223 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
224 AC_CACHE_CHECK([whether printf supports the 'n' directive],
225 [gl_cv_func_printf_directive_n],
230 static char buf[100];
234 if (sprintf (buf, "%d %n", 123, &count, 33, 44, 55) < 0
235 || strcmp (buf, "123 ") != 0
239 }], [gl_cv_func_printf_directive_n=yes], [gl_cv_func_printf_directive_n=no],
243 *) gl_cv_func_printf_directive_n="guessing yes";;
250 dnl Test whether the *printf family of functions supports POSIX/XSI format
251 dnl strings with positions. (POSIX:2001)
252 dnl Result is gl_cv_func_printf_positions.
254 AC_DEFUN([gl_PRINTF_POSITIONS],
256 AC_REQUIRE([AC_PROG_CC])
257 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
258 AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions],
259 [gl_cv_func_printf_positions],
264 /* The string "%2$d %1$d", with dollar characters protected from the shell's
265 dollar expansion (possibly an autoconf bug). */
266 static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' };
267 static char buf[100];
270 sprintf (buf, format, 33, 55);
271 return (strcmp (buf, "55 33") != 0);
272 }], [gl_cv_func_printf_positions=yes], [gl_cv_func_printf_positions=no],
276 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
277 gl_cv_func_printf_positions="guessing no";;
278 beos*) gl_cv_func_printf_positions="guessing no";;
279 mingw* | pw*) gl_cv_func_printf_positions="guessing no";;
280 *) gl_cv_func_printf_positions="guessing yes";;
287 dnl Test whether the *printf family of functions supports POSIX/XSI format
288 dnl strings with the ' flag for grouping of decimal digits. (POSIX:2001)
289 dnl Result is gl_cv_func_printf_flag_grouping.
291 AC_DEFUN([gl_PRINTF_FLAG_GROUPING],
293 AC_REQUIRE([AC_PROG_CC])
294 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
295 AC_CACHE_CHECK([whether printf supports the grouping flag],
296 [gl_cv_func_printf_flag_grouping],
301 static char buf[100];
304 if (sprintf (buf, "%'d %d", 1234567, 99) < 0
305 || buf[strlen (buf) - 1] != '9')
308 }], [gl_cv_func_printf_flag_grouping=yes], [gl_cv_func_printf_flag_grouping=no],
312 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";;
313 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
314 *) gl_cv_func_printf_flag_grouping="guessing yes";;
321 dnl Test whether the *printf family of functions supports padding of non-finite
322 dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See
323 dnl <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html>
324 dnl Result is gl_cv_func_printf_flag_zero.
326 AC_DEFUN([gl_PRINTF_FLAG_ZERO],
328 AC_REQUIRE([AC_PROG_CC])
329 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
330 AC_CACHE_CHECK([whether printf supports the zero flag correctly],
331 [gl_cv_func_printf_flag_zero],
336 static char buf[100];
339 if (sprintf (buf, "%010f", 1.0 / 0.0, 33, 44, 55) < 0
340 || (strcmp (buf, " inf") != 0
341 && strcmp (buf, " infinity") != 0))
344 }], [gl_cv_func_printf_flag_zero=yes], [gl_cv_func_printf_flag_zero=no],
348 # Guess yes on glibc systems.
349 *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";;
351 beos*) gl_cv_func_printf_flag_zero="guessing yes";;
352 # If we don't know, assume the worst.
353 *) gl_cv_func_printf_flag_zero="guessing no";;
360 dnl Test whether the snprintf function exists. (ISO C99, POSIX:2001)
361 dnl Result is ac_cv_func_snprintf.
363 AC_DEFUN([gl_SNPRINTF_PRESENCE],
365 AC_CHECK_FUNCS_ONCE([snprintf])
368 dnl Test whether the string produced by the snprintf function is always NUL
369 dnl terminated. (ISO C99, POSIX:2001)
370 dnl Result is gl_cv_func_snprintf_truncation_c99.
372 AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99],
374 AC_REQUIRE([AC_PROG_CC])
375 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
376 AC_CACHE_CHECK([whether snprintf truncates the result as in C99],
377 [gl_cv_func_snprintf_truncation_c99],
382 static char buf[100];
385 strcpy (buf, "ABCDEF");
386 snprintf (buf, 3, "%d %d", 4567, 89);
387 if (memcmp (buf, "45\0DEF", 6) != 0)
390 }], [gl_cv_func_snprintf_truncation_c99=yes], [gl_cv_func_snprintf_truncation_c99=no],
394 # Guess yes on glibc systems.
395 *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
396 # Guess yes on FreeBSD >= 5.
397 freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
398 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
399 # Guess yes on MacOS X >= 10.3.
400 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
401 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
402 # Guess yes on OpenBSD >= 3.9.
403 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
404 gl_cv_func_snprintf_truncation_c99="guessing no";;
405 openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
406 # Guess yes on Solaris >= 2.6.
407 solaris2.[0-5]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
408 solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
409 # Guess yes on AIX >= 4.
410 aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
411 aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
412 # Guess yes on HP-UX >= 11.
413 hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";;
414 hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
415 # Guess yes on IRIX >= 6.5.
416 irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";;
417 # Guess yes on OSF/1 >= 5.
418 osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
419 osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
420 # Guess yes on NetBSD >= 3.
421 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
422 gl_cv_func_snprintf_truncation_c99="guessing no";;
423 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
425 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
426 # If we don't know, assume the worst.
427 *) gl_cv_func_snprintf_truncation_c99="guessing no";;
434 dnl Test whether the return value of the snprintf function is the number
435 dnl of bytes (excluding the terminating NUL) that would have been produced
436 dnl if the buffer had been large enough. (ISO C99, POSIX:2001)
437 dnl For example, this test program fails on IRIX 6.5:
438 dnl ---------------------------------------------------------------------
439 dnl #include <stdio.h>
442 dnl static char buf[8];
443 dnl int retval = snprintf (buf, 3, "%d", 12345);
444 dnl return retval >= 0 && retval < 3;
446 dnl ---------------------------------------------------------------------
447 dnl Result is gl_cv_func_snprintf_retval_c99.
449 AC_DEFUN([gl_SNPRINTF_RETVAL_C99],
451 AC_REQUIRE([AC_PROG_CC])
452 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
453 AC_CACHE_CHECK([whether snprintf returns a byte count as in C99],
454 [gl_cv_func_snprintf_retval_c99],
459 static char buf[100];
462 strcpy (buf, "ABCDEF");
463 if (snprintf (buf, 3, "%d %d", 4567, 89) != 7)
466 }], [gl_cv_func_snprintf_retval_c99=yes], [gl_cv_func_snprintf_retval_c99=no],
470 # Guess yes on glibc systems.
471 *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";;
472 # Guess yes on FreeBSD >= 5.
473 freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";;
474 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
475 # Guess yes on MacOS X >= 10.3.
476 darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";;
477 darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";;
478 # Guess yes on OpenBSD >= 3.9.
479 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
480 gl_cv_func_snprintf_retval_c99="guessing no";;
481 openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
482 # Guess yes on Solaris >= 2.6.
483 solaris2.[0-5]*) gl_cv_func_snprintf_retval_c99="guessing no";;
484 solaris*) gl_cv_func_snprintf_retval_c99="guessing yes";;
485 # Guess yes on AIX >= 4.
486 aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";;
487 aix*) gl_cv_func_snprintf_retval_c99="guessing yes";;
488 # Guess yes on NetBSD >= 3.
489 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
490 gl_cv_func_snprintf_retval_c99="guessing no";;
491 netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
493 beos*) gl_cv_func_snprintf_retval_c99="guessing yes";;
494 # If we don't know, assume the worst.
495 *) gl_cv_func_snprintf_retval_c99="guessing no";;
502 dnl Test whether the snprintf function supports the %n format directive
503 dnl also in truncated portions of the format string. (ISO C99, POSIX:2001)
504 dnl Result is gl_cv_func_snprintf_directive_n.
506 AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N],
508 AC_REQUIRE([AC_PROG_CC])
509 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
510 AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive],
511 [gl_cv_func_snprintf_directive_n],
516 static char buf[100];
520 snprintf (buf, 4, "%d %n", 12345, &count, 33, 44, 55);
524 }], [gl_cv_func_snprintf_directive_n=yes], [gl_cv_func_snprintf_directive_n=no],
528 # Guess yes on glibc systems.
529 *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";;
530 # Guess yes on FreeBSD >= 5.
531 freebsd[1-4]*) gl_cv_func_snprintf_directive_n="guessing no";;
532 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
533 # Guess yes on MacOS X >= 10.3.
534 darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";;
535 darwin*) gl_cv_func_snprintf_directive_n="guessing yes";;
536 # Guess yes on Solaris >= 2.6.
537 solaris2.[0-5]*) gl_cv_func_snprintf_directive_n="guessing no";;
538 solaris*) gl_cv_func_snprintf_directive_n="guessing yes";;
539 # Guess yes on AIX >= 4.
540 aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";;
541 aix*) gl_cv_func_snprintf_directive_n="guessing yes";;
542 # Guess yes on IRIX >= 6.5.
543 irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";;
544 # Guess yes on OSF/1 >= 5.
545 osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";;
546 osf*) gl_cv_func_snprintf_directive_n="guessing yes";;
547 # Guess yes on NetBSD >= 3.
548 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
549 gl_cv_func_snprintf_directive_n="guessing no";;
550 netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
552 beos*) gl_cv_func_snprintf_directive_n="guessing yes";;
553 # If we don't know, assume the worst.
554 *) gl_cv_func_snprintf_directive_n="guessing no";;
561 dnl Test whether the vsnprintf function, when passed a zero size, produces no
562 dnl output. (ISO C99, POSIX:2001)
563 dnl For example, snprintf nevertheless writes a NUL byte in this case
565 dnl ---------------------------------------------------------------------
566 dnl #include <stdio.h>
569 dnl static char buf[8] = "DEADBEEF";
570 dnl snprintf (buf, 0, "%d", 12345);
571 dnl return buf[0] != 'D';
573 dnl ---------------------------------------------------------------------
574 dnl And vsnprintf writes any output without bounds in this case, behaving like
575 dnl vsprintf, on HP-UX 11 and OSF/1 5.1:
576 dnl ---------------------------------------------------------------------
577 dnl #include <stdarg.h>
578 dnl #include <stdio.h>
579 dnl static int my_snprintf (char *buf, int size, const char *format, ...)
583 dnl va_start (args, format);
584 dnl ret = vsnprintf (buf, size, format, args);
590 dnl static char buf[8] = "DEADBEEF";
591 dnl my_snprintf (buf, 0, "%d", 12345);
592 dnl return buf[0] != 'D';
594 dnl ---------------------------------------------------------------------
595 dnl Result is gl_cv_func_vsnprintf_zerosize_c99.
597 AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99],
599 AC_REQUIRE([AC_PROG_CC])
600 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
601 AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99],
602 [gl_cv_func_vsnprintf_zerosize_c99],
607 static int my_snprintf (char *buf, int size, const char *format, ...)
611 va_start (args, format);
612 ret = vsnprintf (buf, size, format, args);
618 static char buf[8] = "DEADBEEF";
619 my_snprintf (buf, 0, "%d", 12345);
620 return buf[0] != 'D';
622 [gl_cv_func_vsnprintf_zerosize_c99=yes],
623 [gl_cv_func_vsnprintf_zerosize_c99=no],
627 # Guess yes on glibc systems.
628 *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
629 # Guess yes on FreeBSD >= 5.
630 freebsd[1-4]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
631 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
632 # Guess yes on MacOS X >= 10.3.
633 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
634 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
635 # Guess yes on Solaris >= 2.6.
636 solaris2.[0-5]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
637 solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
638 # Guess yes on AIX >= 4.
639 aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
640 aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
641 # Guess yes on IRIX >= 6.5.
642 irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
643 # Guess yes on NetBSD >= 3.
644 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
645 gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
646 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
648 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
649 # Guess yes on mingw.
650 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
651 # If we don't know, assume the worst.
652 *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
659 dnl The results of these tests on various platforms are:
661 dnl 1 = gl_PRINTF_SIZES_C99
662 dnl 2 = gl_PRINTF_DIRECTIVE_A
663 dnl 3 = gl_PRINTF_DIRECTIVE_F
664 dnl 4 = gl_PRINTF_DIRECTIVE_N
665 dnl 5 = gl_PRINTF_POSITIONS
666 dnl 6 = gl_PRINTF_FLAG_GROUPING
667 dnl 7 = gl_PRINTF_FLAG_ZERO
668 dnl 8 = gl_SNPRINTF_PRESENCE
669 dnl 9 = gl_SNPRINTF_TRUNCATION_C99
670 dnl 10 = gl_SNPRINTF_RETVAL_C99
671 dnl 11 = gl_SNPRINTF_DIRECTIVE_N
672 dnl 12 = gl_VSNPRINTF_ZEROSIZE_C99
674 dnl 1 = checking whether printf supports size specifiers as in C99...
675 dnl 2 = checking whether printf supports the 'a' and 'A' directives...
676 dnl 3 = checking whether printf supports the 'F' directive...
677 dnl 4 = checking whether printf supports the 'n' directive...
678 dnl 5 = checking whether printf supports POSIX/XSI format strings with positions...
679 dnl 6 = checking whether printf supports the grouping flag...
680 dnl 7 = checking whether printf supports the zero flag correctly...
681 dnl 8 = checking for snprintf...
682 dnl 9 = checking whether snprintf truncates the result as in C99...
683 dnl 10 = checking whether snprintf returns a byte count as in C99...
684 dnl 11 = checking whether snprintf fully supports the 'n' directive...
685 dnl 12 = checking whether vsnprintf respects a zero size as in C99...
689 dnl 1 2 3 4 5 6 7 8 9 10 11 12
690 dnl glibc 2.5 . . . . . . . . . . . .
691 dnl glibc 2.3.6 . # . . . . . . . . . .
692 dnl FreeBSD 5.4, 6.1 . ? . . . . # . . . . .
693 dnl MacOS X 10.3.9 . # . . . . # . . . . .
694 dnl OpenBSD 3.9, 4.0 . # ? . . ? ? . . . ? ?
695 dnl Cygwin 2007 . # # . . ? ? . . . . ?
696 dnl Cygwin 2006 # # # . . ? ? . . . . ?
697 dnl Solaris 10 . # . . . . # . . . . .
698 dnl Solaris 2.6 ... 9 # # # . . . # . . . . .
699 dnl Solaris 2.5.1 # # # . . . # # # # # #
700 dnl AIX 5.2 . # . . . . # . . . . .
701 dnl AIX 4.3.2, 5.1 # # # . . . # . . . . .
702 dnl HP-UX 11.31 . # . . . . # . . # # .
703 dnl HP-UX 10.20, 11.00, 11.11, 11.23 # # # . . . # . . # # #
704 dnl IRIX 6.5 # # # . . . # . . # . .
705 dnl OSF/1 5.1 # # # . . . # . . # . #
706 dnl OSF/1 4.0d # # # . . . # # # # # #
707 dnl NetBSD 4.0 . ? ? . . ? ? . . . ? ?
708 dnl NetBSD 3.0 . # # . # # # . . . . .
709 dnl BeOS # # # . # . . . . . . .
710 dnl mingw # # # . # # # . # # # .