Mercurial > hg > octave-shane > gnulib-hg
annotate m4/printf.m4 @ 10973:e1a3422c4e90
Add support for universal builds to vasnprintf.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 25 Dec 2008 20:18:10 +0100 |
parents | 7f50373172eb |
children | f6cba5a556ce |
rev | line source |
---|---|
10973
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
1 # printf.m4 serial 25 |
9674
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
2 dnl Copyright (C) 2003, 2007-2008 Free Software Foundation, Inc. |
8335 | 3 dnl This file is free software; the Free Software Foundation |
4 dnl gives unlimited permission to copy and/or distribute it, | |
5 dnl with or without modifications, as long as this notice is preserved. | |
6 | |
7 dnl Test whether the *printf family of functions supports the 'j', 'z', 't', | |
8 dnl 'L' size specifiers. (ISO C99, POSIX:2001) | |
9 dnl Result is gl_cv_func_printf_sizes_c99. | |
10 | |
11 AC_DEFUN([gl_PRINTF_SIZES_C99], | |
12 [ | |
13 AC_REQUIRE([AC_PROG_CC]) | |
14 AC_REQUIRE([gl_AC_HEADER_STDINT_H]) | |
15 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) | |
16 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
17 AC_CACHE_CHECK([whether printf supports size specifiers as in C99], | |
8847 | 18 [gl_cv_func_printf_sizes_c99], |
8335 | 19 [ |
20 AC_TRY_RUN([ | |
21 #include <stddef.h> | |
22 #include <stdio.h> | |
23 #include <string.h> | |
24 #include <sys/types.h> | |
25 #if HAVE_STDINT_H_WITH_UINTMAX | |
26 # include <stdint.h> | |
27 #endif | |
28 #if HAVE_INTTYPES_H_WITH_UINTMAX | |
29 # include <inttypes.h> | |
30 #endif | |
31 static char buf[100]; | |
32 int main () | |
33 { | |
34 #if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX | |
35 buf[0] = '\0'; | |
36 if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0 | |
37 || strcmp (buf, "12345671 33") != 0) | |
38 return 1; | |
39 #endif | |
40 buf[0] = '\0'; | |
41 if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0 | |
42 || strcmp (buf, "12345672 33") != 0) | |
43 return 1; | |
44 buf[0] = '\0'; | |
45 if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0 | |
46 || strcmp (buf, "12345673 33") != 0) | |
47 return 1; | |
48 buf[0] = '\0'; | |
49 if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0 | |
50 || strcmp (buf, "1.5 33") != 0) | |
51 return 1; | |
52 return 0; | |
53 }], [gl_cv_func_printf_sizes_c99=yes], [gl_cv_func_printf_sizes_c99=no], | |
54 [ | |
55 changequote(,)dnl | |
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 | 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 | 60 freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";; |
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 | 63 darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";; |
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 | 66 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) |
67 gl_cv_func_printf_sizes_c99="guessing no";; | |
68 openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; | |
8380
61a6d421d6f2
Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents:
8353
diff
changeset
|
69 # Guess yes on Solaris >= 2.10. |
8335 | 70 solaris2.[0-9]*) gl_cv_func_printf_sizes_c99="guessing no";; |
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 | 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 | 77 *) gl_cv_func_printf_sizes_c99="guessing no";; |
78 esac | |
79 changequote([,])dnl | |
80 ]) | |
81 ]) | |
82 ]) | |
83 | |
8849 | 84 dnl Test whether the *printf family of functions supports 'long double' |
85 dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001) | |
86 dnl Result is gl_cv_func_printf_long_double. | |
87 | |
88 AC_DEFUN([gl_PRINTF_LONG_DOUBLE], | |
89 [ | |
90 AC_REQUIRE([AC_PROG_CC]) | |
91 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
92 AC_CACHE_CHECK([whether printf supports 'long double' arguments], | |
93 [gl_cv_func_printf_long_double], | |
94 [ | |
95 AC_TRY_RUN([ | |
96 #include <stdio.h> | |
97 #include <string.h> | |
9214
39a1b395c333
Make the buffer large enough, to avoid a buffer overflow.
Bruno Haible <bruno@clisp.org>
parents:
8977
diff
changeset
|
98 static char buf[10000]; |
8849 | 99 int main () |
100 { | |
101 buf[0] = '\0'; | |
102 if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0 | |
103 || strcmp (buf, "1.750000 33") != 0) | |
104 return 1; | |
105 buf[0] = '\0'; | |
106 if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0 | |
107 || strcmp (buf, "1.750000e+00 33") != 0) | |
108 return 1; | |
109 buf[0] = '\0'; | |
110 if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0 | |
111 || strcmp (buf, "1.75 33") != 0) | |
112 return 1; | |
113 return 0; | |
114 }], [gl_cv_func_printf_long_double=yes], [gl_cv_func_printf_long_double=no], | |
115 [ | |
116 changequote(,)dnl | |
117 case "$host_os" in | |
118 beos*) gl_cv_func_printf_long_double="guessing no";; | |
119 mingw* | pw*) gl_cv_func_printf_long_double="guessing no";; | |
120 *) gl_cv_func_printf_long_double="guessing yes";; | |
121 esac | |
122 changequote([,])dnl | |
123 ]) | |
124 ]) | |
125 ]) | |
126 | |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
127 dnl Test whether the *printf family of functions supports infinite and NaN |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
128 dnl 'double' arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001) |
8840
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 | 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> |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
141 static int |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
142 strisnan (const char *string, size_t start_index, size_t end_index) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
143 { |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
144 if (start_index < end_index) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
145 { |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
146 if (string[start_index] == '-') |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
147 start_index++; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
148 if (start_index + 3 <= end_index |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
149 && memcmp (string + start_index, "nan", 3) == 0) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
150 { |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
151 start_index += 3; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
152 if (start_index == end_index |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
153 || (string[start_index] == '(' && string[end_index - 1] == ')')) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
154 return 1; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
155 } |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
156 } |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
157 return 0; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
158 } |
9214
39a1b395c333
Make the buffer large enough, to avoid a buffer overflow.
Bruno Haible <bruno@clisp.org>
parents:
8977
diff
changeset
|
159 static char buf[10000]; |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
160 static double zero = 0.0; |
8840
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
161 int main () |
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
162 { |
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
163 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
|
164 || (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
|
165 return 1; |
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
166 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
|
167 || (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
|
168 return 1; |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
169 if (sprintf (buf, "%f", zero / zero) < 0 |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
170 || !strisnan (buf, 0, strlen (buf))) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
171 return 1; |
8840
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
172 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
|
173 || (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
|
174 return 1; |
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
175 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
|
176 || (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
|
177 return 1; |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
178 if (sprintf (buf, "%e", zero / zero) < 0 |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
179 || !strisnan (buf, 0, strlen (buf))) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
180 return 1; |
8840
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
181 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
|
182 || (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
|
183 return 1; |
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
184 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
|
185 || (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
|
186 return 1; |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
187 if (sprintf (buf, "%g", zero / zero) < 0 |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
188 || !strisnan (buf, 0, strlen (buf))) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
189 return 1; |
8840
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
190 return 0; |
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
191 }], [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
|
192 [ |
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
193 changequote(,)dnl |
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
194 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
|
195 # 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
|
196 *-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
|
197 # 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
|
198 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
|
199 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
|
200 # 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
|
201 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
|
202 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
|
203 # 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
|
204 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
|
205 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
|
206 # 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
|
207 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
|
208 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
|
209 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
|
210 # 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
|
211 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
|
212 # 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
|
213 *) 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
|
214 esac |
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
215 changequote([,])dnl |
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
216 ]) |
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
217 ]) |
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
218 ]) |
792e05ae7ac8
Fix *printf result for NaN, Inf, -0.0 on mingw.
Bruno Haible <bruno@clisp.org>
parents:
8832
diff
changeset
|
219 |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
220 dnl Test whether the *printf family of functions supports infinite and NaN |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
221 dnl 'long double' arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001) |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
222 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
|
223 |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
224 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
|
225 [ |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
226 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
|
227 AC_REQUIRE([AC_PROG_CC]) |
8920
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
228 AC_REQUIRE([AC_C_BIGENDIAN]) |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
229 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
8920
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
230 dnl The user can set or unset the variable gl_printf_safe to indicate |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
231 dnl that he wishes a safe handling of non-IEEE-754 'long double' values. |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
232 if test -n "$gl_printf_safe"; then |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
233 AC_DEFINE([CHECK_PRINTF_SAFE], 1, |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
234 [Define if you wish *printf() functions that have a safe handling of |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
235 non-IEEE-754 'long double' values.]) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
236 fi |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
237 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
|
238 *yes) |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
239 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
|
240 [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
|
241 [ |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
242 AC_TRY_RUN([ |
9533
7d6b0049b0a4
Avoid a crash of a configure test on some x86_64 systems.
Bruno Haible <bruno@clisp.org>
parents:
9449
diff
changeset
|
243 ]GL_NOCRASH[ |
8920
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
244 #include <float.h> |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
245 #include <stdio.h> |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
246 #include <string.h> |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
247 static int |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
248 strisnan (const char *string, size_t start_index, size_t end_index) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
249 { |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
250 if (start_index < end_index) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
251 { |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
252 if (string[start_index] == '-') |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
253 start_index++; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
254 if (start_index + 3 <= end_index |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
255 && memcmp (string + start_index, "nan", 3) == 0) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
256 { |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
257 start_index += 3; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
258 if (start_index == end_index |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
259 || (string[start_index] == '(' && string[end_index - 1] == ')')) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
260 return 1; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
261 } |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
262 } |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
263 return 0; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
264 } |
9214
39a1b395c333
Make the buffer large enough, to avoid a buffer overflow.
Bruno Haible <bruno@clisp.org>
parents:
8977
diff
changeset
|
265 static char buf[10000]; |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
266 static long double zeroL = 0.0L; |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
267 int main () |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
268 { |
9533
7d6b0049b0a4
Avoid a crash of a configure test on some x86_64 systems.
Bruno Haible <bruno@clisp.org>
parents:
9449
diff
changeset
|
269 nocrash_init(); |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
270 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
|
271 || (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
|
272 return 1; |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
273 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
|
274 || (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
|
275 return 1; |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
276 if (sprintf (buf, "%Lf", zeroL / zeroL) < 0 |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
277 || !strisnan (buf, 0, strlen (buf))) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
278 return 1; |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
279 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
|
280 || (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
|
281 return 1; |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
282 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
|
283 || (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
|
284 return 1; |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
285 if (sprintf (buf, "%Le", zeroL / zeroL) < 0 |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
286 || !strisnan (buf, 0, strlen (buf))) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
287 return 1; |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
288 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
|
289 || (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
|
290 return 1; |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
291 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
|
292 || (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
|
293 return 1; |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
294 if (sprintf (buf, "%Lg", zeroL / zeroL) < 0 |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
295 || !strisnan (buf, 0, strlen (buf))) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
296 return 1; |
8920
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
297 #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
298 /* Representation of an 80-bit 'long double' as an initializer for a sequence |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
299 of 'unsigned int' words. */ |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
300 # ifdef WORDS_BIGENDIAN |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
301 # define LDBL80_WORDS(exponent,manthi,mantlo) \ |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
302 { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
303 ((unsigned int) (manthi) << 16) | (unsigned int) (mantlo) >> 16), \ |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
304 (unsigned int) (mantlo) << 16 \ |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
305 } |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
306 # else |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
307 # define LDBL80_WORDS(exponent,manthi,mantlo) \ |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
308 { mantlo, manthi, exponent } |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
309 # endif |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
310 { /* Quiet NaN. */ |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
311 static union { unsigned int word[4]; long double value; } x = |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
312 { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
313 if (sprintf (buf, "%Lf", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
314 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
315 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
316 if (sprintf (buf, "%Le", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
317 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
318 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
319 if (sprintf (buf, "%Lg", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
320 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
321 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
322 } |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
323 { |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
324 /* Signalling NaN. */ |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
325 static union { unsigned int word[4]; long double value; } x = |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
326 { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
327 if (sprintf (buf, "%Lf", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
328 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
329 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
330 if (sprintf (buf, "%Le", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
331 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
332 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
333 if (sprintf (buf, "%Lg", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
334 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
335 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
336 } |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
337 { /* Pseudo-NaN. */ |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
338 static union { unsigned int word[4]; long double value; } x = |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
339 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
340 if (sprintf (buf, "%Lf", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
341 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
342 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
343 if (sprintf (buf, "%Le", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
344 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
345 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
346 if (sprintf (buf, "%Lg", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
347 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
348 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
349 } |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
350 { /* Pseudo-Infinity. */ |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
351 static union { unsigned int word[4]; long double value; } x = |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
352 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
353 if (sprintf (buf, "%Lf", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
354 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
355 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
356 if (sprintf (buf, "%Le", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
357 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
358 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
359 if (sprintf (buf, "%Lg", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
360 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
361 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
362 } |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
363 { /* Pseudo-Zero. */ |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
364 static union { unsigned int word[4]; long double value; } x = |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
365 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
366 if (sprintf (buf, "%Lf", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
367 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
368 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
369 if (sprintf (buf, "%Le", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
370 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
371 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
372 if (sprintf (buf, "%Lg", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
373 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
374 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
375 } |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
376 { /* Unnormalized number. */ |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
377 static union { unsigned int word[4]; long double value; } x = |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
378 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
379 if (sprintf (buf, "%Lf", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
380 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
381 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
382 if (sprintf (buf, "%Le", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
383 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
384 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
385 if (sprintf (buf, "%Lg", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
386 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
387 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
388 } |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
389 { /* Pseudo-Denormal. */ |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
390 static union { unsigned int word[4]; long double value; } x = |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
391 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
392 if (sprintf (buf, "%Lf", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
393 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
394 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
395 if (sprintf (buf, "%Le", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
396 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
397 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
398 if (sprintf (buf, "%Lg", x.value) < 0 |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
399 || !strisnan (buf, 0, strlen (buf))) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
400 return 1; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
401 } |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
402 #endif |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
403 return 0; |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
404 }], |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
405 [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
|
406 [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
|
407 [ |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
408 changequote(,)dnl |
8920
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
409 case "$host_cpu" in |
8977
6186374fc70c
x86_64 has the same 'long double' format as i386.
Bruno Haible <bruno@clisp.org>
parents:
8920
diff
changeset
|
410 # Guess no on ia64, x86_64, i386. |
6186374fc70c
x86_64 has the same 'long double' format as i386.
Bruno Haible <bruno@clisp.org>
parents:
8920
diff
changeset
|
411 ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";; |
8920
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
412 *) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
413 case "$host_os" in |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
414 # Guess yes on glibc systems. |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
415 *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
416 # Guess yes on FreeBSD >= 6. |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
417 freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
418 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
419 # Guess yes on MacOS X >= 10.3. |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
420 darwin[1-6].*) gl_cv_func_printf_infinite_long_double="guessing no";; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
421 darwin*) gl_cv_func_printf_infinite_long_double="guessing yes";; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
422 # Guess yes on HP-UX >= 11. |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
423 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
424 hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
425 # Guess yes on NetBSD >= 3. |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
426 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
427 gl_cv_func_printf_infinite_long_double="guessing no";; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
428 netbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
429 # If we don't know, assume the worst. |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
430 *) gl_cv_func_printf_infinite_long_double="guessing no";; |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
431 esac |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
432 ;; |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
433 esac |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
434 changequote([,])dnl |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
435 ]) |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
436 ]) |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
437 ;; |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
438 *) |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
439 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
|
440 ;; |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
441 esac |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
442 ]) |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
443 |
8335 | 444 dnl Test whether the *printf family of functions supports the 'a' and 'A' |
445 dnl conversion specifier for hexadecimal output of floating-point numbers. | |
446 dnl (ISO C99, POSIX:2001) | |
447 dnl Result is gl_cv_func_printf_directive_a. | |
448 | |
449 AC_DEFUN([gl_PRINTF_DIRECTIVE_A], | |
450 [ | |
451 AC_REQUIRE([AC_PROG_CC]) | |
452 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
453 AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives], | |
8847 | 454 [gl_cv_func_printf_directive_a], |
8335 | 455 [ |
456 AC_TRY_RUN([ | |
457 #include <stdio.h> | |
458 #include <string.h> | |
459 static char buf[100]; | |
460 int main () | |
461 { | |
462 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
|
463 || (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
|
464 && 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
|
465 && 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
|
466 && strcmp (buf, "0xc.91p-2 33") != 0)) |
8335 | 467 return 1; |
468 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
|
469 || (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
|
470 && 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
|
471 && 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
|
472 && strcmp (buf, "-0XC.91P-2 33") != 0)) |
8335 | 473 return 1; |
8643
013fc89d552c
Catch a bug of printf "%a" on FreeBSD 6.1.
Bruno Haible <bruno@clisp.org>
parents:
8383
diff
changeset
|
474 /* 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
|
475 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
|
476 || (strcmp (buf, "0x1.83p+0 33") != 0 |
e2189cab039d
The 2007-04-04 patch was broken.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
477 && strcmp (buf, "0x3.05p-1 33") != 0 |
e2189cab039d
The 2007-04-04 patch was broken.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
478 && strcmp (buf, "0x6.0ap-2 33") != 0 |
e2189cab039d
The 2007-04-04 patch was broken.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
479 && 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
|
480 return 1; |
8662
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
481 /* This catches a FreeBSD 6.1 bug. See |
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
482 <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
|
483 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
|
484 || buf[0] == '0') |
8662
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
485 return 1; |
8344
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
486 /* 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
|
487 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
|
488 || (strcmp (buf, "0x1.0p+1") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
489 && strcmp (buf, "0x2.0p+0") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
490 && strcmp (buf, "0x4.0p-1") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
491 && strcmp (buf, "0x8.0p-2") != 0)) |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
492 return 1; |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
493 /* 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
|
494 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
|
495 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
|
496 || (strcmp (buf, "0x1.0p+1") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
497 && strcmp (buf, "0x2.0p+0") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
498 && strcmp (buf, "0x4.0p-1") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
499 && strcmp (buf, "0x8.0p-2") != 0)) |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
500 return 1; |
8335 | 501 return 0; |
502 }], [gl_cv_func_printf_directive_a=yes], [gl_cv_func_printf_directive_a=no], | |
503 [ | |
8344
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
504 case "$host_os" in |
8380
61a6d421d6f2
Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents:
8353
diff
changeset
|
505 # 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
|
506 *-gnu*) |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
507 AC_EGREP_CPP([BZ2908], [ |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
508 #include <features.h> |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
509 #ifdef __GNU_LIBRARY__ |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
510 #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
|
511 BZ2908 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
512 #endif |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
513 #endif |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
514 ], |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
515 [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
|
516 [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
|
517 ;; |
8380
61a6d421d6f2
Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents:
8353
diff
changeset
|
518 # If we don't know, assume the worst. |
8335 | 519 *) gl_cv_func_printf_directive_a="guessing no";; |
520 esac | |
521 ]) | |
522 ]) | |
523 ]) | |
524 | |
8664
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
525 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
|
526 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
|
527 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
|
528 |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
529 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
|
530 [ |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
531 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
|
532 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
|
533 AC_CACHE_CHECK([whether printf supports the 'F' directive], |
8847 | 534 [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
|
535 [ |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
536 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
|
537 #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
|
538 #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
|
539 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
|
540 int main () |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
541 { |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
542 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
|
543 || 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
|
544 return 1; |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
545 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
|
546 || (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
|
547 return 1; |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
548 /* 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
|
549 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
|
550 || 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
|
551 return 1; |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
552 return 0; |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
553 }], [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
|
554 [ |
8666
7ff0dd9e3d4f
Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
8665
diff
changeset
|
555 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
|
556 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
|
557 # 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
|
558 *-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
|
559 # 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
|
560 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
|
561 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
|
562 # 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
|
563 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
|
564 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
|
565 # 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
|
566 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
|
567 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
|
568 # 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
|
569 *) 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
|
570 esac |
8666
7ff0dd9e3d4f
Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
8665
diff
changeset
|
571 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
|
572 ]) |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
573 ]) |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
574 ]) |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
575 |
8335 | 576 dnl Test whether the *printf family of functions supports the %n format |
577 dnl directive. (ISO C99, POSIX:2001) | |
578 dnl Result is gl_cv_func_printf_directive_n. | |
579 | |
580 AC_DEFUN([gl_PRINTF_DIRECTIVE_N], | |
581 [ | |
582 AC_REQUIRE([AC_PROG_CC]) | |
583 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
584 AC_CACHE_CHECK([whether printf supports the 'n' directive], | |
8847 | 585 [gl_cv_func_printf_directive_n], |
8335 | 586 [ |
587 AC_TRY_RUN([ | |
588 #include <stdio.h> | |
589 #include <string.h> | |
9359
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
590 static char fmtstring[10]; |
8335 | 591 static char buf[100]; |
592 int main () | |
593 { | |
594 int count = -1; | |
9359
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
595 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) |
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
596 support %n in format strings in read-only memory but not in writable |
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
597 memory. */ |
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
598 strcpy (fmtstring, "%d %n"); |
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
599 if (sprintf (buf, fmtstring, 123, &count, 33, 44, 55) < 0 |
8335 | 600 || strcmp (buf, "123 ") != 0 |
601 || count != 4) | |
602 return 1; | |
603 return 0; | |
604 }], [gl_cv_func_printf_directive_n=yes], [gl_cv_func_printf_directive_n=no], | |
605 [ | |
606 changequote(,)dnl | |
607 case "$host_os" in | |
608 *) gl_cv_func_printf_directive_n="guessing yes";; | |
609 esac | |
610 changequote([,])dnl | |
611 ]) | |
612 ]) | |
613 ]) | |
614 | |
615 dnl Test whether the *printf family of functions supports POSIX/XSI format | |
616 dnl strings with positions. (POSIX:2001) | |
617 dnl Result is gl_cv_func_printf_positions. | |
618 | |
619 AC_DEFUN([gl_PRINTF_POSITIONS], | |
620 [ | |
621 AC_REQUIRE([AC_PROG_CC]) | |
622 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
623 AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions], | |
8847 | 624 [gl_cv_func_printf_positions], |
8335 | 625 [ |
626 AC_TRY_RUN([ | |
627 #include <stdio.h> | |
628 #include <string.h> | |
629 /* The string "%2$d %1$d", with dollar characters protected from the shell's | |
630 dollar expansion (possibly an autoconf bug). */ | |
631 static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; | |
632 static char buf[100]; | |
633 int main () | |
634 { | |
635 sprintf (buf, format, 33, 55); | |
636 return (strcmp (buf, "55 33") != 0); | |
637 }], [gl_cv_func_printf_positions=yes], [gl_cv_func_printf_positions=no], | |
638 [ | |
639 changequote(,)dnl | |
640 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
|
641 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
|
642 gl_cv_func_printf_positions="guessing no";; |
8335 | 643 beos*) gl_cv_func_printf_positions="guessing no";; |
644 mingw* | pw*) gl_cv_func_printf_positions="guessing no";; | |
645 *) gl_cv_func_printf_positions="guessing yes";; | |
646 esac | |
647 changequote([,])dnl | |
648 ]) | |
649 ]) | |
650 ]) | |
651 | |
8803
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
652 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
|
653 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
|
654 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
|
655 |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
656 AC_DEFUN([gl_PRINTF_FLAG_GROUPING], |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
657 [ |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
658 AC_REQUIRE([AC_PROG_CC]) |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
659 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
|
660 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
|
661 [gl_cv_func_printf_flag_grouping], |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
662 [ |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
663 AC_TRY_RUN([ |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
664 #include <stdio.h> |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
665 #include <string.h> |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
666 static char buf[100]; |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
667 int main () |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
668 { |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
669 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
|
670 || buf[strlen (buf) - 1] != '9') |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
671 return 1; |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
672 return 0; |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
673 }], [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
|
674 [ |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
675 changequote(,)dnl |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
676 case "$host_os" in |
8805 | 677 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
|
678 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
|
679 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
|
680 *) 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
|
681 esac |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
682 changequote([,])dnl |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
683 ]) |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
684 ]) |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
685 ]) |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
686 |
9674
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
687 dnl Test whether the *printf family of functions supports the - flag correctly. |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
688 dnl (ISO C99.) See |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
689 dnl <http://lists.gnu.org/archive/html/bug-coreutils/2008-02/msg00035.html> |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
690 dnl Result is gl_cv_func_printf_flag_leftadjust. |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
691 |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
692 AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST], |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
693 [ |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
694 AC_REQUIRE([AC_PROG_CC]) |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
695 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
696 AC_CACHE_CHECK([whether printf supports the left-adjust flag correctly], |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
697 [gl_cv_func_printf_flag_leftadjust], |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
698 [ |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
699 AC_TRY_RUN([ |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
700 #include <stdio.h> |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
701 #include <string.h> |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
702 static char buf[100]; |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
703 int main () |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
704 { |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
705 /* Check that a '-' flag is not annihilated by a negative width. */ |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
706 if (sprintf (buf, "a%-*sc", -3, "b") < 0 |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
707 || strcmp (buf, "ab c") != 0) |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
708 return 1; |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
709 return 0; |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
710 }], |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
711 [gl_cv_func_printf_flag_leftadjust=yes], |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
712 [gl_cv_func_printf_flag_leftadjust=no], |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
713 [ |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
714 changequote(,)dnl |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
715 case "$host_os" in |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
716 # Guess yes on HP-UX 11. |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
717 hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";; |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
718 # Guess no on HP-UX 10 and older. |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
719 hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";; |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
720 # Guess yes otherwise. |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
721 *) gl_cv_func_printf_flag_leftadjust="guessing yes";; |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
722 esac |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
723 changequote([,])dnl |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
724 ]) |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
725 ]) |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
726 ]) |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
727 |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
728 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
|
729 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
|
730 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
|
731 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
|
732 |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
733 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
|
734 [ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
735 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
|
736 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
|
737 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
|
738 [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
|
739 [ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
740 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
|
741 #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
|
742 #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
|
743 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
|
744 int main () |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
745 { |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
746 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
|
747 || (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
|
748 && 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
|
749 return 1; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
750 return 0; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
751 }], [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
|
752 [ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
753 changequote(,)dnl |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
754 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
|
755 # 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
|
756 *-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
|
757 # 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
|
758 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
|
759 # 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
|
760 *) 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
|
761 esac |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
762 changequote([,])dnl |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
763 ]) |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
764 ]) |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
765 ]) |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
766 |
9446
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
767 dnl Test whether the *printf family of functions supports large precisions. |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
768 dnl On mingw, precisions larger than 512 are treated like 512, in integer, |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
769 dnl floating-point or pointer output. On BeOS, precisions larger than 1044 |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
770 dnl crash the program. |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
771 dnl Result is gl_cv_func_printf_precision. |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
772 |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
773 AC_DEFUN([gl_PRINTF_PRECISION], |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
774 [ |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
775 AC_REQUIRE([AC_PROG_CC]) |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
776 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
777 AC_CACHE_CHECK([whether printf supports large precisions], |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
778 [gl_cv_func_printf_precision], |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
779 [ |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
780 AC_TRY_RUN([ |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
781 #include <stdio.h> |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
782 #include <string.h> |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
783 static char buf[5000]; |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
784 int main () |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
785 { |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
786 #ifdef __BEOS__ |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
787 /* On BeOS, this would crash and show a dialog box. Avoid the crash. */ |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
788 return 1; |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
789 #endif |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
790 if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3) |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
791 return 1; |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
792 return 0; |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
793 }], [gl_cv_func_printf_precision=yes], [gl_cv_func_printf_precision=no], |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
794 [ |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
795 changequote(,)dnl |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
796 case "$host_os" in |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
797 # Guess no only on native Win32 and BeOS systems. |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
798 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
799 beos*) gl_cv_func_printf_precision="guessing no" ;; |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
800 *) gl_cv_func_printf_precision="guessing yes" ;; |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
801 esac |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
802 changequote([,])dnl |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
803 ]) |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
804 ]) |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
805 ]) |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
806 |
9442
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
807 dnl Test whether the *printf family of functions recovers gracefully in case |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
808 dnl of an out-of-memory condition, or whether it crashes the entire program. |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
809 dnl Result is gl_cv_func_printf_enomem. |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
810 |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
811 AC_DEFUN([gl_PRINTF_ENOMEM], |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
812 [ |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
813 AC_REQUIRE([AC_PROG_CC]) |
10973
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
814 AC_REQUIRE([gl_MULTIARCH]) |
9442
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
815 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
816 AC_CACHE_CHECK([whether printf survives out-of-memory conditions], |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
817 [gl_cv_func_printf_enomem], |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
818 [ |
10783
7f50373172eb
Guess that printf on Haiku survives out-of-memory conditions.
Bruno Haible <bruno@clisp.org>
parents:
9940
diff
changeset
|
819 gl_cv_func_printf_enomem="guessing no" |
9442
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
820 if test "$cross_compiling" = no; then |
10973
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
821 if test $APPLE_UNIVERSAL_BUILD = 0; then |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
822 AC_LANG_CONFTEST([AC_LANG_SOURCE([ |
9449
a859a771e88a
Use GL_NOCRASH, to avoid a crashreporter dialog box from a configure check.
Bruno Haible <bruno@clisp.org>
parents:
9446
diff
changeset
|
823 ]GL_NOCRASH[ |
9442
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
824 changequote(,)dnl |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
825 #include <stdio.h> |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
826 #include <sys/types.h> |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
827 #include <sys/time.h> |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
828 #include <sys/resource.h> |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
829 #include <errno.h> |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
830 int main() |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
831 { |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
832 struct rlimit limit; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
833 int ret; |
9449
a859a771e88a
Use GL_NOCRASH, to avoid a crashreporter dialog box from a configure check.
Bruno Haible <bruno@clisp.org>
parents:
9446
diff
changeset
|
834 nocrash_init (); |
9442
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
835 /* Some printf implementations allocate temporary space with malloc. */ |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
836 /* On BSD systems, malloc() is limited by RLIMIT_DATA. */ |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
837 #ifdef RLIMIT_DATA |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
838 if (getrlimit (RLIMIT_DATA, &limit) < 0) |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
839 return 77; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
840 if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
841 limit.rlim_max = 5000000; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
842 limit.rlim_cur = limit.rlim_max; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
843 if (setrlimit (RLIMIT_DATA, &limit) < 0) |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
844 return 77; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
845 #endif |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
846 /* On Linux systems, malloc() is limited by RLIMIT_AS. */ |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
847 #ifdef RLIMIT_AS |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
848 if (getrlimit (RLIMIT_AS, &limit) < 0) |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
849 return 77; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
850 if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
851 limit.rlim_max = 5000000; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
852 limit.rlim_cur = limit.rlim_max; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
853 if (setrlimit (RLIMIT_AS, &limit) < 0) |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
854 return 77; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
855 #endif |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
856 /* Some printf implementations allocate temporary space on the stack. */ |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
857 #ifdef RLIMIT_STACK |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
858 if (getrlimit (RLIMIT_STACK, &limit) < 0) |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
859 return 77; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
860 if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000) |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
861 limit.rlim_max = 5000000; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
862 limit.rlim_cur = limit.rlim_max; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
863 if (setrlimit (RLIMIT_STACK, &limit) < 0) |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
864 return 77; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
865 #endif |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
866 ret = printf ("%.5000000f", 1.0); |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
867 return !(ret == 5000002 || (ret < 0 && errno == ENOMEM)); |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
868 } |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
869 changequote([,])dnl |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
870 ])]) |
10973
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
871 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
872 (./conftest |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
873 result=$? |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
874 if test $result != 0 && test $result != 77; then result=1; fi |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
875 exit $result |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
876 ) >/dev/null 2>/dev/null |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
877 case $? in |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
878 0) gl_cv_func_printf_enomem="yes" ;; |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
879 77) gl_cv_func_printf_enomem="guessing no" ;; |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
880 *) gl_cv_func_printf_enomem="no" ;; |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
881 esac |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
882 else |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
883 gl_cv_func_printf_enomem="guessing no" |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
884 fi |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
885 rm -fr conftest* |
9442
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
886 else |
10973
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
887 dnl A universal build on Apple MacOS X platforms. |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
888 dnl The result would be 'no' in 32-bit mode and 'yes' in 64-bit mode. |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
889 dnl But we need a configuration result that is valid in both modes. |
9442
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
890 gl_cv_func_printf_enomem="guessing no" |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
891 fi |
10783
7f50373172eb
Guess that printf on Haiku survives out-of-memory conditions.
Bruno Haible <bruno@clisp.org>
parents:
9940
diff
changeset
|
892 fi |
7f50373172eb
Guess that printf on Haiku survives out-of-memory conditions.
Bruno Haible <bruno@clisp.org>
parents:
9940
diff
changeset
|
893 if test "$gl_cv_func_printf_enomem" = "guessing no"; then |
9442
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
894 changequote(,)dnl |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
895 case "$host_os" in |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
896 # Guess yes on glibc systems. |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
897 *-gnu*) gl_cv_func_printf_enomem="guessing yes";; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
898 # Guess yes on Solaris. |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
899 solaris*) gl_cv_func_printf_enomem="guessing yes";; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
900 # Guess yes on AIX. |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
901 aix*) gl_cv_func_printf_enomem="guessing yes";; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
902 # Guess yes on HP-UX/hppa. |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
903 hpux*) case "$host_cpu" in |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
904 hppa*) gl_cv_func_printf_enomem="guessing yes";; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
905 *) gl_cv_func_printf_enomem="guessing no";; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
906 esac |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
907 ;; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
908 # Guess yes on IRIX. |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
909 irix*) gl_cv_func_printf_enomem="guessing yes";; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
910 # Guess yes on OSF/1. |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
911 osf*) gl_cv_func_printf_enomem="guessing yes";; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
912 # Guess yes on BeOS. |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
913 beos*) gl_cv_func_printf_enomem="guessing yes";; |
10783
7f50373172eb
Guess that printf on Haiku survives out-of-memory conditions.
Bruno Haible <bruno@clisp.org>
parents:
9940
diff
changeset
|
914 # Guess yes on Haiku. |
7f50373172eb
Guess that printf on Haiku survives out-of-memory conditions.
Bruno Haible <bruno@clisp.org>
parents:
9940
diff
changeset
|
915 haiku*) gl_cv_func_printf_enomem="guessing yes";; |
9442
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
916 # If we don't know, assume the worst. |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
917 *) gl_cv_func_printf_enomem="guessing no";; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
918 esac |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
919 changequote([,])dnl |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
920 fi |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
921 ]) |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
922 ]) |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
923 |
8335 | 924 dnl Test whether the snprintf function exists. (ISO C99, POSIX:2001) |
925 dnl Result is ac_cv_func_snprintf. | |
926 | |
927 AC_DEFUN([gl_SNPRINTF_PRESENCE], | |
928 [ | |
929 AC_CHECK_FUNCS_ONCE([snprintf]) | |
930 ]) | |
931 | |
932 dnl Test whether the string produced by the snprintf function is always NUL | |
933 dnl terminated. (ISO C99, POSIX:2001) | |
934 dnl Result is gl_cv_func_snprintf_truncation_c99. | |
935 | |
936 AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99], | |
937 [ | |
938 AC_REQUIRE([AC_PROG_CC]) | |
939 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
940 AC_CACHE_CHECK([whether snprintf truncates the result as in C99], | |
8847 | 941 [gl_cv_func_snprintf_truncation_c99], |
8335 | 942 [ |
943 AC_TRY_RUN([ | |
944 #include <stdio.h> | |
945 #include <string.h> | |
946 static char buf[100]; | |
947 int main () | |
948 { | |
949 strcpy (buf, "ABCDEF"); | |
950 snprintf (buf, 3, "%d %d", 4567, 89); | |
951 if (memcmp (buf, "45\0DEF", 6) != 0) | |
952 return 1; | |
953 return 0; | |
954 }], [gl_cv_func_snprintf_truncation_c99=yes], [gl_cv_func_snprintf_truncation_c99=no], | |
955 [ | |
956 changequote(,)dnl | |
957 case "$host_os" in | |
8380
61a6d421d6f2
Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents:
8353
diff
changeset
|
958 # Guess yes on glibc systems. |
8335 | 959 *-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
|
960 # Guess yes on FreeBSD >= 5. |
8335 | 961 freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; |
962 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
|
963 # Guess yes on MacOS X >= 10.3. |
8335 | 964 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";; |
965 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
|
966 # Guess yes on OpenBSD >= 3.9. |
8347 | 967 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) |
968 gl_cv_func_snprintf_truncation_c99="guessing no";; | |
969 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
|
970 # Guess yes on Solaris >= 2.6. |
8335 | 971 solaris2.[0-5]*) gl_cv_func_snprintf_truncation_c99="guessing no";; |
972 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
|
973 # Guess yes on AIX >= 4. |
8335 | 974 aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";; |
975 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
|
976 # Guess yes on HP-UX >= 11. |
8335 | 977 hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";; |
978 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
|
979 # Guess yes on IRIX >= 6.5. |
8335 | 980 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
|
981 # Guess yes on OSF/1 >= 5. |
8335 | 982 osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; |
983 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
|
984 # 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
|
985 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
|
986 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
|
987 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
|
988 # Guess yes on BeOS. |
8335 | 989 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
|
990 # If we don't know, assume the worst. |
8335 | 991 *) gl_cv_func_snprintf_truncation_c99="guessing no";; |
992 esac | |
993 changequote([,])dnl | |
994 ]) | |
995 ]) | |
996 ]) | |
997 | |
998 dnl Test whether the return value of the snprintf function is the number | |
999 dnl of bytes (excluding the terminating NUL) that would have been produced | |
1000 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
|
1001 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
|
1002 dnl --------------------------------------------------------------------- |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1003 dnl #include <stdio.h> |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1004 dnl int main() |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1005 dnl { |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1006 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
|
1007 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
|
1008 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
|
1009 dnl } |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1010 dnl --------------------------------------------------------------------- |
8353 | 1011 dnl Result is gl_cv_func_snprintf_retval_c99. |
8335 | 1012 |
1013 AC_DEFUN([gl_SNPRINTF_RETVAL_C99], | |
1014 [ | |
1015 AC_REQUIRE([AC_PROG_CC]) | |
1016 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
1017 AC_CACHE_CHECK([whether snprintf returns a byte count as in C99], | |
8847 | 1018 [gl_cv_func_snprintf_retval_c99], |
8335 | 1019 [ |
1020 AC_TRY_RUN([ | |
1021 #include <stdio.h> | |
1022 #include <string.h> | |
1023 static char buf[100]; | |
1024 int main () | |
1025 { | |
1026 strcpy (buf, "ABCDEF"); | |
1027 if (snprintf (buf, 3, "%d %d", 4567, 89) != 7) | |
1028 return 1; | |
1029 return 0; | |
8353 | 1030 }], [gl_cv_func_snprintf_retval_c99=yes], [gl_cv_func_snprintf_retval_c99=no], |
8335 | 1031 [ |
1032 changequote(,)dnl | |
1033 case "$host_os" in | |
8380
61a6d421d6f2
Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents:
8353
diff
changeset
|
1034 # Guess yes on glibc systems. |
8353 | 1035 *-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
|
1036 # Guess yes on FreeBSD >= 5. |
8353 | 1037 freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";; |
1038 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
|
1039 # Guess yes on MacOS X >= 10.3. |
8353 | 1040 darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";; |
1041 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
|
1042 # Guess yes on OpenBSD >= 3.9. |
8347 | 1043 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) |
8353 | 1044 gl_cv_func_snprintf_retval_c99="guessing no";; |
1045 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
|
1046 # Guess yes on Solaris >= 2.6. |
8353 | 1047 solaris2.[0-5]*) gl_cv_func_snprintf_retval_c99="guessing no";; |
1048 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
|
1049 # Guess yes on AIX >= 4. |
8353 | 1050 aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";; |
1051 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
|
1052 # 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
|
1053 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) |
8353 | 1054 gl_cv_func_snprintf_retval_c99="guessing no";; |
1055 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
|
1056 # Guess yes on BeOS. |
8353 | 1057 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
|
1058 # If we don't know, assume the worst. |
8353 | 1059 *) gl_cv_func_snprintf_retval_c99="guessing no";; |
8335 | 1060 esac |
1061 changequote([,])dnl | |
1062 ]) | |
1063 ]) | |
1064 ]) | |
1065 | |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1066 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
|
1067 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
|
1068 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
|
1069 |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1070 AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N], |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1071 [ |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1072 AC_REQUIRE([AC_PROG_CC]) |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1073 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
|
1074 AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive], |
8847 | 1075 [gl_cv_func_snprintf_directive_n], |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1076 [ |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1077 AC_TRY_RUN([ |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1078 #include <stdio.h> |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1079 #include <string.h> |
9359
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
1080 static char fmtstring[10]; |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1081 static char buf[100]; |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1082 int main () |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1083 { |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1084 int count = -1; |
9359
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
1085 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) |
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
1086 support %n in format strings in read-only memory but not in writable |
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
1087 memory. */ |
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
1088 strcpy (fmtstring, "%d %n"); |
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
1089 snprintf (buf, 4, fmtstring, 12345, &count, 33, 44, 55); |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1090 if (count != 6) |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1091 return 1; |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1092 return 0; |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1093 }], [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
|
1094 [ |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1095 changequote(,)dnl |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1096 case "$host_os" in |
8380
61a6d421d6f2
Make shell snippets copy&pastable.
Bruno Haible <bruno@clisp.org>
parents:
8353
diff
changeset
|
1097 # Guess yes on glibc systems. |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1098 *-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
|
1099 # Guess yes on FreeBSD >= 5. |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1100 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
|
1101 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
|
1102 # 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
|
1103 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
|
1104 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
|
1105 # Guess yes on Solaris >= 2.6. |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1106 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
|
1107 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
|
1108 # Guess yes on AIX >= 4. |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1109 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
|
1110 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
|
1111 # Guess yes on IRIX >= 6.5. |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1112 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
|
1113 # Guess yes on OSF/1 >= 5. |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1114 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
|
1115 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
|
1116 # Guess yes on NetBSD >= 3. |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1117 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
|
1118 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
|
1119 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
|
1120 # Guess yes on BeOS. |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1121 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
|
1122 # 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
|
1123 *) 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
|
1124 esac |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1125 changequote([,])dnl |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1126 ]) |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1127 ]) |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1128 ]) |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1129 |
9940
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1130 dnl Test whether the snprintf function, when passed a size = 1, writes any |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1131 dnl output without bounds in this case, behaving like sprintf. This is the |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1132 dnl case on Linux libc5. |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1133 dnl Result is gl_cv_func_snprintf_size1. |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1134 |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1135 AC_DEFUN([gl_SNPRINTF_SIZE1], |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1136 [ |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1137 AC_REQUIRE([AC_PROG_CC]) |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1138 AC_CACHE_CHECK([whether snprintf respects a size of 1], |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1139 [gl_cv_func_snprintf_size1], |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1140 [ |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1141 AC_TRY_RUN([ |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1142 #include <stdio.h> |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1143 int main() |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1144 { |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1145 static char buf[8] = "DEADBEEF"; |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1146 snprintf (buf, 1, "%d", 12345); |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1147 return buf[1] != 'E'; |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1148 }], |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1149 [gl_cv_func_snprintf_size1=yes], |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1150 [gl_cv_func_snprintf_size1=no], |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1151 [gl_cv_func_snprintf_size1="guessing yes"]) |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1152 ]) |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1153 ]) |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1154 |
8763
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1155 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
|
1156 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
|
1157 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
|
1158 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
|
1159 dnl --------------------------------------------------------------------- |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1160 dnl #include <stdio.h> |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1161 dnl int main() |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1162 dnl { |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1163 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
|
1164 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
|
1165 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
|
1166 dnl } |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1167 dnl --------------------------------------------------------------------- |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1168 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
|
1169 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
|
1170 dnl --------------------------------------------------------------------- |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1171 dnl #include <stdarg.h> |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1172 dnl #include <stdio.h> |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1173 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
|
1174 dnl { |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1175 dnl va_list args; |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1176 dnl int ret; |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1177 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
|
1178 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
|
1179 dnl va_end (args); |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1180 dnl return ret; |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1181 dnl } |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1182 dnl int main() |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1183 dnl { |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1184 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
|
1185 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
|
1186 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
|
1187 dnl } |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1188 dnl --------------------------------------------------------------------- |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1189 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
|
1190 |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1191 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
|
1192 [ |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1193 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
|
1194 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
|
1195 AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99], |
8847 | 1196 [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
|
1197 [ |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1198 AC_TRY_RUN([ |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1199 #include <stdarg.h> |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1200 #include <stdio.h> |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1201 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
|
1202 { |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1203 va_list args; |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1204 int ret; |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1205 va_start (args, format); |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1206 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
|
1207 va_end (args); |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1208 return ret; |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1209 } |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1210 int main() |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1211 { |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1212 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
|
1213 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
|
1214 return buf[0] != 'D'; |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1215 }], |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1216 [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
|
1217 [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
|
1218 [ |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1219 changequote(,)dnl |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1220 case "$host_os" in |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1221 # 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
|
1222 *-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
|
1223 # 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
|
1224 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
|
1225 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
|
1226 # 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
|
1227 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
|
1228 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; |
8805 | 1229 # Guess yes on Cygwin. |
1230 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
|
1231 # 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
|
1232 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
|
1233 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
|
1234 # 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
|
1235 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
|
1236 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
|
1237 # 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
|
1238 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
|
1239 # 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
|
1240 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
|
1241 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
|
1242 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
|
1243 # Guess yes on BeOS. |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1244 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
|
1245 # Guess yes on mingw. |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1246 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
|
1247 # 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
|
1248 *) 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
|
1249 esac |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1250 changequote([,])dnl |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1251 ]) |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1252 ]) |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1253 ]) |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1254 |
8335 | 1255 dnl The results of these tests on various platforms are: |
1256 dnl | |
1257 dnl 1 = gl_PRINTF_SIZES_C99 | |
8849 | 1258 dnl 2 = gl_PRINTF_LONG_DOUBLE |
1259 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
|
1260 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
|
1261 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
|
1262 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
|
1263 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
|
1264 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
|
1265 dnl 9 = gl_PRINTF_FLAG_GROUPING |
9674
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1266 dnl 10 = gl_PRINTF_FLAG_LEFTADJUST |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1267 dnl 11 = gl_PRINTF_FLAG_ZERO |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1268 dnl 12 = gl_PRINTF_PRECISION |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1269 dnl 13 = gl_PRINTF_ENOMEM |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1270 dnl 14 = gl_SNPRINTF_PRESENCE |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1271 dnl 15 = gl_SNPRINTF_TRUNCATION_C99 |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1272 dnl 16 = gl_SNPRINTF_RETVAL_C99 |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1273 dnl 17 = gl_SNPRINTF_DIRECTIVE_N |
9940
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1274 dnl 18 = gl_SNPRINTF_SIZE1 |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1275 dnl 19 = gl_VSNPRINTF_ZEROSIZE_C99 |
8335 | 1276 dnl |
1277 dnl 1 = checking whether printf supports size specifiers as in C99... | |
8849 | 1278 dnl 2 = checking whether printf supports 'long double' arguments... |
1279 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
|
1280 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
|
1281 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
|
1282 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
|
1283 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
|
1284 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
|
1285 dnl 9 = checking whether printf supports the grouping flag... |
9674
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1286 dnl 10 = checking whether printf supports the left-adjust flag correctly... |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1287 dnl 11 = checking whether printf supports the zero flag correctly... |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1288 dnl 12 = checking whether printf supports large precisions... |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1289 dnl 13 = checking whether printf survives out-of-memory conditions... |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1290 dnl 14 = checking for snprintf... |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1291 dnl 15 = checking whether snprintf truncates the result as in C99... |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1292 dnl 16 = checking whether snprintf returns a byte count as in C99... |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
1293 dnl 17 = checking whether snprintf fully supports the 'n' directive... |
9940
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1294 dnl 18 = checking whether snprintf respects a size of 1... |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1295 dnl 19 = checking whether vsnprintf respects a zero size as in C99... |
8335 | 1296 dnl |
1297 dnl . = yes, # = no. | |
1298 dnl | |
9940
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1299 dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1300 dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1301 dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1302 dnl FreeBSD 5.4, 6.1 . . . . # . . . . . # . # . . . . . . |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1303 dnl MacOS X 10.3.9 . . . . # . . . . . # . # . . . . . . |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1304 dnl OpenBSD 3.9, 4.0 . . # # # # . . # . # . # . . . . . . |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1305 dnl Cygwin 2007 (= Cygwin 1.5.24) . . . . # # . . . ? # ? ? . . . . . . |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1306 dnl Cygwin 2006 (= Cygwin 1.5.19) # . . . # # . . # ? # ? ? . . . . . . |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1307 dnl Solaris 10 . . # # # . . . . . # . . . . . . . . |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1308 dnl Solaris 2.6 ... 9 # . # # # # . . . . # . . . . . . . . |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1309 dnl Solaris 2.5.1 # . # # # # . . . . # . . # # # # # # |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1310 dnl AIX 5.2 . . # # # . . . . . # . . . . . . . . |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1311 dnl AIX 4.3.2, 5.1 # . # # # # . . . . # . . . . . . . . |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1312 dnl HP-UX 11.31 . . . . # . . . . . # . . . . # # . . |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1313 dnl HP-UX 11.{00,11,23} # . . . # # . . . . # . . . . # # . # |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1314 dnl HP-UX 10.20 # . . . # # . . . # # . . . . # # ? # |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1315 dnl IRIX 6.5 # . # # # # . . . . # . . . . # . . . |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1316 dnl OSF/1 5.1 # . # # # # . . . . # . . . . # . . # |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1317 dnl OSF/1 4.0d # . # # # # . . . . # . . # # # # # # |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1318 dnl NetBSD 4.0 . ? ? ? ? ? . . ? ? ? ? ? . . . ? ? ? |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1319 dnl NetBSD 3.0 . . . . # # . # # ? # . # . . . . . . |
10783
7f50373172eb
Guess that printf on Haiku survives out-of-memory conditions.
Bruno Haible <bruno@clisp.org>
parents:
9940
diff
changeset
|
1320 dnl Haiku . . . # # # . . . . . . ? . . . . . . |
9940
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1321 dnl BeOS # # . # # # . # . ? . # ? . . . . . . |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1322 dnl mingw # # # # # # . # # . # # ? . # # # . . |