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