1# printf.m4 serial 58 2dnl Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc. 3dnl This file is free software; the Free Software Foundation 4dnl gives unlimited permission to copy and/or distribute it, 5dnl with or without modifications, as long as this notice is preserved. 6 7dnl Test whether the *printf family of functions supports the 'j', 'z', 't', 8dnl 'L' size specifiers. (ISO C99, POSIX:2001) 9dnl Result is gl_cv_func_printf_sizes_c99. 10 11AC_DEFUN([gl_PRINTF_SIZES_C99], 12[ 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], 19 [ 20 AC_RUN_IFELSE( 21 [AC_LANG_SOURCE([[ 22#include <stddef.h> 23#include <stdio.h> 24#include <string.h> 25#include <sys/types.h> 26#if HAVE_STDINT_H_WITH_UINTMAX 27# include <stdint.h> 28#endif 29#if HAVE_INTTYPES_H_WITH_UINTMAX 30# include <inttypes.h> 31#endif 32static char buf[100]; 33int main () 34{ 35 int result = 0; 36#if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX 37 buf[0] = '\0'; 38 if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0 39 || strcmp (buf, "12345671 33") != 0) 40 result |= 1; 41#else 42 result |= 1; 43#endif 44 buf[0] = '\0'; 45 if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0 46 || strcmp (buf, "12345672 33") != 0) 47 result |= 2; 48 buf[0] = '\0'; 49 if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0 50 || strcmp (buf, "12345673 33") != 0) 51 result |= 4; 52 buf[0] = '\0'; 53 if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0 54 || strcmp (buf, "1.5 33") != 0) 55 result |= 8; 56 return result; 57}]])], 58 [gl_cv_func_printf_sizes_c99=yes], 59 [gl_cv_func_printf_sizes_c99=no], 60 [ 61 case "$host_os" in 62changequote(,)dnl 63 # Guess yes on glibc systems. 64 *-gnu* | gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; 65 # Guess yes on FreeBSD >= 5. 66 freebsd[1-4].*) gl_cv_func_printf_sizes_c99="guessing no";; 67 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; 68 # Guess yes on Mac OS X >= 10.3. 69 darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";; 70 darwin*) gl_cv_func_printf_sizes_c99="guessing yes";; 71 # Guess yes on OpenBSD >= 3.9. 72 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) 73 gl_cv_func_printf_sizes_c99="guessing no";; 74 openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; 75 # Guess yes on Solaris >= 2.10. 76 solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";; 77 solaris*) gl_cv_func_printf_sizes_c99="guessing no";; 78 # Guess yes on NetBSD >= 3. 79 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 80 gl_cv_func_printf_sizes_c99="guessing no";; 81 netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; 82changequote([,])dnl 83 # Guess yes on MSVC, no on mingw. 84 mingw*) AC_EGREP_CPP([Known], [ 85#ifdef _MSC_VER 86 Known 87#endif 88 ], 89 [gl_cv_func_printf_sizes_c99="guessing yes"], 90 [gl_cv_func_printf_sizes_c99="guessing no"]) 91 ;; 92 # If we don't know, assume the worst. 93 *) gl_cv_func_printf_sizes_c99="guessing no";; 94 esac 95 ]) 96 ]) 97]) 98 99dnl Test whether the *printf family of functions supports 'long double' 100dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001) 101dnl Result is gl_cv_func_printf_long_double. 102 103AC_DEFUN([gl_PRINTF_LONG_DOUBLE], 104[ 105 AC_REQUIRE([AC_PROG_CC]) 106 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 107 AC_CACHE_CHECK([whether printf supports 'long double' arguments], 108 [gl_cv_func_printf_long_double], 109 [ 110 AC_RUN_IFELSE( 111 [AC_LANG_SOURCE([[ 112#include <stdio.h> 113#include <string.h> 114static char buf[10000]; 115int main () 116{ 117 int result = 0; 118 buf[0] = '\0'; 119 if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0 120 || strcmp (buf, "1.750000 33") != 0) 121 result |= 1; 122 buf[0] = '\0'; 123 if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0 124 || strcmp (buf, "1.750000e+00 33") != 0) 125 result |= 2; 126 buf[0] = '\0'; 127 if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0 128 || strcmp (buf, "1.75 33") != 0) 129 result |= 4; 130 return result; 131}]])], 132 [gl_cv_func_printf_long_double=yes], 133 [gl_cv_func_printf_long_double=no], 134 [case "$host_os" in 135 beos*) gl_cv_func_printf_long_double="guessing no";; 136 # Guess yes on MSVC, no on mingw. 137 mingw*) AC_EGREP_CPP([Known], [ 138#ifdef _MSC_VER 139 Known 140#endif 141 ], 142 [gl_cv_func_printf_long_double="guessing yes"], 143 [gl_cv_func_printf_long_double="guessing no"]) 144 ;; 145 *) gl_cv_func_printf_long_double="guessing yes";; 146 esac 147 ]) 148 ]) 149]) 150 151dnl Test whether the *printf family of functions supports infinite and NaN 152dnl 'double' arguments and negative zero arguments in the %f, %e, %g 153dnl directives. (ISO C99, POSIX:2001) 154dnl Result is gl_cv_func_printf_infinite. 155 156AC_DEFUN([gl_PRINTF_INFINITE], 157[ 158 AC_REQUIRE([AC_PROG_CC]) 159 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 160 AC_CACHE_CHECK([whether printf supports infinite 'double' arguments], 161 [gl_cv_func_printf_infinite], 162 [ 163 AC_RUN_IFELSE( 164 [AC_LANG_SOURCE([[ 165#include <stdio.h> 166#include <string.h> 167static int 168strisnan (const char *string, size_t start_index, size_t end_index) 169{ 170 if (start_index < end_index) 171 { 172 if (string[start_index] == '-') 173 start_index++; 174 if (start_index + 3 <= end_index 175 && memcmp (string + start_index, "nan", 3) == 0) 176 { 177 start_index += 3; 178 if (start_index == end_index 179 || (string[start_index] == '(' && string[end_index - 1] == ')')) 180 return 1; 181 } 182 } 183 return 0; 184} 185static int 186have_minus_zero () 187{ 188 static double plus_zero = 0.0; 189 double minus_zero = - plus_zero; 190 return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; 191} 192static char buf[10000]; 193static double zero = 0.0; 194int main () 195{ 196 int result = 0; 197 if (sprintf (buf, "%f", 1.0 / zero) < 0 198 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) 199 result |= 1; 200 if (sprintf (buf, "%f", -1.0 / zero) < 0 201 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) 202 result |= 1; 203 if (sprintf (buf, "%f", zero / zero) < 0 204 || !strisnan (buf, 0, strlen (buf))) 205 result |= 2; 206 if (sprintf (buf, "%e", 1.0 / zero) < 0 207 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) 208 result |= 4; 209 if (sprintf (buf, "%e", -1.0 / zero) < 0 210 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) 211 result |= 4; 212 if (sprintf (buf, "%e", zero / zero) < 0 213 || !strisnan (buf, 0, strlen (buf))) 214 result |= 8; 215 if (sprintf (buf, "%g", 1.0 / zero) < 0 216 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) 217 result |= 16; 218 if (sprintf (buf, "%g", -1.0 / zero) < 0 219 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) 220 result |= 16; 221 if (sprintf (buf, "%g", zero / zero) < 0 222 || !strisnan (buf, 0, strlen (buf))) 223 result |= 32; 224 /* This test fails on HP-UX 10.20. */ 225 if (have_minus_zero ()) 226 if (sprintf (buf, "%g", - zero) < 0 227 || strcmp (buf, "-0") != 0) 228 result |= 64; 229 return result; 230}]])], 231 [gl_cv_func_printf_infinite=yes], 232 [gl_cv_func_printf_infinite=no], 233 [ 234 case "$host_os" in 235changequote(,)dnl 236 # Guess yes on glibc systems. 237 *-gnu* | gnu*) gl_cv_func_printf_infinite="guessing yes";; 238 # Guess yes on FreeBSD >= 6. 239 freebsd[1-5].*) gl_cv_func_printf_infinite="guessing no";; 240 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; 241 # Guess yes on Mac OS X >= 10.3. 242 darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";; 243 darwin*) gl_cv_func_printf_infinite="guessing yes";; 244 # Guess yes on HP-UX >= 11. 245 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";; 246 hpux*) gl_cv_func_printf_infinite="guessing yes";; 247 # Guess yes on NetBSD >= 3. 248 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 249 gl_cv_func_printf_infinite="guessing no";; 250 netbsd*) gl_cv_func_printf_infinite="guessing yes";; 251 # Guess yes on BeOS. 252 beos*) gl_cv_func_printf_infinite="guessing yes";; 253changequote([,])dnl 254 # Guess yes on MSVC, no on mingw. 255 mingw*) AC_EGREP_CPP([Known], [ 256#ifdef _MSC_VER 257 Known 258#endif 259 ], 260 [gl_cv_func_printf_infinite="guessing yes"], 261 [gl_cv_func_printf_infinite="guessing no"]) 262 ;; 263 # If we don't know, assume the worst. 264 *) gl_cv_func_printf_infinite="guessing no";; 265 esac 266 ]) 267 ]) 268]) 269 270dnl Test whether the *printf family of functions supports infinite and NaN 271dnl 'long double' arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001) 272dnl Result is gl_cv_func_printf_infinite_long_double. 273 274AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE], 275[ 276 AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) 277 AC_REQUIRE([AC_PROG_CC]) 278 AC_REQUIRE([gl_BIGENDIAN]) 279 AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) 280 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 281 dnl The user can set or unset the variable gl_printf_safe to indicate 282 dnl that he wishes a safe handling of non-IEEE-754 'long double' values. 283 if test -n "$gl_printf_safe"; then 284 AC_DEFINE([CHECK_PRINTF_SAFE], [1], 285 [Define if you wish *printf() functions that have a safe handling of 286 non-IEEE-754 'long double' values.]) 287 fi 288 case "$gl_cv_func_printf_long_double" in 289 *yes) 290 AC_CACHE_CHECK([whether printf supports infinite 'long double' arguments], 291 [gl_cv_func_printf_infinite_long_double], 292 [ 293 AC_RUN_IFELSE( 294 [AC_LANG_SOURCE([[ 295]GL_NOCRASH[ 296#include <float.h> 297#include <stdio.h> 298#include <string.h> 299static int 300strisnan (const char *string, size_t start_index, size_t end_index) 301{ 302 if (start_index < end_index) 303 { 304 if (string[start_index] == '-') 305 start_index++; 306 if (start_index + 3 <= end_index 307 && memcmp (string + start_index, "nan", 3) == 0) 308 { 309 start_index += 3; 310 if (start_index == end_index 311 || (string[start_index] == '(' && string[end_index - 1] == ')')) 312 return 1; 313 } 314 } 315 return 0; 316} 317static char buf[10000]; 318static long double zeroL = 0.0L; 319int main () 320{ 321 int result = 0; 322 nocrash_init(); 323 if (sprintf (buf, "%Lf", 1.0L / zeroL) < 0 324 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) 325 result |= 1; 326 if (sprintf (buf, "%Lf", -1.0L / zeroL) < 0 327 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) 328 result |= 1; 329 if (sprintf (buf, "%Lf", zeroL / zeroL) < 0 330 || !strisnan (buf, 0, strlen (buf))) 331 result |= 1; 332 if (sprintf (buf, "%Le", 1.0L / zeroL) < 0 333 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) 334 result |= 1; 335 if (sprintf (buf, "%Le", -1.0L / zeroL) < 0 336 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) 337 result |= 1; 338 if (sprintf (buf, "%Le", zeroL / zeroL) < 0 339 || !strisnan (buf, 0, strlen (buf))) 340 result |= 1; 341 if (sprintf (buf, "%Lg", 1.0L / zeroL) < 0 342 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) 343 result |= 1; 344 if (sprintf (buf, "%Lg", -1.0L / zeroL) < 0 345 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) 346 result |= 1; 347 if (sprintf (buf, "%Lg", zeroL / zeroL) < 0 348 || !strisnan (buf, 0, strlen (buf))) 349 result |= 1; 350#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_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE 351/* Representation of an 80-bit 'long double' as an initializer for a sequence 352 of 'unsigned int' words. */ 353# ifdef WORDS_BIGENDIAN 354# define LDBL80_WORDS(exponent,manthi,mantlo) \ 355 { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ 356 ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \ 357 (unsigned int) (mantlo) << 16 \ 358 } 359# else 360# define LDBL80_WORDS(exponent,manthi,mantlo) \ 361 { mantlo, manthi, exponent } 362# endif 363 { /* Quiet NaN. */ 364 static union { unsigned int word[4]; long double value; } x = 365 { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; 366 if (sprintf (buf, "%Lf", x.value) < 0 367 || !strisnan (buf, 0, strlen (buf))) 368 result |= 2; 369 if (sprintf (buf, "%Le", x.value) < 0 370 || !strisnan (buf, 0, strlen (buf))) 371 result |= 2; 372 if (sprintf (buf, "%Lg", x.value) < 0 373 || !strisnan (buf, 0, strlen (buf))) 374 result |= 2; 375 } 376 { 377 /* Signalling NaN. */ 378 static union { unsigned int word[4]; long double value; } x = 379 { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; 380 if (sprintf (buf, "%Lf", x.value) < 0 381 || !strisnan (buf, 0, strlen (buf))) 382 result |= 2; 383 if (sprintf (buf, "%Le", x.value) < 0 384 || !strisnan (buf, 0, strlen (buf))) 385 result |= 2; 386 if (sprintf (buf, "%Lg", x.value) < 0 387 || !strisnan (buf, 0, strlen (buf))) 388 result |= 2; 389 } 390 { /* Pseudo-NaN. */ 391 static union { unsigned int word[4]; long double value; } x = 392 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; 393 if (sprintf (buf, "%Lf", x.value) <= 0) 394 result |= 4; 395 if (sprintf (buf, "%Le", x.value) <= 0) 396 result |= 4; 397 if (sprintf (buf, "%Lg", x.value) <= 0) 398 result |= 4; 399 } 400 { /* Pseudo-Infinity. */ 401 static union { unsigned int word[4]; long double value; } x = 402 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; 403 if (sprintf (buf, "%Lf", x.value) <= 0) 404 result |= 8; 405 if (sprintf (buf, "%Le", x.value) <= 0) 406 result |= 8; 407 if (sprintf (buf, "%Lg", x.value) <= 0) 408 result |= 8; 409 } 410 { /* Pseudo-Zero. */ 411 static union { unsigned int word[4]; long double value; } x = 412 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; 413 if (sprintf (buf, "%Lf", x.value) <= 0) 414 result |= 16; 415 if (sprintf (buf, "%Le", x.value) <= 0) 416 result |= 16; 417 if (sprintf (buf, "%Lg", x.value) <= 0) 418 result |= 16; 419 } 420 { /* Unnormalized number. */ 421 static union { unsigned int word[4]; long double value; } x = 422 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; 423 if (sprintf (buf, "%Lf", x.value) <= 0) 424 result |= 32; 425 if (sprintf (buf, "%Le", x.value) <= 0) 426 result |= 32; 427 if (sprintf (buf, "%Lg", x.value) <= 0) 428 result |= 32; 429 } 430 { /* Pseudo-Denormal. */ 431 static union { unsigned int word[4]; long double value; } x = 432 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; 433 if (sprintf (buf, "%Lf", x.value) <= 0) 434 result |= 64; 435 if (sprintf (buf, "%Le", x.value) <= 0) 436 result |= 64; 437 if (sprintf (buf, "%Lg", x.value) <= 0) 438 result |= 64; 439 } 440#endif 441 return result; 442}]])], 443 [gl_cv_func_printf_infinite_long_double=yes], 444 [gl_cv_func_printf_infinite_long_double=no], 445 [case "$host_cpu" in 446 # Guess no on ia64, x86_64, i386. 447 ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";; 448 *) 449 case "$host_os" in 450changequote(,)dnl 451 # Guess yes on glibc systems. 452 *-gnu* | gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; 453 # Guess yes on FreeBSD >= 6. 454 freebsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";; 455 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; 456 # Guess yes on HP-UX >= 11. 457 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; 458 hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; 459changequote([,])dnl 460 # Guess yes on MSVC, no on mingw. 461 mingw*) AC_EGREP_CPP([Known], [ 462#ifdef _MSC_VER 463 Known 464#endif 465 ], 466 [gl_cv_func_printf_infinite_long_double="guessing yes"], 467 [gl_cv_func_printf_infinite_long_double="guessing no"]) 468 ;; 469 # If we don't know, assume the worst. 470 *) gl_cv_func_printf_infinite_long_double="guessing no";; 471 esac 472 ;; 473 esac 474 ]) 475 ]) 476 ;; 477 *) 478 gl_cv_func_printf_infinite_long_double="irrelevant" 479 ;; 480 esac 481]) 482 483dnl Test whether the *printf family of functions supports the 'a' and 'A' 484dnl conversion specifier for hexadecimal output of floating-point numbers. 485dnl (ISO C99, POSIX:2001) 486dnl Result is gl_cv_func_printf_directive_a. 487 488AC_DEFUN([gl_PRINTF_DIRECTIVE_A], 489[ 490 AC_REQUIRE([AC_PROG_CC]) 491 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 492 AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives], 493 [gl_cv_func_printf_directive_a], 494 [ 495 AC_RUN_IFELSE( 496 [AC_LANG_SOURCE([[ 497#include <stdio.h> 498#include <string.h> 499static char buf[100]; 500static double zero = 0.0; 501int main () 502{ 503 int result = 0; 504 if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0 505 || (strcmp (buf, "0x1.922p+1 33") != 0 506 && strcmp (buf, "0x3.244p+0 33") != 0 507 && strcmp (buf, "0x6.488p-1 33") != 0 508 && strcmp (buf, "0xc.91p-2 33") != 0)) 509 result |= 1; 510 if (sprintf (buf, "%A %d", -3.1416015625, 33, 44, 55) < 0 511 || (strcmp (buf, "-0X1.922P+1 33") != 0 512 && strcmp (buf, "-0X3.244P+0 33") != 0 513 && strcmp (buf, "-0X6.488P-1 33") != 0 514 && strcmp (buf, "-0XC.91P-2 33") != 0)) 515 result |= 2; 516 /* This catches a FreeBSD 6.1 bug: it doesn't round. */ 517 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0 518 || (strcmp (buf, "0x1.83p+0 33") != 0 519 && strcmp (buf, "0x3.05p-1 33") != 0 520 && strcmp (buf, "0x6.0ap-2 33") != 0 521 && strcmp (buf, "0xc.14p-3 33") != 0)) 522 result |= 4; 523 /* This catches a Mac OS X 10.12.4 (Darwin 16.5) bug: it doesn't round. */ 524 if (sprintf (buf, "%.0a %d", 1.51, 33, 44, 55) < 0 525 || (strcmp (buf, "0x2p+0 33") != 0 526 && strcmp (buf, "0x3p-1 33") != 0 527 && strcmp (buf, "0x6p-2 33") != 0 528 && strcmp (buf, "0xcp-3 33") != 0)) 529 result |= 4; 530 /* This catches a FreeBSD 6.1 bug. See 531 <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html> */ 532 if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0 533 || buf[0] == '0') 534 result |= 8; 535 /* This catches a Mac OS X 10.3.9 (Darwin 7.9) bug. */ 536 if (sprintf (buf, "%.1a", 1.999) < 0 537 || (strcmp (buf, "0x1.0p+1") != 0 538 && strcmp (buf, "0x2.0p+0") != 0 539 && strcmp (buf, "0x4.0p-1") != 0 540 && strcmp (buf, "0x8.0p-2") != 0)) 541 result |= 16; 542 /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a 543 glibc 2.4 bug <https://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */ 544 if (sprintf (buf, "%.1La", 1.999L) < 0 545 || (strcmp (buf, "0x1.0p+1") != 0 546 && strcmp (buf, "0x2.0p+0") != 0 547 && strcmp (buf, "0x4.0p-1") != 0 548 && strcmp (buf, "0x8.0p-2") != 0)) 549 result |= 32; 550 return result; 551}]])], 552 [gl_cv_func_printf_directive_a=yes], 553 [gl_cv_func_printf_directive_a=no], 554 [ 555 case "$host_os" in 556 # Guess yes on glibc >= 2.5 systems. 557 *-gnu* | gnu*) 558 AC_EGREP_CPP([BZ2908], [ 559 #include <features.h> 560 #ifdef __GNU_LIBRARY__ 561 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2)) && !defined __UCLIBC__ 562 BZ2908 563 #endif 564 #endif 565 ], 566 [gl_cv_func_printf_directive_a="guessing yes"], 567 [gl_cv_func_printf_directive_a="guessing no"]) 568 ;; 569 # Guess no on native Windows. 570 mingw*) gl_cv_func_printf_directive_a="guessing no";; 571 # If we don't know, assume the worst. 572 *) gl_cv_func_printf_directive_a="guessing no";; 573 esac 574 ]) 575 ]) 576]) 577 578dnl Test whether the *printf family of functions supports the %F format 579dnl directive. (ISO C99, POSIX:2001) 580dnl Result is gl_cv_func_printf_directive_f. 581 582AC_DEFUN([gl_PRINTF_DIRECTIVE_F], 583[ 584 AC_REQUIRE([AC_PROG_CC]) 585 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 586 AC_CACHE_CHECK([whether printf supports the 'F' directive], 587 [gl_cv_func_printf_directive_f], 588 [ 589 AC_RUN_IFELSE( 590 [AC_LANG_SOURCE([[ 591#include <stdio.h> 592#include <string.h> 593static char buf[100]; 594static double zero = 0.0; 595int main () 596{ 597 int result = 0; 598 if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0 599 || strcmp (buf, "1234567.000000 33") != 0) 600 result |= 1; 601 if (sprintf (buf, "%F", 1.0 / zero) < 0 602 || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0)) 603 result |= 2; 604 /* This catches a Cygwin 1.5.x bug. */ 605 if (sprintf (buf, "%.F", 1234.0) < 0 606 || strcmp (buf, "1234") != 0) 607 result |= 4; 608 return result; 609}]])], 610 [gl_cv_func_printf_directive_f=yes], 611 [gl_cv_func_printf_directive_f=no], 612 [ 613 case "$host_os" in 614changequote(,)dnl 615 # Guess yes on glibc systems. 616 *-gnu* | gnu*) gl_cv_func_printf_directive_f="guessing yes";; 617 # Guess yes on FreeBSD >= 6. 618 freebsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";; 619 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; 620 # Guess yes on Mac OS X >= 10.3. 621 darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";; 622 darwin*) gl_cv_func_printf_directive_f="guessing yes";; 623 # Guess yes on Solaris >= 2.10. 624 solaris2.[1-9][0-9]*) gl_cv_func_printf_directive_f="guessing yes";; 625 solaris*) gl_cv_func_printf_directive_f="guessing no";; 626changequote([,])dnl 627 # Guess yes on MSVC, no on mingw. 628 mingw*) AC_EGREP_CPP([Known], [ 629#ifdef _MSC_VER 630 Known 631#endif 632 ], 633 [gl_cv_func_printf_directive_f="guessing yes"], 634 [gl_cv_func_printf_directive_f="guessing no"]) 635 ;; 636 # If we don't know, assume the worst. 637 *) gl_cv_func_printf_directive_f="guessing no";; 638 esac 639 ]) 640 ]) 641]) 642 643dnl Test whether the *printf family of functions supports the %n format 644dnl directive. (ISO C99, POSIX:2001) 645dnl Result is gl_cv_func_printf_directive_n. 646 647AC_DEFUN([gl_PRINTF_DIRECTIVE_N], 648[ 649 AC_REQUIRE([AC_PROG_CC]) 650 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 651 AC_CACHE_CHECK([whether printf supports the 'n' directive], 652 [gl_cv_func_printf_directive_n], 653 [ 654 AC_RUN_IFELSE( 655 [AC_LANG_SOURCE([[ 656#include <stdio.h> 657#include <stdlib.h> 658#include <string.h> 659#ifdef _MSC_VER 660/* See page about "Parameter Validation" on msdn.microsoft.com. */ 661static void cdecl 662invalid_parameter_handler (const wchar_t *expression, 663 const wchar_t *function, 664 const wchar_t *file, unsigned int line, 665 uintptr_t dummy) 666{ 667 exit (1); 668} 669#endif 670static char fmtstring[10]; 671static char buf[100]; 672int main () 673{ 674 int count = -1; 675#ifdef _MSC_VER 676 _set_invalid_parameter_handler (invalid_parameter_handler); 677#endif 678 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) 679 support %n in format strings in read-only memory but not in writable 680 memory. */ 681 strcpy (fmtstring, "%d %n"); 682 if (sprintf (buf, fmtstring, 123, &count, 33, 44, 55) < 0 683 || strcmp (buf, "123 ") != 0 684 || count != 4) 685 return 1; 686 return 0; 687}]])], 688 [gl_cv_func_printf_directive_n=yes], 689 [gl_cv_func_printf_directive_n=no], 690 [case "$host_os" in 691 # Guess no on native Windows. 692 mingw*) gl_cv_func_printf_directive_n="guessing no";; 693 *) gl_cv_func_printf_directive_n="guessing yes";; 694 esac 695 ]) 696 ]) 697]) 698 699dnl Test whether the *printf family of functions supports the %ls format 700dnl directive and in particular, when a precision is specified, whether 701dnl the functions stop converting the wide string argument when the number 702dnl of bytes that have been produced by this conversion equals or exceeds 703dnl the precision. 704dnl Result is gl_cv_func_printf_directive_ls. 705 706AC_DEFUN([gl_PRINTF_DIRECTIVE_LS], 707[ 708 AC_REQUIRE([AC_PROG_CC]) 709 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 710 AC_CACHE_CHECK([whether printf supports the 'ls' directive], 711 [gl_cv_func_printf_directive_ls], 712 [ 713 AC_RUN_IFELSE( 714 [AC_LANG_SOURCE([[ 715/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 716 <wchar.h>. 717 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be 718 included before <wchar.h>. */ 719#include <stddef.h> 720#include <stdio.h> 721#include <time.h> 722#include <wchar.h> 723#include <string.h> 724int main () 725{ 726 int result = 0; 727 char buf[100]; 728 /* Test whether %ls works at all. 729 This test fails on OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku, but not on 730 Cygwin 1.5. */ 731 { 732 static const wchar_t wstring[] = { 'a', 'b', 'c', 0 }; 733 buf[0] = '\0'; 734 if (sprintf (buf, "%ls", wstring) < 0 735 || strcmp (buf, "abc") != 0) 736 result |= 1; 737 } 738 /* This test fails on IRIX 6.5, Solaris 2.6, Cygwin 1.5, Haiku (with an 739 assertion failure inside libc), but not on OpenBSD 4.0. */ 740 { 741 static const wchar_t wstring[] = { 'a', 0 }; 742 buf[0] = '\0'; 743 if (sprintf (buf, "%ls", wstring) < 0 744 || strcmp (buf, "a") != 0) 745 result |= 2; 746 } 747 /* Test whether precisions in %ls are supported as specified in ISO C 99 748 section 7.19.6.1: 749 "If a precision is specified, no more than that many bytes are written 750 (including shift sequences, if any), and the array shall contain a 751 null wide character if, to equal the multibyte character sequence 752 length given by the precision, the function would need to access a 753 wide character one past the end of the array." 754 This test fails on Solaris 10. */ 755 { 756 static const wchar_t wstring[] = { 'a', 'b', (wchar_t) 0xfdfdfdfd, 0 }; 757 buf[0] = '\0'; 758 if (sprintf (buf, "%.2ls", wstring) < 0 759 || strcmp (buf, "ab") != 0) 760 result |= 8; 761 } 762 return result; 763}]])], 764 [gl_cv_func_printf_directive_ls=yes], 765 [gl_cv_func_printf_directive_ls=no], 766 [ 767changequote(,)dnl 768 case "$host_os" in 769 openbsd*) gl_cv_func_printf_directive_ls="guessing no";; 770 irix*) gl_cv_func_printf_directive_ls="guessing no";; 771 solaris*) gl_cv_func_printf_directive_ls="guessing no";; 772 cygwin*) gl_cv_func_printf_directive_ls="guessing no";; 773 beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; 774 # Guess yes on native Windows. 775 mingw*) gl_cv_func_printf_directive_ls="guessing yes";; 776 *) gl_cv_func_printf_directive_ls="guessing yes";; 777 esac 778changequote([,])dnl 779 ]) 780 ]) 781]) 782 783dnl Test whether the *printf family of functions supports POSIX/XSI format 784dnl strings with positions. (POSIX:2001) 785dnl Result is gl_cv_func_printf_positions. 786 787AC_DEFUN([gl_PRINTF_POSITIONS], 788[ 789 AC_REQUIRE([AC_PROG_CC]) 790 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 791 AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions], 792 [gl_cv_func_printf_positions], 793 [ 794 AC_RUN_IFELSE( 795 [AC_LANG_SOURCE([[ 796#include <stdio.h> 797#include <string.h> 798/* The string "%2$d %1$d", with dollar characters protected from the shell's 799 dollar expansion (possibly an autoconf bug). */ 800static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; 801static char buf[100]; 802int main () 803{ 804 sprintf (buf, format, 33, 55); 805 return (strcmp (buf, "55 33") != 0); 806}]])], 807 [gl_cv_func_printf_positions=yes], 808 [gl_cv_func_printf_positions=no], 809 [ 810changequote(,)dnl 811 case "$host_os" in 812 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) 813 gl_cv_func_printf_positions="guessing no";; 814 beos*) gl_cv_func_printf_positions="guessing no";; 815 # Guess no on native Windows. 816 mingw* | pw*) gl_cv_func_printf_positions="guessing no";; 817 *) gl_cv_func_printf_positions="guessing yes";; 818 esac 819changequote([,])dnl 820 ]) 821 ]) 822]) 823 824dnl Test whether the *printf family of functions supports POSIX/XSI format 825dnl strings with the ' flag for grouping of decimal digits. (POSIX:2001) 826dnl Result is gl_cv_func_printf_flag_grouping. 827 828AC_DEFUN([gl_PRINTF_FLAG_GROUPING], 829[ 830 AC_REQUIRE([AC_PROG_CC]) 831 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 832 AC_CACHE_CHECK([whether printf supports the grouping flag], 833 [gl_cv_func_printf_flag_grouping], 834 [ 835 AC_RUN_IFELSE( 836 [AC_LANG_SOURCE([[ 837#include <stdio.h> 838#include <string.h> 839static char buf[100]; 840int main () 841{ 842 if (sprintf (buf, "%'d %d", 1234567, 99) < 0 843 || buf[strlen (buf) - 1] != '9') 844 return 1; 845 return 0; 846}]])], 847 [gl_cv_func_printf_flag_grouping=yes], 848 [gl_cv_func_printf_flag_grouping=no], 849 [ 850changequote(,)dnl 851 case "$host_os" in 852 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; 853 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; 854 # Guess no on native Windows. 855 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; 856 *) gl_cv_func_printf_flag_grouping="guessing yes";; 857 esac 858changequote([,])dnl 859 ]) 860 ]) 861]) 862 863dnl Test whether the *printf family of functions supports the - flag correctly. 864dnl (ISO C99.) See 865dnl <https://lists.gnu.org/r/bug-coreutils/2008-02/msg00035.html> 866dnl Result is gl_cv_func_printf_flag_leftadjust. 867 868AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST], 869[ 870 AC_REQUIRE([AC_PROG_CC]) 871 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 872 AC_CACHE_CHECK([whether printf supports the left-adjust flag correctly], 873 [gl_cv_func_printf_flag_leftadjust], 874 [ 875 AC_RUN_IFELSE( 876 [AC_LANG_SOURCE([[ 877#include <stdio.h> 878#include <string.h> 879static char buf[100]; 880int main () 881{ 882 /* Check that a '-' flag is not annihilated by a negative width. */ 883 if (sprintf (buf, "a%-*sc", -3, "b") < 0 884 || strcmp (buf, "ab c") != 0) 885 return 1; 886 return 0; 887}]])], 888 [gl_cv_func_printf_flag_leftadjust=yes], 889 [gl_cv_func_printf_flag_leftadjust=no], 890 [ 891changequote(,)dnl 892 case "$host_os" in 893 # Guess yes on HP-UX 11. 894 hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";; 895 # Guess no on HP-UX 10 and older. 896 hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";; 897 # Guess yes on native Windows. 898 mingw*) gl_cv_func_printf_flag_leftadjust="guessing yes";; 899 # Guess yes otherwise. 900 *) gl_cv_func_printf_flag_leftadjust="guessing yes";; 901 esac 902changequote([,])dnl 903 ]) 904 ]) 905]) 906 907dnl Test whether the *printf family of functions supports padding of non-finite 908dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See 909dnl <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html> 910dnl Result is gl_cv_func_printf_flag_zero. 911 912AC_DEFUN([gl_PRINTF_FLAG_ZERO], 913[ 914 AC_REQUIRE([AC_PROG_CC]) 915 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 916 AC_CACHE_CHECK([whether printf supports the zero flag correctly], 917 [gl_cv_func_printf_flag_zero], 918 [ 919 AC_RUN_IFELSE( 920 [AC_LANG_SOURCE([[ 921#include <stdio.h> 922#include <string.h> 923static char buf[100]; 924static double zero = 0.0; 925int main () 926{ 927 if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0 928 || (strcmp (buf, " inf") != 0 929 && strcmp (buf, " infinity") != 0)) 930 return 1; 931 return 0; 932}]])], 933 [gl_cv_func_printf_flag_zero=yes], 934 [gl_cv_func_printf_flag_zero=no], 935 [ 936changequote(,)dnl 937 case "$host_os" in 938 # Guess yes on glibc systems. 939 *-gnu* | gnu*) gl_cv_func_printf_flag_zero="guessing yes";; 940 # Guess yes on BeOS. 941 beos*) gl_cv_func_printf_flag_zero="guessing yes";; 942 # Guess no on native Windows. 943 mingw*) gl_cv_func_printf_flag_zero="guessing no";; 944 # If we don't know, assume the worst. 945 *) gl_cv_func_printf_flag_zero="guessing no";; 946 esac 947changequote([,])dnl 948 ]) 949 ]) 950]) 951 952dnl Test whether the *printf family of functions supports large precisions. 953dnl On mingw, precisions larger than 512 are treated like 512, in integer, 954dnl floating-point or pointer output. On Solaris 10/x86, precisions larger 955dnl than 510 in floating-point output crash the program. On Solaris 10/SPARC, 956dnl precisions larger than 510 in floating-point output yield wrong results. 957dnl On AIX 7.1, precisions larger than 998 in floating-point output yield 958dnl wrong results. On BeOS, precisions larger than 1044 crash the program. 959dnl Result is gl_cv_func_printf_precision. 960 961AC_DEFUN([gl_PRINTF_PRECISION], 962[ 963 AC_REQUIRE([AC_PROG_CC]) 964 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 965 AC_CACHE_CHECK([whether printf supports large precisions], 966 [gl_cv_func_printf_precision], 967 [ 968 AC_RUN_IFELSE( 969 [AC_LANG_SOURCE([[ 970#include <stdio.h> 971#include <string.h> 972static char buf[5000]; 973int main () 974{ 975 int result = 0; 976#ifdef __BEOS__ 977 /* On BeOS, this would crash and show a dialog box. Avoid the crash. */ 978 return 1; 979#endif 980 if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3) 981 result |= 1; 982 if (sprintf (buf, "%.4000f %d", 1.0, 33, 44) < 4000 + 5) 983 result |= 2; 984 if (sprintf (buf, "%.511f %d", 1.0, 33, 44) < 511 + 5 985 || buf[0] != '1') 986 result |= 4; 987 if (sprintf (buf, "%.999f %d", 1.0, 33, 44) < 999 + 5 988 || buf[0] != '1') 989 result |= 4; 990 return result; 991}]])], 992 [gl_cv_func_printf_precision=yes], 993 [gl_cv_func_printf_precision=no], 994 [ 995changequote(,)dnl 996 case "$host_os" in 997 # Guess no only on Solaris, native Windows, and BeOS systems. 998 solaris*) gl_cv_func_printf_precision="guessing no" ;; 999 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; 1000 beos*) gl_cv_func_printf_precision="guessing no" ;; 1001 *) gl_cv_func_printf_precision="guessing yes" ;; 1002 esac 1003changequote([,])dnl 1004 ]) 1005 ]) 1006]) 1007 1008dnl Test whether the *printf family of functions recovers gracefully in case 1009dnl of an out-of-memory condition, or whether it crashes the entire program. 1010dnl Result is gl_cv_func_printf_enomem. 1011 1012AC_DEFUN([gl_PRINTF_ENOMEM], 1013[ 1014 AC_REQUIRE([AC_PROG_CC]) 1015 AC_REQUIRE([gl_MULTIARCH]) 1016 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1017 AC_CACHE_CHECK([whether printf survives out-of-memory conditions], 1018 [gl_cv_func_printf_enomem], 1019 [ 1020 gl_cv_func_printf_enomem="guessing no" 1021 if test "$cross_compiling" = no; then 1022 if test $APPLE_UNIVERSAL_BUILD = 0; then 1023 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 1024]GL_NOCRASH[ 1025changequote(,)dnl 1026#include <stdio.h> 1027#include <sys/types.h> 1028#include <sys/time.h> 1029#include <sys/resource.h> 1030#include <errno.h> 1031int main() 1032{ 1033 struct rlimit limit; 1034 int ret; 1035 nocrash_init (); 1036 /* Some printf implementations allocate temporary space with malloc. */ 1037 /* On BSD systems, malloc() is limited by RLIMIT_DATA. */ 1038#ifdef RLIMIT_DATA 1039 if (getrlimit (RLIMIT_DATA, &limit) < 0) 1040 return 77; 1041 if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) 1042 limit.rlim_max = 5000000; 1043 limit.rlim_cur = limit.rlim_max; 1044 if (setrlimit (RLIMIT_DATA, &limit) < 0) 1045 return 77; 1046#endif 1047 /* On Linux systems, malloc() is limited by RLIMIT_AS. */ 1048#ifdef RLIMIT_AS 1049 if (getrlimit (RLIMIT_AS, &limit) < 0) 1050 return 77; 1051 if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) 1052 limit.rlim_max = 5000000; 1053 limit.rlim_cur = limit.rlim_max; 1054 if (setrlimit (RLIMIT_AS, &limit) < 0) 1055 return 77; 1056#endif 1057 /* Some printf implementations allocate temporary space on the stack. */ 1058#ifdef RLIMIT_STACK 1059 if (getrlimit (RLIMIT_STACK, &limit) < 0) 1060 return 77; 1061 if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) 1062 limit.rlim_max = 5000000; 1063 limit.rlim_cur = limit.rlim_max; 1064 if (setrlimit (RLIMIT_STACK, &limit) < 0) 1065 return 77; 1066#endif 1067 ret = printf ("%.5000000f", 1.0); 1068 return !(ret == 5000002 || (ret < 0 && errno == ENOMEM)); 1069} 1070changequote([,])dnl 1071 ])]) 1072 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 1073 (./conftest 2>&AS_MESSAGE_LOG_FD 1074 result=$? 1075 _AS_ECHO_LOG([\$? = $result]) 1076 if test $result != 0 && test $result != 77; then result=1; fi 1077 exit $result 1078 ) >/dev/null 2>/dev/null 1079 case $? in 1080 0) gl_cv_func_printf_enomem="yes" ;; 1081 77) gl_cv_func_printf_enomem="guessing no" ;; 1082 *) gl_cv_func_printf_enomem="no" ;; 1083 esac 1084 else 1085 gl_cv_func_printf_enomem="guessing no" 1086 fi 1087 rm -fr conftest* 1088 else 1089 dnl A universal build on Apple Mac OS X platforms. 1090 dnl The result would be 'no' in 32-bit mode and 'yes' in 64-bit mode. 1091 dnl But we need a configuration result that is valid in both modes. 1092 gl_cv_func_printf_enomem="guessing no" 1093 fi 1094 fi 1095 if test "$gl_cv_func_printf_enomem" = "guessing no"; then 1096changequote(,)dnl 1097 case "$host_os" in 1098 # Guess yes on glibc systems. 1099 *-gnu* | gnu*) gl_cv_func_printf_enomem="guessing yes";; 1100 # Guess yes on Solaris. 1101 solaris*) gl_cv_func_printf_enomem="guessing yes";; 1102 # Guess yes on AIX. 1103 aix*) gl_cv_func_printf_enomem="guessing yes";; 1104 # Guess yes on HP-UX/hppa. 1105 hpux*) case "$host_cpu" in 1106 hppa*) gl_cv_func_printf_enomem="guessing yes";; 1107 *) gl_cv_func_printf_enomem="guessing no";; 1108 esac 1109 ;; 1110 # Guess yes on IRIX. 1111 irix*) gl_cv_func_printf_enomem="guessing yes";; 1112 # Guess yes on OSF/1. 1113 osf*) gl_cv_func_printf_enomem="guessing yes";; 1114 # Guess yes on BeOS. 1115 beos*) gl_cv_func_printf_enomem="guessing yes";; 1116 # Guess yes on Haiku. 1117 haiku*) gl_cv_func_printf_enomem="guessing yes";; 1118 # If we don't know, assume the worst. 1119 *) gl_cv_func_printf_enomem="guessing no";; 1120 esac 1121changequote([,])dnl 1122 fi 1123 ]) 1124]) 1125 1126dnl Test whether the snprintf function exists. (ISO C99, POSIX:2001) 1127dnl Result is ac_cv_func_snprintf. 1128 1129AC_DEFUN([gl_SNPRINTF_PRESENCE], 1130[ 1131 AC_CHECK_FUNCS_ONCE([snprintf]) 1132]) 1133 1134dnl Test whether the string produced by the snprintf function is always NUL 1135dnl terminated. (ISO C99, POSIX:2001) 1136dnl Result is gl_cv_func_snprintf_truncation_c99. 1137 1138AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99], 1139[ 1140 AC_REQUIRE([AC_PROG_CC]) 1141 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1142 AC_REQUIRE([gl_SNPRINTF_PRESENCE]) 1143 AC_CACHE_CHECK([whether snprintf truncates the result as in C99], 1144 [gl_cv_func_snprintf_truncation_c99], 1145 [ 1146 AC_RUN_IFELSE( 1147 [AC_LANG_SOURCE([[ 1148#include <stdio.h> 1149#include <string.h> 1150#if HAVE_SNPRINTF 1151# define my_snprintf snprintf 1152#else 1153# include <stdarg.h> 1154static int my_snprintf (char *buf, int size, const char *format, ...) 1155{ 1156 va_list args; 1157 int ret; 1158 va_start (args, format); 1159 ret = vsnprintf (buf, size, format, args); 1160 va_end (args); 1161 return ret; 1162} 1163#endif 1164static char buf[100]; 1165int main () 1166{ 1167 strcpy (buf, "ABCDEF"); 1168 my_snprintf (buf, 3, "%d %d", 4567, 89); 1169 if (memcmp (buf, "45\0DEF", 6) != 0) 1170 return 1; 1171 return 0; 1172}]])], 1173 [gl_cv_func_snprintf_truncation_c99=yes], 1174 [gl_cv_func_snprintf_truncation_c99=no], 1175 [ 1176changequote(,)dnl 1177 case "$host_os" in 1178 # Guess yes on glibc systems. 1179 *-gnu* | gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1180 # Guess yes on FreeBSD >= 5. 1181 freebsd[1-4].*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1182 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1183 # Guess yes on Mac OS X >= 10.3. 1184 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1185 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1186 # Guess yes on OpenBSD >= 3.9. 1187 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) 1188 gl_cv_func_snprintf_truncation_c99="guessing no";; 1189 openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1190 # Guess yes on Solaris >= 2.6. 1191 solaris2.[0-5] | solaris2.[0-5].*) 1192 gl_cv_func_snprintf_truncation_c99="guessing no";; 1193 solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1194 # Guess yes on AIX >= 4. 1195 aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1196 aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1197 # Guess yes on HP-UX >= 11. 1198 hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1199 hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1200 # Guess yes on IRIX >= 6.5. 1201 irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1202 # Guess yes on OSF/1 >= 5. 1203 osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1204 osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1205 # Guess yes on NetBSD >= 3. 1206 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 1207 gl_cv_func_snprintf_truncation_c99="guessing no";; 1208 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1209 # Guess yes on BeOS. 1210 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1211 # Guess no on native Windows. 1212 mingw*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1213 # If we don't know, assume the worst. 1214 *) gl_cv_func_snprintf_truncation_c99="guessing no";; 1215 esac 1216changequote([,])dnl 1217 ]) 1218 ]) 1219]) 1220 1221dnl Test whether the return value of the snprintf function is the number 1222dnl of bytes (excluding the terminating NUL) that would have been produced 1223dnl if the buffer had been large enough. (ISO C99, POSIX:2001) 1224dnl For example, this test program fails on IRIX 6.5: 1225dnl --------------------------------------------------------------------- 1226dnl #include <stdio.h> 1227dnl int main() 1228dnl { 1229dnl static char buf[8]; 1230dnl int retval = snprintf (buf, 3, "%d", 12345); 1231dnl return retval >= 0 && retval < 3; 1232dnl } 1233dnl --------------------------------------------------------------------- 1234dnl Result is gl_cv_func_snprintf_retval_c99. 1235 1236AC_DEFUN_ONCE([gl_SNPRINTF_RETVAL_C99], 1237[ 1238 AC_REQUIRE([AC_PROG_CC]) 1239 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1240 AC_REQUIRE([gl_SNPRINTF_PRESENCE]) 1241 AC_CACHE_CHECK([whether snprintf returns a byte count as in C99], 1242 [gl_cv_func_snprintf_retval_c99], 1243 [ 1244 AC_RUN_IFELSE( 1245 [AC_LANG_SOURCE([[ 1246#include <stdio.h> 1247#include <string.h> 1248#if HAVE_SNPRINTF 1249# define my_snprintf snprintf 1250#else 1251# include <stdarg.h> 1252static int my_snprintf (char *buf, int size, const char *format, ...) 1253{ 1254 va_list args; 1255 int ret; 1256 va_start (args, format); 1257 ret = vsnprintf (buf, size, format, args); 1258 va_end (args); 1259 return ret; 1260} 1261#endif 1262static char buf[100]; 1263int main () 1264{ 1265 strcpy (buf, "ABCDEF"); 1266 if (my_snprintf (buf, 3, "%d %d", 4567, 89) != 7) 1267 return 1; 1268 if (my_snprintf (buf, 0, "%d %d", 4567, 89) != 7) 1269 return 2; 1270 if (my_snprintf (NULL, 0, "%d %d", 4567, 89) != 7) 1271 return 3; 1272 return 0; 1273}]])], 1274 [gl_cv_func_snprintf_retval_c99=yes], 1275 [gl_cv_func_snprintf_retval_c99=no], 1276 [case "$host_os" in 1277changequote(,)dnl 1278 # Guess yes on glibc systems. 1279 *-gnu* | gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1280 # Guess yes on FreeBSD >= 5. 1281 freebsd[1-4].*) gl_cv_func_snprintf_retval_c99="guessing no";; 1282 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1283 # Guess yes on Mac OS X >= 10.3. 1284 darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";; 1285 darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1286 # Guess yes on OpenBSD >= 3.9. 1287 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) 1288 gl_cv_func_snprintf_retval_c99="guessing no";; 1289 openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1290 # Guess yes on Solaris >= 2.10. 1291 solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";; 1292 solaris*) gl_cv_func_printf_sizes_c99="guessing no";; 1293 # Guess yes on AIX >= 4. 1294 aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";; 1295 aix*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1296 # Guess yes on NetBSD >= 3. 1297 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 1298 gl_cv_func_snprintf_retval_c99="guessing no";; 1299 netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1300 # Guess yes on BeOS. 1301 beos*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1302changequote([,])dnl 1303 # Guess yes on MSVC, no on mingw. 1304 mingw*) AC_EGREP_CPP([Known], [ 1305#ifdef _MSC_VER 1306 Known 1307#endif 1308 ], 1309 [gl_cv_func_snprintf_retval_c99="guessing yes"], 1310 [gl_cv_func_snprintf_retval_c99="guessing no"]) 1311 ;; 1312 # If we don't know, assume the worst. 1313 *) gl_cv_func_snprintf_retval_c99="guessing no";; 1314 esac 1315 ]) 1316 ]) 1317]) 1318 1319dnl Test whether the snprintf function supports the %n format directive 1320dnl also in truncated portions of the format string. (ISO C99, POSIX:2001) 1321dnl Result is gl_cv_func_snprintf_directive_n. 1322 1323AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N], 1324[ 1325 AC_REQUIRE([AC_PROG_CC]) 1326 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1327 AC_REQUIRE([gl_SNPRINTF_PRESENCE]) 1328 AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive], 1329 [gl_cv_func_snprintf_directive_n], 1330 [ 1331 AC_RUN_IFELSE( 1332 [AC_LANG_SOURCE([[ 1333#include <stdio.h> 1334#include <string.h> 1335#if HAVE_SNPRINTF 1336# define my_snprintf snprintf 1337#else 1338# include <stdarg.h> 1339static int my_snprintf (char *buf, int size, const char *format, ...) 1340{ 1341 va_list args; 1342 int ret; 1343 va_start (args, format); 1344 ret = vsnprintf (buf, size, format, args); 1345 va_end (args); 1346 return ret; 1347} 1348#endif 1349static char fmtstring[10]; 1350static char buf[100]; 1351int main () 1352{ 1353 int count = -1; 1354 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) 1355 support %n in format strings in read-only memory but not in writable 1356 memory. */ 1357 strcpy (fmtstring, "%d %n"); 1358 my_snprintf (buf, 4, fmtstring, 12345, &count, 33, 44, 55); 1359 if (count != 6) 1360 return 1; 1361 return 0; 1362}]])], 1363 [gl_cv_func_snprintf_directive_n=yes], 1364 [gl_cv_func_snprintf_directive_n=no], 1365 [ 1366changequote(,)dnl 1367 case "$host_os" in 1368 # Guess yes on glibc systems. 1369 *-gnu* | gnu*) gl_cv_func_snprintf_directive_n="guessing yes";; 1370 # Guess yes on FreeBSD >= 5. 1371 freebsd[1-4].*) gl_cv_func_snprintf_directive_n="guessing no";; 1372 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; 1373 # Guess yes on Mac OS X >= 10.3. 1374 darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";; 1375 darwin*) gl_cv_func_snprintf_directive_n="guessing yes";; 1376 # Guess yes on Solaris >= 2.6. 1377 solaris2.[0-5] | solaris2.[0-5].*) 1378 gl_cv_func_snprintf_directive_n="guessing no";; 1379 solaris*) gl_cv_func_snprintf_directive_n="guessing yes";; 1380 # Guess yes on AIX >= 4. 1381 aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";; 1382 aix*) gl_cv_func_snprintf_directive_n="guessing yes";; 1383 # Guess yes on IRIX >= 6.5. 1384 irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";; 1385 # Guess yes on OSF/1 >= 5. 1386 osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";; 1387 osf*) gl_cv_func_snprintf_directive_n="guessing yes";; 1388 # Guess yes on NetBSD >= 3. 1389 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 1390 gl_cv_func_snprintf_directive_n="guessing no";; 1391 netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";; 1392 # Guess yes on BeOS. 1393 beos*) gl_cv_func_snprintf_directive_n="guessing yes";; 1394 # Guess no on native Windows. 1395 mingw*) gl_cv_func_snprintf_directive_n="guessing no";; 1396 # If we don't know, assume the worst. 1397 *) gl_cv_func_snprintf_directive_n="guessing no";; 1398 esac 1399changequote([,])dnl 1400 ]) 1401 ]) 1402]) 1403 1404dnl Test whether the snprintf function, when passed a size = 1, writes any 1405dnl output without bounds in this case, behaving like sprintf. This is the 1406dnl case on Linux libc5. 1407dnl Result is gl_cv_func_snprintf_size1. 1408 1409AC_DEFUN([gl_SNPRINTF_SIZE1], 1410[ 1411 AC_REQUIRE([AC_PROG_CC]) 1412 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1413 AC_REQUIRE([gl_SNPRINTF_PRESENCE]) 1414 AC_CACHE_CHECK([whether snprintf respects a size of 1], 1415 [gl_cv_func_snprintf_size1], 1416 [ 1417 AC_RUN_IFELSE( 1418 [AC_LANG_SOURCE([[ 1419#include <stdio.h> 1420#if HAVE_SNPRINTF 1421# define my_snprintf snprintf 1422#else 1423# include <stdarg.h> 1424static int my_snprintf (char *buf, int size, const char *format, ...) 1425{ 1426 va_list args; 1427 int ret; 1428 va_start (args, format); 1429 ret = vsnprintf (buf, size, format, args); 1430 va_end (args); 1431 return ret; 1432} 1433#endif 1434int main() 1435{ 1436 static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; 1437 my_snprintf (buf, 1, "%d", 12345); 1438 return buf[1] != 'E'; 1439}]])], 1440 [gl_cv_func_snprintf_size1=yes], 1441 [gl_cv_func_snprintf_size1=no], 1442 [case "$host_os" in 1443 # Guess yes on native Windows. 1444 mingw*) gl_cv_func_snprintf_size1="guessing yes" ;; 1445 *) gl_cv_func_snprintf_size1="guessing yes" ;; 1446 esac 1447 ]) 1448 ]) 1449]) 1450 1451dnl Test whether the vsnprintf function, when passed a zero size, produces no 1452dnl output. (ISO C99, POSIX:2001) 1453dnl For example, snprintf nevertheless writes a NUL byte in this case 1454dnl on OSF/1 5.1: 1455dnl --------------------------------------------------------------------- 1456dnl #include <stdio.h> 1457dnl int main() 1458dnl { 1459dnl static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; 1460dnl snprintf (buf, 0, "%d", 12345); 1461dnl return buf[0] != 'D'; 1462dnl } 1463dnl --------------------------------------------------------------------- 1464dnl And vsnprintf writes any output without bounds in this case, behaving like 1465dnl vsprintf, on HP-UX 11 and OSF/1 5.1: 1466dnl --------------------------------------------------------------------- 1467dnl #include <stdarg.h> 1468dnl #include <stdio.h> 1469dnl static int my_snprintf (char *buf, int size, const char *format, ...) 1470dnl { 1471dnl va_list args; 1472dnl int ret; 1473dnl va_start (args, format); 1474dnl ret = vsnprintf (buf, size, format, args); 1475dnl va_end (args); 1476dnl return ret; 1477dnl } 1478dnl int main() 1479dnl { 1480dnl static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; 1481dnl my_snprintf (buf, 0, "%d", 12345); 1482dnl return buf[0] != 'D'; 1483dnl } 1484dnl --------------------------------------------------------------------- 1485dnl Result is gl_cv_func_vsnprintf_zerosize_c99. 1486 1487AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99], 1488[ 1489 AC_REQUIRE([AC_PROG_CC]) 1490 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1491 AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99], 1492 [gl_cv_func_vsnprintf_zerosize_c99], 1493 [ 1494 AC_RUN_IFELSE( 1495 [AC_LANG_SOURCE([[ 1496#include <stdarg.h> 1497#include <stdio.h> 1498static int my_snprintf (char *buf, int size, const char *format, ...) 1499{ 1500 va_list args; 1501 int ret; 1502 va_start (args, format); 1503 ret = vsnprintf (buf, size, format, args); 1504 va_end (args); 1505 return ret; 1506} 1507int main() 1508{ 1509 static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; 1510 my_snprintf (buf, 0, "%d", 12345); 1511 return buf[0] != 'D'; 1512}]])], 1513 [gl_cv_func_vsnprintf_zerosize_c99=yes], 1514 [gl_cv_func_vsnprintf_zerosize_c99=no], 1515 [ 1516changequote(,)dnl 1517 case "$host_os" in 1518 # Guess yes on glibc systems. 1519 *-gnu* | gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1520 # Guess yes on FreeBSD >= 5. 1521 freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1522 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1523 # Guess yes on Mac OS X >= 10.3. 1524 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1525 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1526 # Guess yes on Cygwin. 1527 cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1528 # Guess yes on Solaris >= 2.6. 1529 solaris2.[0-5] | solaris2.[0-5].*) 1530 gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1531 solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1532 # Guess yes on AIX >= 4. 1533 aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1534 aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1535 # Guess yes on IRIX >= 6.5. 1536 irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1537 # Guess yes on NetBSD >= 3. 1538 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 1539 gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1540 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1541 # Guess yes on BeOS. 1542 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1543 # Guess yes on native Windows. 1544 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1545 # If we don't know, assume the worst. 1546 *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1547 esac 1548changequote([,])dnl 1549 ]) 1550 ]) 1551]) 1552 1553dnl The results of these tests on various platforms are: 1554dnl 1555dnl 1 = gl_PRINTF_SIZES_C99 1556dnl 2 = gl_PRINTF_LONG_DOUBLE 1557dnl 3 = gl_PRINTF_INFINITE 1558dnl 4 = gl_PRINTF_INFINITE_LONG_DOUBLE 1559dnl 5 = gl_PRINTF_DIRECTIVE_A 1560dnl 6 = gl_PRINTF_DIRECTIVE_F 1561dnl 7 = gl_PRINTF_DIRECTIVE_N 1562dnl 8 = gl_PRINTF_DIRECTIVE_LS 1563dnl 9 = gl_PRINTF_POSITIONS 1564dnl 10 = gl_PRINTF_FLAG_GROUPING 1565dnl 11 = gl_PRINTF_FLAG_LEFTADJUST 1566dnl 12 = gl_PRINTF_FLAG_ZERO 1567dnl 13 = gl_PRINTF_PRECISION 1568dnl 14 = gl_PRINTF_ENOMEM 1569dnl 15 = gl_SNPRINTF_PRESENCE 1570dnl 16 = gl_SNPRINTF_TRUNCATION_C99 1571dnl 17 = gl_SNPRINTF_RETVAL_C99 1572dnl 18 = gl_SNPRINTF_DIRECTIVE_N 1573dnl 19 = gl_SNPRINTF_SIZE1 1574dnl 20 = gl_VSNPRINTF_ZEROSIZE_C99 1575dnl 1576dnl 1 = checking whether printf supports size specifiers as in C99... 1577dnl 2 = checking whether printf supports 'long double' arguments... 1578dnl 3 = checking whether printf supports infinite 'double' arguments... 1579dnl 4 = checking whether printf supports infinite 'long double' arguments... 1580dnl 5 = checking whether printf supports the 'a' and 'A' directives... 1581dnl 6 = checking whether printf supports the 'F' directive... 1582dnl 7 = checking whether printf supports the 'n' directive... 1583dnl 8 = checking whether printf supports the 'ls' directive... 1584dnl 9 = checking whether printf supports POSIX/XSI format strings with positions... 1585dnl 10 = checking whether printf supports the grouping flag... 1586dnl 11 = checking whether printf supports the left-adjust flag correctly... 1587dnl 12 = checking whether printf supports the zero flag correctly... 1588dnl 13 = checking whether printf supports large precisions... 1589dnl 14 = checking whether printf survives out-of-memory conditions... 1590dnl 15 = checking for snprintf... 1591dnl 16 = checking whether snprintf truncates the result as in C99... 1592dnl 17 = checking whether snprintf returns a byte count as in C99... 1593dnl 18 = checking whether snprintf fully supports the 'n' directive... 1594dnl 19 = checking whether snprintf respects a size of 1... 1595dnl 20 = checking whether vsnprintf respects a zero size as in C99... 1596dnl 1597dnl . = yes, # = no. 1598dnl 1599dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1600dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . . 1601dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . . 1602dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . . 1603dnl Mac OS X 10.5.8 . . . # # . . . . . . # . . . . . . . . 1604dnl Mac OS X 10.3.9 . . . . # . . . . . . # . # . . . . . . 1605dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . . 1606dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . . 1607dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . . 1608dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . . 1609dnl Solaris 11.3 . . . . # . . # . . . . . . . . . . . . 1610dnl Solaris 11.0 . . # # # . . # . . . # . . . . . . . . 1611dnl Solaris 10 . . # # # . . # . . . # # . . . . . . . 1612dnl Solaris 2.6 ... 9 # . # # # # . # . . . # # . . . # . . . 1613dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # # 1614dnl AIX 7.1 . . # # # . . . . . . # # . . . . . . . 1615dnl AIX 5.2 . . # # # . . . . . . # . . . . . . . . 1616dnl AIX 4.3.2, 5.1 # . # # # # . . . . . # . . . . # . . . 1617dnl HP-UX 11.31 . . . . # . . . . . . # . . . . # # . . 1618dnl HP-UX 11.{00,11,23} # . . . # # . . . . . # . . . . # # . # 1619dnl HP-UX 10.20 # . # . # # . ? . . # # . . . . # # ? # 1620dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . . 1621dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . # 1622dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # # 1623dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . . 1624dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ? 1625dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . . 1626dnl Haiku . . . # # # . # . . . . . ? . . ? . . . 1627dnl BeOS # # . # # # . ? # . ? . # ? . . ? . . . 1628dnl old mingw / msvcrt # # # # # # . . # # . # # ? . # # # . . 1629dnl MSVC 9 # # # # # # # . # # . # # ? # # # # . . 1630dnl mingw 2009-2011 . # . # . . . . # # . . . ? . . . . . . 1631dnl mingw-w64 2011 # # # # # # . . # # . # # ? . # # # . . 1632