annotate m4/printf.m4 @ 8860:771a56a41b5b

Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
author Bruno Haible <bruno@clisp.org>
date Sun, 20 May 2007 09:01:48 +0000
parents c869de19cb7f
children b99c46035f3e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8860
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
1 # printf.m4 serial 12
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc.
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 dnl Test whether the *printf family of functions supports the 'j', 'z', 't',
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 dnl 'L' size specifiers. (ISO C99, POSIX:2001)
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 dnl Result is gl_cv_func_printf_sizes_c99.
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 AC_DEFUN([gl_PRINTF_SIZES_C99],
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 AC_REQUIRE([AC_PROG_CC])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 AC_CACHE_CHECK([whether printf supports size specifiers as in C99],
8847
0c9ab5719ed4 Whitespace change.
Bruno Haible <bruno@clisp.org>
parents: 8840
diff changeset
18 [gl_cv_func_printf_sizes_c99],
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 AC_TRY_RUN([
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include <stddef.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include <stdio.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include <string.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #include <sys/types.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 #if HAVE_STDINT_H_WITH_UINTMAX
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 # include <stdint.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 #endif
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 #if HAVE_INTTYPES_H_WITH_UINTMAX
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 # include <inttypes.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 #endif
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 static char buf[100];
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 int main ()
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 {
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 #if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 buf[0] = '\0';
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 || strcmp (buf, "12345671 33") != 0)
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 return 1;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 #endif
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 buf[0] = '\0';
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 || strcmp (buf, "12345672 33") != 0)
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 return 1;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 buf[0] = '\0';
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 || strcmp (buf, "12345673 33") != 0)
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 return 1;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 buf[0] = '\0';
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 || strcmp (buf, "1.5 33") != 0)
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 return 1;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 return 0;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 }], [gl_cv_func_printf_sizes_c99=yes], [gl_cv_func_printf_sizes_c99=no],
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 changequote(,)dnl
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 case "$host_os" in
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
57 # Guess yes on glibc systems.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
59 # Guess yes on FreeBSD >= 5.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
62 # Guess yes on MacOS X >= 10.3.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 darwin*) gl_cv_func_printf_sizes_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
65 # Guess yes on OpenBSD >= 3.9.
8347
03bfd77e2c10 Add info about OpenBSD.
Bruno Haible <bruno@clisp.org>
parents: 8346
diff changeset
66 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
03bfd77e2c10 Add info about OpenBSD.
Bruno Haible <bruno@clisp.org>
parents: 8346
diff changeset
67 gl_cv_func_printf_sizes_c99="guessing no";;
03bfd77e2c10 Add info about OpenBSD.
Bruno Haible <bruno@clisp.org>
parents: 8346
diff changeset
68 openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
69 # Guess yes on Solaris >= 2.10.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 solaris2.[0-9]*) gl_cv_func_printf_sizes_c99="guessing no";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 solaris*) gl_cv_func_printf_sizes_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
72 # Guess yes on NetBSD >= 3.
8350
4e430e6470b3 Be more conservative about the config.guess results on NetBSD.
Bruno Haible <bruno@clisp.org>
parents: 8349
diff changeset
73 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
4e430e6470b3 Be more conservative about the config.guess results on NetBSD.
Bruno Haible <bruno@clisp.org>
parents: 8349
diff changeset
74 gl_cv_func_printf_sizes_c99="guessing no";;
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
76 # If we don't know, assume the worst.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 *) gl_cv_func_printf_sizes_c99="guessing no";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78 esac
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 changequote([,])dnl
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83
8849
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
84 dnl Test whether the *printf family of functions supports 'long double'
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
85 dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001)
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
86 dnl Result is gl_cv_func_printf_long_double.
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
87
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
88 AC_DEFUN([gl_PRINTF_LONG_DOUBLE],
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
89 [
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
90 AC_REQUIRE([AC_PROG_CC])
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
91 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
92 AC_CACHE_CHECK([whether printf supports 'long double' arguments],
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
93 [gl_cv_func_printf_long_double],
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
94 [
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
95 AC_TRY_RUN([
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
96 #include <stdio.h>
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
97 #include <string.h>
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
98 static char buf[100];
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
99 int main ()
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
100 {
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
101 buf[0] = '\0';
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
102 if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
103 || strcmp (buf, "1.750000 33") != 0)
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
104 return 1;
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
105 buf[0] = '\0';
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
106 if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
107 || strcmp (buf, "1.750000e+00 33") != 0)
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
108 return 1;
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
109 buf[0] = '\0';
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
110 if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
111 || strcmp (buf, "1.75 33") != 0)
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
112 return 1;
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
113 return 0;
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
114 }], [gl_cv_func_printf_long_double=yes], [gl_cv_func_printf_long_double=no],
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
115 [
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
116 changequote(,)dnl
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
117 case "$host_os" in
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
118 beos*) gl_cv_func_printf_long_double="guessing no";;
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
119 mingw* | pw*) gl_cv_func_printf_long_double="guessing no";;
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
120 *) gl_cv_func_printf_long_double="guessing yes";;
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
121 esac
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
122 changequote([,])dnl
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
123 ])
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
124 ])
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
125 ])
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
126
8840
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
127 dnl Test whether the *printf family of functions supports infinite 'double'
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
128 dnl arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001)
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
129 dnl Result is gl_cv_func_printf_infinite.
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
130
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
131 AC_DEFUN([gl_PRINTF_INFINITE],
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
132 [
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
133 AC_REQUIRE([AC_PROG_CC])
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
134 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
135 AC_CACHE_CHECK([whether printf supports infinite 'double' arguments],
8847
0c9ab5719ed4 Whitespace change.
Bruno Haible <bruno@clisp.org>
parents: 8840
diff changeset
136 [gl_cv_func_printf_infinite],
8840
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
137 [
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
138 AC_TRY_RUN([
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
139 #include <stdio.h>
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
140 #include <string.h>
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
141 static char buf[100];
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
142 int main ()
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
143 {
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
144 if (sprintf (buf, "%f", 1.0 / 0.0) < 0
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
145 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
146 return 1;
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
147 if (sprintf (buf, "%f", -1.0 / 0.0) < 0
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
148 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
149 return 1;
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
150 if (sprintf (buf, "%e", 1.0 / 0.0) < 0
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
151 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
152 return 1;
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
153 if (sprintf (buf, "%e", -1.0 / 0.0) < 0
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
154 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
155 return 1;
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
156 if (sprintf (buf, "%g", 1.0 / 0.0) < 0
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
157 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
158 return 1;
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
159 if (sprintf (buf, "%g", -1.0 / 0.0) < 0
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
160 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
161 return 1;
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
162 return 0;
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
163 }], [gl_cv_func_printf_infinite=yes], [gl_cv_func_printf_infinite=no],
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
164 [
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
165 changequote(,)dnl
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
166 case "$host_os" in
8860
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
167 # Guess yes on glibc systems.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
168 *-gnu*) gl_cv_func_printf_infinite="guessing yes";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
169 # Guess yes on FreeBSD >= 6.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
170 freebsd[1-5]*) gl_cv_func_printf_infinite="guessing no";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
171 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
172 # Guess yes on MacOS X >= 10.3.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
173 darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
174 darwin*) gl_cv_func_printf_infinite="guessing yes";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
175 # Guess yes on HP-UX >= 11.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
176 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
177 hpux*) gl_cv_func_printf_infinite="guessing yes";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
178 # Guess yes on IRIX >= 6.5.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
179 irix6.5) gl_cv_func_printf_infinite="guessing yes";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
180 # Guess yes on NetBSD >= 3.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
181 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
182 gl_cv_func_printf_infinite="guessing no";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
183 netbsd*) gl_cv_func_printf_infinite="guessing yes";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
184 # Guess yes on BeOS.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
185 beos*) gl_cv_func_printf_infinite="guessing yes";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
186 # If we don't know, assume the worst.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
187 *) gl_cv_func_printf_infinite="guessing no";;
8840
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
188 esac
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
189 changequote([,])dnl
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
190 ])
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
191 ])
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
192 ])
792e05ae7ac8 Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8832
diff changeset
193
8860
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
194 dnl Test whether the *printf family of functions supports infinite 'long double'
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
195 dnl arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001)
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
196 dnl Result is gl_cv_func_printf_infinite_long_double.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
197
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
198 AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE],
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
199 [
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
200 AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
201 AC_REQUIRE([AC_PROG_CC])
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
202 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
203 case "$gl_cv_func_printf_long_double" in
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
204 *yes)
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
205 AC_CACHE_CHECK([whether printf supports infinite 'long double' arguments],
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
206 [gl_cv_func_printf_infinite_long_double],
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
207 [
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
208 AC_TRY_RUN([
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
209 #include <stdio.h>
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
210 #include <string.h>
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
211 static char buf[100];
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
212 int main ()
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
213 {
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
214 if (sprintf (buf, "%Lf", 1.0L / 0.0L) < 0
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
215 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
216 return 1;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
217 if (sprintf (buf, "%Lf", -1.0L / 0.0L) < 0
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
218 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
219 return 1;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
220 if (sprintf (buf, "%Le", 1.0L / 0.0L) < 0
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
221 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
222 return 1;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
223 if (sprintf (buf, "%Le", -1.0L / 0.0L) < 0
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
224 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
225 return 1;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
226 if (sprintf (buf, "%Lg", 1.0L / 0.0L) < 0
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
227 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
228 return 1;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
229 if (sprintf (buf, "%Lg", -1.0L / 0.0L) < 0
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
230 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
231 return 1;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
232 return 0;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
233 }],
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
234 [gl_cv_func_printf_infinite_long_double=yes],
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
235 [gl_cv_func_printf_infinite_long_double=no],
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
236 [
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
237 changequote(,)dnl
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
238 case "$host_os" in
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
239 # Guess yes on glibc systems.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
240 *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
241 # Guess yes on FreeBSD >= 6.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
242 freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
243 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
244 # Guess yes on MacOS X >= 10.3.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
245 darwin[1-6].*) gl_cv_func_printf_infinite_long_double="guessing no";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
246 darwin*) gl_cv_func_printf_infinite_long_double="guessing yes";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
247 # Guess yes on HP-UX >= 11.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
248 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
249 hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
250 # Guess yes on IRIX >= 6.5.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
251 irix6.5) gl_cv_func_printf_infinite_long_double="guessing yes";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
252 # Guess yes on NetBSD >= 3.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
253 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
254 gl_cv_func_printf_infinite_long_double="guessing no";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
255 netbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
256 # If we don't know, assume the worst.
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
257 *) gl_cv_func_printf_infinite_long_double="guessing no";;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
258 esac
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
259 changequote([,])dnl
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
260 ])
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
261 ])
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
262 ;;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
263 *)
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
264 gl_cv_func_printf_infinite_long_double="irrelevant"
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
265 ;;
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
266 esac
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
267 ])
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
268
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
269 dnl Test whether the *printf family of functions supports the 'a' and 'A'
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
270 dnl conversion specifier for hexadecimal output of floating-point numbers.
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
271 dnl (ISO C99, POSIX:2001)
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
272 dnl Result is gl_cv_func_printf_directive_a.
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
273
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
274 AC_DEFUN([gl_PRINTF_DIRECTIVE_A],
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
275 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
276 AC_REQUIRE([AC_PROG_CC])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
277 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
278 AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives],
8847
0c9ab5719ed4 Whitespace change.
Bruno Haible <bruno@clisp.org>
parents: 8840
diff changeset
279 [gl_cv_func_printf_directive_a],
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
280 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
281 AC_TRY_RUN([
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
282 #include <stdio.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
283 #include <string.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
284 static char buf[100];
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
285 int main ()
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
286 {
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
287 if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0
8344
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
288 || (strcmp (buf, "0x1.922p+1 33") != 0
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
289 && strcmp (buf, "0x3.244p+0 33") != 0
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
290 && strcmp (buf, "0x6.488p-1 33") != 0
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
291 && strcmp (buf, "0xc.91p-2 33") != 0))
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
292 return 1;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
293 if (sprintf (buf, "%A %d", -3.1416015625, 33, 44, 55) < 0
8344
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
294 || (strcmp (buf, "-0X1.922P+1 33") != 0
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
295 && strcmp (buf, "-0X3.244P+0 33") != 0
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
296 && strcmp (buf, "-0X6.488P-1 33") != 0
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
297 && strcmp (buf, "-0XC.91P-2 33") != 0))
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
298 return 1;
8643
013fc89d552c Catch a bug of printf "%a" on FreeBSD 6.1.
Bruno Haible <bruno@clisp.org>
parents: 8383
diff changeset
299 /* This catches a FreeBSD 6.1 bug: it doesn't round. */
013fc89d552c Catch a bug of printf "%a" on FreeBSD 6.1.
Bruno Haible <bruno@clisp.org>
parents: 8383
diff changeset
300 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0
8663
e2189cab039d The 2007-04-04 patch was broken.
Bruno Haible <bruno@clisp.org>
parents: 8662
diff changeset
301 || (strcmp (buf, "0x1.83p+0 33") != 0
e2189cab039d The 2007-04-04 patch was broken.
Bruno Haible <bruno@clisp.org>
parents: 8662
diff changeset
302 && strcmp (buf, "0x3.05p-1 33") != 0
e2189cab039d The 2007-04-04 patch was broken.
Bruno Haible <bruno@clisp.org>
parents: 8662
diff changeset
303 && strcmp (buf, "0x6.0ap-2 33") != 0
e2189cab039d The 2007-04-04 patch was broken.
Bruno Haible <bruno@clisp.org>
parents: 8662
diff changeset
304 && strcmp (buf, "0xc.14p-3 33") != 0))
8643
013fc89d552c Catch a bug of printf "%a" on FreeBSD 6.1.
Bruno Haible <bruno@clisp.org>
parents: 8383
diff changeset
305 return 1;
8662
023aa5c883a7 Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 8648
diff changeset
306 /* This catches a FreeBSD 6.1 bug. See
023aa5c883a7 Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 8648
diff changeset
307 <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
023aa5c883a7 Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 8648
diff changeset
308 if (sprintf (buf, "%010a %d", 1.0 / 0.0, 33, 44, 55) < 0
8663
e2189cab039d The 2007-04-04 patch was broken.
Bruno Haible <bruno@clisp.org>
parents: 8662
diff changeset
309 || buf[0] == '0')
8662
023aa5c883a7 Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 8648
diff changeset
310 return 1;
8344
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
311 /* This catches a MacOS X 10.3.9 (Darwin 7.9) bug. */
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
312 if (sprintf (buf, "%.1a", 1.999) < 0
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
313 || (strcmp (buf, "0x1.0p+1") != 0
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
314 && strcmp (buf, "0x2.0p+0") != 0
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
315 && strcmp (buf, "0x4.0p-1") != 0
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
316 && strcmp (buf, "0x8.0p-2") != 0))
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
317 return 1;
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
318 /* This catches the same MacOS X 10.3.9 (Darwin 7.9) bug and also a
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
319 glibc 2.4 bug <http://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
320 if (sprintf (buf, "%.1La", 1.999L) < 0
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
321 || (strcmp (buf, "0x1.0p+1") != 0
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
322 && strcmp (buf, "0x2.0p+0") != 0
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
323 && strcmp (buf, "0x4.0p-1") != 0
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
324 && strcmp (buf, "0x8.0p-2") != 0))
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
325 return 1;
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
326 return 0;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
327 }], [gl_cv_func_printf_directive_a=yes], [gl_cv_func_printf_directive_a=no],
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
328 [
8344
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
329 case "$host_os" in
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
330 # Guess yes on glibc >= 2.5 systems.
8344
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
331 *-gnu*)
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
332 AC_EGREP_CPP([BZ2908], [
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
333 #include <features.h>
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
334 #ifdef __GNU_LIBRARY__
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
335 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2)
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
336 BZ2908
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
337 #endif
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
338 #endif
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
339 ],
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
340 [gl_cv_func_printf_directive_a="guessing yes"],
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
341 [gl_cv_func_printf_directive_a="guessing no"])
c8055280f68e Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents: 8335
diff changeset
342 ;;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
343 # If we don't know, assume the worst.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
344 *) gl_cv_func_printf_directive_a="guessing no";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
345 esac
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
346 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
347 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
348 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
349
8664
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
350 dnl Test whether the *printf family of functions supports the %F format
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
351 dnl directive. (ISO C99, POSIX:2001)
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
352 dnl Result is gl_cv_func_printf_directive_f.
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
353
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
354 AC_DEFUN([gl_PRINTF_DIRECTIVE_F],
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
355 [
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
356 AC_REQUIRE([AC_PROG_CC])
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
357 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
358 AC_CACHE_CHECK([whether printf supports the 'F' directive],
8847
0c9ab5719ed4 Whitespace change.
Bruno Haible <bruno@clisp.org>
parents: 8840
diff changeset
359 [gl_cv_func_printf_directive_f],
8664
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
360 [
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
361 AC_TRY_RUN([
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
362 #include <stdio.h>
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
363 #include <string.h>
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
364 static char buf[100];
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
365 int main ()
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
366 {
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
367 if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
368 || strcmp (buf, "1234567.000000 33") != 0)
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
369 return 1;
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
370 if (sprintf (buf, "%F", 1.0 / 0.0) < 0
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
371 || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0))
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
372 return 1;
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
373 /* This catches a Cygwin 2007 bug. */
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
374 if (sprintf (buf, "%.F", 1234.0) < 0
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
375 || strcmp (buf, "1234") != 0)
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
376 return 1;
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
377 return 0;
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
378 }], [gl_cv_func_printf_directive_f=yes], [gl_cv_func_printf_directive_f=no],
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
379 [
8666
7ff0dd9e3d4f Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 8665
diff changeset
380 changequote(,)dnl
8664
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
381 case "$host_os" in
8666
7ff0dd9e3d4f Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 8665
diff changeset
382 # Guess yes on glibc systems.
7ff0dd9e3d4f Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 8665
diff changeset
383 *-gnu*) gl_cv_func_printf_directive_f="guessing yes";;
7ff0dd9e3d4f Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 8665
diff changeset
384 # Guess yes on FreeBSD >= 6.
7ff0dd9e3d4f Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 8665
diff changeset
385 freebsd[1-5]*) gl_cv_func_printf_directive_f="guessing no";;
7ff0dd9e3d4f Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 8665
diff changeset
386 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";;
7ff0dd9e3d4f Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 8665
diff changeset
387 # Guess yes on MacOS X >= 10.3.
7ff0dd9e3d4f Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 8665
diff changeset
388 darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";;
7ff0dd9e3d4f Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 8665
diff changeset
389 darwin*) gl_cv_func_printf_directive_f="guessing yes";;
7ff0dd9e3d4f Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 8665
diff changeset
390 # Guess yes on Solaris >= 2.10.
7ff0dd9e3d4f Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 8665
diff changeset
391 solaris2.[0-9]*) gl_cv_func_printf_directive_f="guessing no";;
7ff0dd9e3d4f Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 8665
diff changeset
392 solaris*) gl_cv_func_printf_directive_f="guessing yes";;
8664
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
393 # If we don't know, assume the worst.
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
394 *) gl_cv_func_printf_directive_f="guessing no";;
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
395 esac
8666
7ff0dd9e3d4f Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 8665
diff changeset
396 changequote([,])dnl
8664
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
397 ])
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
398 ])
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
399 ])
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8663
diff changeset
400
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
401 dnl Test whether the *printf family of functions supports the %n format
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
402 dnl directive. (ISO C99, POSIX:2001)
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
403 dnl Result is gl_cv_func_printf_directive_n.
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
404
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
405 AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
406 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
407 AC_REQUIRE([AC_PROG_CC])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
408 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
409 AC_CACHE_CHECK([whether printf supports the 'n' directive],
8847
0c9ab5719ed4 Whitespace change.
Bruno Haible <bruno@clisp.org>
parents: 8840
diff changeset
410 [gl_cv_func_printf_directive_n],
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
411 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
412 AC_TRY_RUN([
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
413 #include <stdio.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
414 #include <string.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
415 static char buf[100];
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
416 int main ()
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
417 {
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
418 int count = -1;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
419 if (sprintf (buf, "%d %n", 123, &count, 33, 44, 55) < 0
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
420 || strcmp (buf, "123 ") != 0
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
421 || count != 4)
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
422 return 1;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
423 return 0;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
424 }], [gl_cv_func_printf_directive_n=yes], [gl_cv_func_printf_directive_n=no],
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
425 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
426 changequote(,)dnl
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
427 case "$host_os" in
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
428 *) gl_cv_func_printf_directive_n="guessing yes";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
429 esac
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
430 changequote([,])dnl
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
431 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
432 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
433 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
434
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
435 dnl Test whether the *printf family of functions supports POSIX/XSI format
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
436 dnl strings with positions. (POSIX:2001)
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
437 dnl Result is gl_cv_func_printf_positions.
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
438
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
439 AC_DEFUN([gl_PRINTF_POSITIONS],
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
440 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
441 AC_REQUIRE([AC_PROG_CC])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
442 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
443 AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions],
8847
0c9ab5719ed4 Whitespace change.
Bruno Haible <bruno@clisp.org>
parents: 8840
diff changeset
444 [gl_cv_func_printf_positions],
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
445 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
446 AC_TRY_RUN([
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
447 #include <stdio.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
448 #include <string.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
449 /* The string "%2$d %1$d", with dollar characters protected from the shell's
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
450 dollar expansion (possibly an autoconf bug). */
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
451 static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' };
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
452 static char buf[100];
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
453 int main ()
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
454 {
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
455 sprintf (buf, format, 33, 55);
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
456 return (strcmp (buf, "55 33") != 0);
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
457 }], [gl_cv_func_printf_positions=yes], [gl_cv_func_printf_positions=no],
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
458 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
459 changequote(,)dnl
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
460 case "$host_os" in
8350
4e430e6470b3 Be more conservative about the config.guess results on NetBSD.
Bruno Haible <bruno@clisp.org>
parents: 8349
diff changeset
461 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
4e430e6470b3 Be more conservative about the config.guess results on NetBSD.
Bruno Haible <bruno@clisp.org>
parents: 8349
diff changeset
462 gl_cv_func_printf_positions="guessing no";;
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
463 beos*) gl_cv_func_printf_positions="guessing no";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
464 mingw* | pw*) gl_cv_func_printf_positions="guessing no";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
465 *) gl_cv_func_printf_positions="guessing yes";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
466 esac
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
467 changequote([,])dnl
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
468 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
469 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
470 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
471
8803
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
472 dnl Test whether the *printf family of functions supports POSIX/XSI format
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
473 dnl strings with the ' flag for grouping of decimal digits. (POSIX:2001)
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
474 dnl Result is gl_cv_func_printf_flag_grouping.
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
475
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
476 AC_DEFUN([gl_PRINTF_FLAG_GROUPING],
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
477 [
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
478 AC_REQUIRE([AC_PROG_CC])
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
479 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
480 AC_CACHE_CHECK([whether printf supports the grouping flag],
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
481 [gl_cv_func_printf_flag_grouping],
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
482 [
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
483 AC_TRY_RUN([
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
484 #include <stdio.h>
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
485 #include <string.h>
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
486 static char buf[100];
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
487 int main ()
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
488 {
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
489 if (sprintf (buf, "%'d %d", 1234567, 99) < 0
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
490 || buf[strlen (buf) - 1] != '9')
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
491 return 1;
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
492 return 0;
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
493 }], [gl_cv_func_printf_flag_grouping=yes], [gl_cv_func_printf_flag_grouping=no],
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
494 [
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
495 changequote(,)dnl
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
496 case "$host_os" in
8805
c6df1b1d2c81 More info about Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 8804
diff changeset
497 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";;
8803
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
498 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";;
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
499 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
500 *) gl_cv_func_printf_flag_grouping="guessing yes";;
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
501 esac
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
502 changequote([,])dnl
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
503 ])
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
504 ])
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
505 ])
6c1d98929550 Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents: 8763
diff changeset
506
8804
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
507 dnl Test whether the *printf family of functions supports padding of non-finite
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
508 dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
509 dnl <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html>
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
510 dnl Result is gl_cv_func_printf_flag_zero.
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
511
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
512 AC_DEFUN([gl_PRINTF_FLAG_ZERO],
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
513 [
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
514 AC_REQUIRE([AC_PROG_CC])
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
515 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
516 AC_CACHE_CHECK([whether printf supports the zero flag correctly],
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
517 [gl_cv_func_printf_flag_zero],
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
518 [
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
519 AC_TRY_RUN([
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
520 #include <stdio.h>
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
521 #include <string.h>
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
522 static char buf[100];
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
523 int main ()
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
524 {
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
525 if (sprintf (buf, "%010f", 1.0 / 0.0, 33, 44, 55) < 0
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
526 || (strcmp (buf, " inf") != 0
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
527 && strcmp (buf, " infinity") != 0))
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
528 return 1;
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
529 return 0;
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
530 }], [gl_cv_func_printf_flag_zero=yes], [gl_cv_func_printf_flag_zero=no],
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
531 [
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
532 changequote(,)dnl
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
533 case "$host_os" in
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
534 # Guess yes on glibc systems.
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
535 *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";;
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
536 # Guess yes on BeOS.
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
537 beos*) gl_cv_func_printf_flag_zero="guessing yes";;
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
538 # If we don't know, assume the worst.
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
539 *) gl_cv_func_printf_flag_zero="guessing no";;
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
540 esac
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
541 changequote([,])dnl
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
542 ])
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
543 ])
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
544 ])
6ce313658b4d Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents: 8803
diff changeset
545
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
546 dnl Test whether the snprintf function exists. (ISO C99, POSIX:2001)
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
547 dnl Result is ac_cv_func_snprintf.
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
548
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
549 AC_DEFUN([gl_SNPRINTF_PRESENCE],
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
550 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
551 AC_CHECK_FUNCS_ONCE([snprintf])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
552 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
553
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
554 dnl Test whether the string produced by the snprintf function is always NUL
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
555 dnl terminated. (ISO C99, POSIX:2001)
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
556 dnl Result is gl_cv_func_snprintf_truncation_c99.
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
557
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
558 AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99],
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
559 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
560 AC_REQUIRE([AC_PROG_CC])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
561 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
562 AC_CACHE_CHECK([whether snprintf truncates the result as in C99],
8847
0c9ab5719ed4 Whitespace change.
Bruno Haible <bruno@clisp.org>
parents: 8840
diff changeset
563 [gl_cv_func_snprintf_truncation_c99],
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
564 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
565 AC_TRY_RUN([
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
566 #include <stdio.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
567 #include <string.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
568 static char buf[100];
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
569 int main ()
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
570 {
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
571 strcpy (buf, "ABCDEF");
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
572 snprintf (buf, 3, "%d %d", 4567, 89);
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
573 if (memcmp (buf, "45\0DEF", 6) != 0)
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
574 return 1;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
575 return 0;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
576 }], [gl_cv_func_snprintf_truncation_c99=yes], [gl_cv_func_snprintf_truncation_c99=no],
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
577 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
578 changequote(,)dnl
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
579 case "$host_os" in
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
580 # Guess yes on glibc systems.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
581 *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
582 # Guess yes on FreeBSD >= 5.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
583 freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
584 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
585 # Guess yes on MacOS X >= 10.3.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
586 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
587 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
588 # Guess yes on OpenBSD >= 3.9.
8347
03bfd77e2c10 Add info about OpenBSD.
Bruno Haible <bruno@clisp.org>
parents: 8346
diff changeset
589 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
03bfd77e2c10 Add info about OpenBSD.
Bruno Haible <bruno@clisp.org>
parents: 8346
diff changeset
590 gl_cv_func_snprintf_truncation_c99="guessing no";;
03bfd77e2c10 Add info about OpenBSD.
Bruno Haible <bruno@clisp.org>
parents: 8346
diff changeset
591 openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
592 # Guess yes on Solaris >= 2.6.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
593 solaris2.[0-5]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
594 solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
595 # Guess yes on AIX >= 4.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
596 aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
597 aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
598 # Guess yes on HP-UX >= 11.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
599 hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
600 hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
601 # Guess yes on IRIX >= 6.5.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
602 irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
603 # Guess yes on OSF/1 >= 5.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
604 osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
605 osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
606 # Guess yes on NetBSD >= 3.
8350
4e430e6470b3 Be more conservative about the config.guess results on NetBSD.
Bruno Haible <bruno@clisp.org>
parents: 8349
diff changeset
607 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
4e430e6470b3 Be more conservative about the config.guess results on NetBSD.
Bruno Haible <bruno@clisp.org>
parents: 8349
diff changeset
608 gl_cv_func_snprintf_truncation_c99="guessing no";;
4e430e6470b3 Be more conservative about the config.guess results on NetBSD.
Bruno Haible <bruno@clisp.org>
parents: 8349
diff changeset
609 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
610 # Guess yes on BeOS.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
611 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
612 # If we don't know, assume the worst.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
613 *) gl_cv_func_snprintf_truncation_c99="guessing no";;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
614 esac
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
615 changequote([,])dnl
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
616 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
617 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
618 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
619
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
620 dnl Test whether the return value of the snprintf function is the number
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
621 dnl of bytes (excluding the terminating NUL) that would have been produced
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
622 dnl if the buffer had been large enough. (ISO C99, POSIX:2001)
8763
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
623 dnl For example, this test program fails on IRIX 6.5:
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
624 dnl ---------------------------------------------------------------------
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
625 dnl #include <stdio.h>
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
626 dnl int main()
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
627 dnl {
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
628 dnl static char buf[8];
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
629 dnl int retval = snprintf (buf, 3, "%d", 12345);
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
630 dnl return retval >= 0 && retval < 3;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
631 dnl }
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
632 dnl ---------------------------------------------------------------------
8353
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
633 dnl Result is gl_cv_func_snprintf_retval_c99.
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
634
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
635 AC_DEFUN([gl_SNPRINTF_RETVAL_C99],
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
636 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
637 AC_REQUIRE([AC_PROG_CC])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
638 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
639 AC_CACHE_CHECK([whether snprintf returns a byte count as in C99],
8847
0c9ab5719ed4 Whitespace change.
Bruno Haible <bruno@clisp.org>
parents: 8840
diff changeset
640 [gl_cv_func_snprintf_retval_c99],
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
641 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
642 AC_TRY_RUN([
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
643 #include <stdio.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
644 #include <string.h>
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
645 static char buf[100];
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
646 int main ()
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
647 {
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
648 strcpy (buf, "ABCDEF");
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
649 if (snprintf (buf, 3, "%d %d", 4567, 89) != 7)
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
650 return 1;
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
651 return 0;
8353
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
652 }], [gl_cv_func_snprintf_retval_c99=yes], [gl_cv_func_snprintf_retval_c99=no],
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
653 [
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
654 changequote(,)dnl
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
655 case "$host_os" in
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
656 # Guess yes on glibc systems.
8353
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
657 *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
658 # Guess yes on FreeBSD >= 5.
8353
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
659 freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";;
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
660 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
661 # Guess yes on MacOS X >= 10.3.
8353
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
662 darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";;
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
663 darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
664 # Guess yes on OpenBSD >= 3.9.
8347
03bfd77e2c10 Add info about OpenBSD.
Bruno Haible <bruno@clisp.org>
parents: 8346
diff changeset
665 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
8353
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
666 gl_cv_func_snprintf_retval_c99="guessing no";;
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
667 openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
668 # Guess yes on Solaris >= 2.6.
8353
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
669 solaris2.[0-5]*) gl_cv_func_snprintf_retval_c99="guessing no";;
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
670 solaris*) gl_cv_func_snprintf_retval_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
671 # Guess yes on AIX >= 4.
8353
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
672 aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";;
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
673 aix*) gl_cv_func_snprintf_retval_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
674 # Guess yes on NetBSD >= 3.
8350
4e430e6470b3 Be more conservative about the config.guess results on NetBSD.
Bruno Haible <bruno@clisp.org>
parents: 8349
diff changeset
675 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
8353
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
676 gl_cv_func_snprintf_retval_c99="guessing no";;
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
677 netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
678 # Guess yes on BeOS.
8353
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
679 beos*) gl_cv_func_snprintf_retval_c99="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
680 # If we don't know, assume the worst.
8353
2beaea8e12f9 Rename a cache variable.
Bruno Haible <bruno@clisp.org>
parents: 8352
diff changeset
681 *) gl_cv_func_snprintf_retval_c99="guessing no";;
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
682 esac
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
683 changequote([,])dnl
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
684 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
685 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
686 ])
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
687
8352
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
688 dnl Test whether the snprintf function supports the %n format directive
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
689 dnl also in truncated portions of the format string. (ISO C99, POSIX:2001)
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
690 dnl Result is gl_cv_func_snprintf_directive_n.
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
691
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
692 AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N],
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
693 [
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
694 AC_REQUIRE([AC_PROG_CC])
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
695 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
696 AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive],
8847
0c9ab5719ed4 Whitespace change.
Bruno Haible <bruno@clisp.org>
parents: 8840
diff changeset
697 [gl_cv_func_snprintf_directive_n],
8352
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
698 [
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
699 AC_TRY_RUN([
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
700 #include <stdio.h>
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
701 #include <string.h>
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
702 static char buf[100];
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
703 int main ()
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
704 {
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
705 int count = -1;
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
706 snprintf (buf, 4, "%d %n", 12345, &count, 33, 44, 55);
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
707 if (count != 6)
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
708 return 1;
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
709 return 0;
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
710 }], [gl_cv_func_snprintf_directive_n=yes], [gl_cv_func_snprintf_directive_n=no],
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
711 [
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
712 changequote(,)dnl
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
713 case "$host_os" in
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
714 # Guess yes on glibc systems.
8352
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
715 *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
716 # Guess yes on FreeBSD >= 5.
8352
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
717 freebsd[1-4]*) gl_cv_func_snprintf_directive_n="guessing no";;
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
718 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
719 # Guess yes on MacOS X >= 10.3.
8352
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
720 darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";;
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
721 darwin*) gl_cv_func_snprintf_directive_n="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
722 # Guess yes on Solaris >= 2.6.
8352
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
723 solaris2.[0-5]*) gl_cv_func_snprintf_directive_n="guessing no";;
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
724 solaris*) gl_cv_func_snprintf_directive_n="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
725 # Guess yes on AIX >= 4.
8352
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
726 aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";;
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
727 aix*) gl_cv_func_snprintf_directive_n="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
728 # Guess yes on IRIX >= 6.5.
8352
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
729 irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
730 # Guess yes on OSF/1 >= 5.
8352
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
731 osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";;
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
732 osf*) gl_cv_func_snprintf_directive_n="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
733 # Guess yes on NetBSD >= 3.
8352
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
734 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
735 gl_cv_func_snprintf_directive_n="guessing no";;
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
736 netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
737 # Guess yes on BeOS.
8352
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
738 beos*) gl_cv_func_snprintf_directive_n="guessing yes";;
8380
61a6d421d6f2 Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents: 8353
diff changeset
739 # If we don't know, assume the worst.
8352
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
740 *) gl_cv_func_snprintf_directive_n="guessing no";;
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
741 esac
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
742 changequote([,])dnl
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
743 ])
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
744 ])
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
745 ])
741f8a5caa9c Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents: 8351
diff changeset
746
8763
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
747 dnl Test whether the vsnprintf function, when passed a zero size, produces no
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
748 dnl output. (ISO C99, POSIX:2001)
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
749 dnl For example, snprintf nevertheless writes a NUL byte in this case
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
750 dnl on OSF/1 5.1:
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
751 dnl ---------------------------------------------------------------------
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
752 dnl #include <stdio.h>
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
753 dnl int main()
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
754 dnl {
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
755 dnl static char buf[8] = "DEADBEEF";
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
756 dnl snprintf (buf, 0, "%d", 12345);
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
757 dnl return buf[0] != 'D';
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
758 dnl }
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
759 dnl ---------------------------------------------------------------------
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
760 dnl And vsnprintf writes any output without bounds in this case, behaving like
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
761 dnl vsprintf, on HP-UX 11 and OSF/1 5.1:
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
762 dnl ---------------------------------------------------------------------
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
763 dnl #include <stdarg.h>
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
764 dnl #include <stdio.h>
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
765 dnl static int my_snprintf (char *buf, int size, const char *format, ...)
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
766 dnl {
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
767 dnl va_list args;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
768 dnl int ret;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
769 dnl va_start (args, format);
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
770 dnl ret = vsnprintf (buf, size, format, args);
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
771 dnl va_end (args);
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
772 dnl return ret;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
773 dnl }
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
774 dnl int main()
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
775 dnl {
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
776 dnl static char buf[8] = "DEADBEEF";
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
777 dnl my_snprintf (buf, 0, "%d", 12345);
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
778 dnl return buf[0] != 'D';
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
779 dnl }
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
780 dnl ---------------------------------------------------------------------
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
781 dnl Result is gl_cv_func_vsnprintf_zerosize_c99.
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
782
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
783 AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99],
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
784 [
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
785 AC_REQUIRE([AC_PROG_CC])
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
786 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
787 AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99],
8847
0c9ab5719ed4 Whitespace change.
Bruno Haible <bruno@clisp.org>
parents: 8840
diff changeset
788 [gl_cv_func_vsnprintf_zerosize_c99],
8763
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
789 [
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
790 AC_TRY_RUN([
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
791 #include <stdarg.h>
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
792 #include <stdio.h>
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
793 static int my_snprintf (char *buf, int size, const char *format, ...)
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
794 {
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
795 va_list args;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
796 int ret;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
797 va_start (args, format);
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
798 ret = vsnprintf (buf, size, format, args);
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
799 va_end (args);
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
800 return ret;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
801 }
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
802 int main()
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
803 {
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
804 static char buf[8] = "DEADBEEF";
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
805 my_snprintf (buf, 0, "%d", 12345);
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
806 return buf[0] != 'D';
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
807 }],
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
808 [gl_cv_func_vsnprintf_zerosize_c99=yes],
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
809 [gl_cv_func_vsnprintf_zerosize_c99=no],
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
810 [
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
811 changequote(,)dnl
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
812 case "$host_os" in
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
813 # Guess yes on glibc systems.
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
814 *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
815 # Guess yes on FreeBSD >= 5.
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
816 freebsd[1-4]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
817 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
818 # Guess yes on MacOS X >= 10.3.
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
819 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
820 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
8805
c6df1b1d2c81 More info about Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 8804
diff changeset
821 # Guess yes on Cygwin.
c6df1b1d2c81 More info about Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 8804
diff changeset
822 cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
8763
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
823 # Guess yes on Solaris >= 2.6.
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
824 solaris2.[0-5]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
825 solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
826 # Guess yes on AIX >= 4.
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
827 aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
828 aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
829 # Guess yes on IRIX >= 6.5.
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
830 irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
831 # Guess yes on NetBSD >= 3.
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
832 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
833 gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
834 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
835 # Guess yes on BeOS.
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
836 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
837 # Guess yes on mingw.
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
838 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
839 # If we don't know, assume the worst.
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
840 *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
841 esac
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
842 changequote([,])dnl
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
843 ])
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
844 ])
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
845 ])
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8676
diff changeset
846
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
847 dnl The results of these tests on various platforms are:
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
848 dnl
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
849 dnl 1 = gl_PRINTF_SIZES_C99
8849
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
850 dnl 2 = gl_PRINTF_LONG_DOUBLE
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
851 dnl 3 = gl_PRINTF_INFINITE
8860
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
852 dnl 4 = gl_PRINTF_INFINITE_LONG_DOUBLE
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
853 dnl 5 = gl_PRINTF_DIRECTIVE_A
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
854 dnl 6 = gl_PRINTF_DIRECTIVE_F
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
855 dnl 7 = gl_PRINTF_DIRECTIVE_N
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
856 dnl 8 = gl_PRINTF_POSITIONS
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
857 dnl 9 = gl_PRINTF_FLAG_GROUPING
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
858 dnl 10 = gl_PRINTF_FLAG_ZERO
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
859 dnl 11 = gl_SNPRINTF_PRESENCE
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
860 dnl 12 = gl_SNPRINTF_TRUNCATION_C99
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
861 dnl 13 = gl_SNPRINTF_RETVAL_C99
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
862 dnl 14 = gl_SNPRINTF_DIRECTIVE_N
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
863 dnl 15 = gl_VSNPRINTF_ZEROSIZE_C99
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
864 dnl
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
865 dnl 1 = checking whether printf supports size specifiers as in C99...
8849
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
866 dnl 2 = checking whether printf supports 'long double' arguments...
c869de19cb7f Swap the tests 2 and 3.
Bruno Haible <bruno@clisp.org>
parents: 8848
diff changeset
867 dnl 3 = checking whether printf supports infinite 'double' arguments...
8860
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
868 dnl 4 = checking whether printf supports infinite 'long double' arguments...
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
869 dnl 5 = checking whether printf supports the 'a' and 'A' directives...
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
870 dnl 6 = checking whether printf supports the 'F' directive...
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
871 dnl 7 = checking whether printf supports the 'n' directive...
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
872 dnl 8 = checking whether printf supports POSIX/XSI format strings with positions...
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
873 dnl 9 = checking whether printf supports the grouping flag...
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
874 dnl 10 = checking whether printf supports the zero flag correctly...
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
875 dnl 11 = checking for snprintf...
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
876 dnl 12 = checking whether snprintf truncates the result as in C99...
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
877 dnl 13 = checking whether snprintf returns a byte count as in C99...
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
878 dnl 14 = checking whether snprintf fully supports the 'n' directive...
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
879 dnl 15 = checking whether vsnprintf respects a zero size as in C99...
8335
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
880 dnl
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
881 dnl . = yes, # = no.
2c9de3b6ba5b New module 'vasnprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
882 dnl
8860
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
883 dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
884 dnl glibc 2.5 . . . . . . . . . . . . . . .
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
885 dnl glibc 2.3.6 . . . . # . . . . . . . . . .
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
886 dnl FreeBSD 5.4, 6.1 . . . . # . . . . # . . . . .
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
887 dnl MacOS X 10.3.9 . . . . # . . . . # . . . . .
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
888 dnl OpenBSD 3.9, 4.0 . ? ? ? # ? . . ? ? . . . ? ?
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
889 dnl Cygwin 2007 (= Cygwin 1.5.24) . ? ? ? # # . . . # . . . . .
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
890 dnl Cygwin 2006 (= Cygwin 1.5.19) # ? ? ? # # . . # # . . . . .
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
891 dnl Solaris 10 . . # # # . . . . # . . . . .
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
892 dnl Solaris 2.6 ... 9 # . # # # # . . . # . . . . .
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
893 dnl Solaris 2.5.1 # . # # # # . . . # # # # # #
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
894 dnl AIX 5.2 . . # # # . . . . # . . . . .
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
895 dnl AIX 4.3.2, 5.1 # . # # # # . . . # . . . . .
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
896 dnl HP-UX 11.31 . . . . # . . . . # . . # # .
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
897 dnl HP-UX 10.20, 11.{00,11,23} # . . . # # . . . # . . # # #
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
898 dnl IRIX 6.5 # . . . # # . . . # . . # . .
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
899 dnl OSF/1 5.1 # . # # # # . . . # . . # . #
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
900 dnl OSF/1 4.0d # . # # # # . . . # # # # # #
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
901 dnl NetBSD 4.0 . ? ? ? ? ? . . ? ? . . . ? ?
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
902 dnl NetBSD 3.0 . . . . # # . # # # . . . . .
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
903 dnl BeOS # # . # # # . # . . . . . . .
771a56a41b5b Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 8849
diff changeset
904 dnl mingw # # # # # # . # # # . # # # .