Mercurial > hg > octave-shane > gnulib-hg
annotate m4/printf.m4 @ 8351:3c87bcef59c2
Mention glibc-2.5.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 05 Mar 2007 23:51:20 +0000 |
parents | 4e430e6470b3 |
children | 741f8a5caa9c |
rev | line source |
---|---|
8335 | 1 # printf.m4 serial 1 |
2 dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc. | |
3 dnl This file is free software; the Free Software Foundation | |
4 dnl gives unlimited permission to copy and/or distribute it, | |
5 dnl with or without modifications, as long as this notice is preserved. | |
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([gt_TYPE_LONGDOUBLE]) | |
17 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
18 AC_CACHE_CHECK([whether printf supports size specifiers as in C99], | |
19 [gl_cv_func_printf_sizes_c99], | |
20 [ | |
21 AC_TRY_RUN([ | |
22 #include <stddef.h> | |
23 #include <stdio.h> | |
24 #include <string.h> | |
25 #include <sys/types.h> | |
26 #if HAVE_STDINT_H_WITH_UINTMAX | |
27 # include <stdint.h> | |
28 #endif | |
29 #if HAVE_INTTYPES_H_WITH_UINTMAX | |
30 # include <inttypes.h> | |
31 #endif | |
32 static char buf[100]; | |
33 int main () | |
34 { | |
35 #if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX | |
36 buf[0] = '\0'; | |
37 if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0 | |
38 || strcmp (buf, "12345671 33") != 0) | |
39 return 1; | |
40 #endif | |
41 buf[0] = '\0'; | |
42 if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0 | |
43 || strcmp (buf, "12345672 33") != 0) | |
44 return 1; | |
45 buf[0] = '\0'; | |
46 if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0 | |
47 || strcmp (buf, "12345673 33") != 0) | |
48 return 1; | |
49 #if HAVE_LONG_DOUBLE | |
50 buf[0] = '\0'; | |
51 if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0 | |
52 || strcmp (buf, "1.5 33") != 0) | |
53 return 1; | |
54 #endif | |
55 return 0; | |
56 }], [gl_cv_func_printf_sizes_c99=yes], [gl_cv_func_printf_sizes_c99=no], | |
57 [ | |
58 changequote(,)dnl | |
59 case "$host_os" in | |
60 dnl Guess yes on glibc systems. | |
61 *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; | |
62 dnl Guess yes on FreeBSD >= 5. | |
63 freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";; | |
64 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; | |
8347 | 65 dnl Guess yes on MacOS X >= 10.3. |
8335 | 66 darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";; |
67 darwin*) gl_cv_func_printf_sizes_c99="guessing yes";; | |
8347 | 68 dnl Guess yes on OpenBSD >= 3.9. |
69 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) | |
70 gl_cv_func_printf_sizes_c99="guessing no";; | |
71 openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; | |
8335 | 72 dnl Guess yes on Solaris >= 2.10. |
73 solaris2.[0-9]*) gl_cv_func_printf_sizes_c99="guessing no";; | |
74 solaris*) gl_cv_func_printf_sizes_c99="guessing yes";; | |
75 dnl 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
|
76 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
|
77 gl_cv_func_printf_sizes_c99="guessing no";; |
8335 | 78 netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; |
79 dnl If we don't know, assume the worst. | |
80 *) gl_cv_func_printf_sizes_c99="guessing no";; | |
81 esac | |
82 changequote([,])dnl | |
83 ]) | |
84 ]) | |
85 ]) | |
86 | |
87 dnl Test whether the *printf family of functions supports the 'a' and 'A' | |
88 dnl conversion specifier for hexadecimal output of floating-point numbers. | |
89 dnl (ISO C99, POSIX:2001) | |
90 dnl Result is gl_cv_func_printf_directive_a. | |
91 | |
92 AC_DEFUN([gl_PRINTF_DIRECTIVE_A], | |
93 [ | |
94 AC_REQUIRE([AC_PROG_CC]) | |
8344
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
95 AC_REQUIRE([gt_TYPE_LONGDOUBLE]) |
8335 | 96 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
97 AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives], | |
98 [gl_cv_func_printf_directive_a], | |
99 [ | |
100 AC_TRY_RUN([ | |
101 #include <stdio.h> | |
102 #include <string.h> | |
103 static char buf[100]; | |
104 int main () | |
105 { | |
106 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
|
107 || (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
|
108 && 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
|
109 && 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
|
110 && strcmp (buf, "0xc.91p-2 33") != 0)) |
8335 | 111 return 1; |
112 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
|
113 || (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
|
114 && 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
|
115 && 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
|
116 && strcmp (buf, "-0XC.91P-2 33") != 0)) |
8335 | 117 return 1; |
8344
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
118 /* 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
|
119 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
|
120 || (strcmp (buf, "0x1.0p+1") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
121 && strcmp (buf, "0x2.0p+0") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
122 && strcmp (buf, "0x4.0p-1") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
123 && strcmp (buf, "0x8.0p-2") != 0)) |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
124 return 1; |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
125 #if HAVE_LONG_DOUBLE |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
126 /* 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
|
127 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
|
128 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
|
129 || (strcmp (buf, "0x1.0p+1") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
130 && strcmp (buf, "0x2.0p+0") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
131 && strcmp (buf, "0x4.0p-1") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
132 && strcmp (buf, "0x8.0p-2") != 0)) |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
133 return 1; |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
134 #endif |
8335 | 135 return 0; |
136 }], [gl_cv_func_printf_directive_a=yes], [gl_cv_func_printf_directive_a=no], | |
137 [ | |
8344
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
138 case "$host_os" in |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
139 dnl Guess yes on glibc >= 2.5 systems. |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
140 *-gnu*) |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
141 AC_EGREP_CPP([BZ2908], [ |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
142 #include <features.h> |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
143 #ifdef __GNU_LIBRARY__ |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
144 #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
|
145 BZ2908 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
146 #endif |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
147 #endif |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
148 ], |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
149 [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
|
150 [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
|
151 ;; |
8335 | 152 changequote(,)dnl |
153 dnl Guess yes on FreeBSD >= 5. | |
154 freebsd[1-4]*) gl_cv_func_printf_directive_a="guessing no";; | |
155 freebsd* | kfreebsd*) gl_cv_func_printf_directive_a="guessing yes";; | |
8349
d1f886e7c41b
Add info about NetBSD 4, which has now borrowed the printf implementation
Bruno Haible <bruno@clisp.org>
parents:
8348
diff
changeset
|
156 dnl Guess yes on NetBSD >= 4. |
8350
4e430e6470b3
Be more conservative about the config.guess results on NetBSD.
Bruno Haible <bruno@clisp.org>
parents:
8349
diff
changeset
|
157 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
|
158 gl_cv_func_printf_directive_a="guessing no";; |
8349
d1f886e7c41b
Add info about NetBSD 4, which has now borrowed the printf implementation
Bruno Haible <bruno@clisp.org>
parents:
8348
diff
changeset
|
159 netbsd*) gl_cv_func_printf_directive_a="guessing yes";; |
8335 | 160 dnl If we don't know, assume the worst. |
161 *) gl_cv_func_printf_directive_a="guessing no";; | |
162 esac | |
163 changequote([,])dnl | |
164 ]) | |
165 ]) | |
166 ]) | |
167 | |
168 dnl Test whether the *printf family of functions supports the %n format | |
169 dnl directive. (ISO C99, POSIX:2001) | |
170 dnl Result is gl_cv_func_printf_directive_n. | |
171 | |
172 AC_DEFUN([gl_PRINTF_DIRECTIVE_N], | |
173 [ | |
174 AC_REQUIRE([AC_PROG_CC]) | |
175 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
176 AC_CACHE_CHECK([whether printf supports the 'n' directive], | |
177 [gl_cv_func_printf_directive_n], | |
178 [ | |
179 AC_TRY_RUN([ | |
180 #include <stdio.h> | |
181 #include <string.h> | |
182 static char buf[100]; | |
183 int main () | |
184 { | |
185 int count = -1; | |
186 if (sprintf (buf, "%d %n", 123, &count, 33, 44, 55) < 0 | |
187 || strcmp (buf, "123 ") != 0 | |
188 || count != 4) | |
189 return 1; | |
190 return 0; | |
191 }], [gl_cv_func_printf_directive_n=yes], [gl_cv_func_printf_directive_n=no], | |
192 [ | |
193 changequote(,)dnl | |
194 case "$host_os" in | |
195 *) gl_cv_func_printf_directive_n="guessing yes";; | |
196 esac | |
197 changequote([,])dnl | |
198 ]) | |
199 ]) | |
200 ]) | |
201 | |
202 dnl Test whether the *printf family of functions supports POSIX/XSI format | |
203 dnl strings with positions. (POSIX:2001) | |
204 dnl Result is gl_cv_func_printf_positions. | |
205 | |
206 AC_DEFUN([gl_PRINTF_POSITIONS], | |
207 [ | |
208 AC_REQUIRE([AC_PROG_CC]) | |
209 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
210 AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions], | |
211 [gl_cv_func_printf_positions], | |
212 [ | |
213 AC_TRY_RUN([ | |
214 #include <stdio.h> | |
215 #include <string.h> | |
216 /* The string "%2$d %1$d", with dollar characters protected from the shell's | |
217 dollar expansion (possibly an autoconf bug). */ | |
218 static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; | |
219 static char buf[100]; | |
220 int main () | |
221 { | |
222 sprintf (buf, format, 33, 55); | |
223 return (strcmp (buf, "55 33") != 0); | |
224 }], [gl_cv_func_printf_positions=yes], [gl_cv_func_printf_positions=no], | |
225 [ | |
226 changequote(,)dnl | |
227 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
|
228 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
|
229 gl_cv_func_printf_positions="guessing no";; |
8335 | 230 beos*) gl_cv_func_printf_positions="guessing no";; |
231 mingw* | pw*) gl_cv_func_printf_positions="guessing no";; | |
232 *) gl_cv_func_printf_positions="guessing yes";; | |
233 esac | |
234 changequote([,])dnl | |
235 ]) | |
236 ]) | |
237 ]) | |
238 | |
239 dnl Test whether the snprintf function exists. (ISO C99, POSIX:2001) | |
240 dnl Result is ac_cv_func_snprintf. | |
241 | |
242 AC_DEFUN([gl_SNPRINTF_PRESENCE], | |
243 [ | |
244 AC_CHECK_FUNCS_ONCE([snprintf]) | |
245 ]) | |
246 | |
247 dnl Test whether the string produced by the snprintf function is always NUL | |
248 dnl terminated. (ISO C99, POSIX:2001) | |
249 dnl Result is gl_cv_func_snprintf_truncation_c99. | |
250 | |
251 AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99], | |
252 [ | |
253 AC_REQUIRE([AC_PROG_CC]) | |
254 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
255 AC_CACHE_CHECK([whether snprintf truncates the result as in C99], | |
256 [gl_cv_func_snprintf_truncation_c99], | |
257 [ | |
258 AC_TRY_RUN([ | |
259 #include <stdio.h> | |
260 #include <string.h> | |
261 static char buf[100]; | |
262 int main () | |
263 { | |
264 strcpy (buf, "ABCDEF"); | |
265 snprintf (buf, 3, "%d %d", 4567, 89); | |
266 if (memcmp (buf, "45\0DEF", 6) != 0) | |
267 return 1; | |
268 return 0; | |
269 }], [gl_cv_func_snprintf_truncation_c99=yes], [gl_cv_func_snprintf_truncation_c99=no], | |
270 [ | |
271 changequote(,)dnl | |
272 case "$host_os" in | |
273 dnl Guess yes on glibc systems. | |
274 *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; | |
275 dnl Guess yes on FreeBSD >= 5. | |
276 freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; | |
277 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; | |
8347 | 278 dnl Guess yes on MacOS X >= 10.3. |
8335 | 279 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";; |
280 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";; | |
8347 | 281 dnl Guess yes on OpenBSD >= 3.9. |
282 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) | |
283 gl_cv_func_snprintf_truncation_c99="guessing no";; | |
284 openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; | |
8335 | 285 dnl Guess yes on Solaris >= 2.6. |
286 solaris2.[0-5]*) gl_cv_func_snprintf_truncation_c99="guessing no";; | |
287 solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";; | |
288 dnl Guess yes on AIX >= 4. | |
289 aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";; | |
290 aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";; | |
291 dnl Guess yes on HP-UX >= 11. | |
292 hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";; | |
293 hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";; | |
294 dnl Guess yes on IRIX >= 6.5. | |
295 irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";; | |
296 dnl Guess yes on OSF/1 >= 5. | |
297 osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; | |
298 osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";; | |
299 dnl 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
|
300 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
|
301 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
|
302 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; |
8335 | 303 dnl Guess yes on BeOS. |
304 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";; | |
305 dnl If we don't know, assume the worst. | |
306 *) gl_cv_func_snprintf_truncation_c99="guessing no";; | |
307 esac | |
308 changequote([,])dnl | |
309 ]) | |
310 ]) | |
311 ]) | |
312 | |
313 dnl Test whether the return value of the snprintf function is the number | |
314 dnl of bytes (excluding the terminating NUL) that would have been produced | |
315 dnl if the buffer had been large enough. (ISO C99, POSIX:2001) | |
316 dnl Result is gl_cv_func_printf_retval_c99. | |
317 | |
318 AC_DEFUN([gl_SNPRINTF_RETVAL_C99], | |
319 [ | |
320 AC_REQUIRE([AC_PROG_CC]) | |
321 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
322 AC_CACHE_CHECK([whether snprintf returns a byte count as in C99], | |
323 [gl_cv_func_printf_retval_c99], | |
324 [ | |
325 AC_TRY_RUN([ | |
326 #include <stdio.h> | |
327 #include <string.h> | |
328 static char buf[100]; | |
329 int main () | |
330 { | |
331 strcpy (buf, "ABCDEF"); | |
332 if (snprintf (buf, 3, "%d %d", 4567, 89) != 7) | |
333 return 1; | |
334 return 0; | |
335 }], [gl_cv_func_printf_retval_c99=yes], [gl_cv_func_printf_retval_c99=no], | |
336 [ | |
337 changequote(,)dnl | |
338 case "$host_os" in | |
339 dnl Guess yes on glibc systems. | |
340 *-gnu*) gl_cv_func_printf_retval_c99="guessing yes";; | |
341 dnl Guess yes on FreeBSD >= 5. | |
342 freebsd[1-4]*) gl_cv_func_printf_retval_c99="guessing no";; | |
343 freebsd* | kfreebsd*) gl_cv_func_printf_retval_c99="guessing yes";; | |
8347 | 344 dnl Guess yes on MacOS X >= 10.3. |
8335 | 345 darwin[1-6].*) gl_cv_func_printf_retval_c99="guessing no";; |
346 darwin*) gl_cv_func_printf_retval_c99="guessing yes";; | |
8347 | 347 dnl Guess yes on OpenBSD >= 3.9. |
348 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) | |
349 gl_cv_func_printf_retval_c99="guessing no";; | |
350 openbsd*) gl_cv_func_printf_retval_c99="guessing yes";; | |
8335 | 351 dnl Guess yes on Solaris >= 2.6. |
352 solaris2.[0-5]*) gl_cv_func_printf_retval_c99="guessing no";; | |
353 solaris*) gl_cv_func_printf_retval_c99="guessing yes";; | |
354 dnl Guess yes on AIX >= 4. | |
355 aix[1-3]*) gl_cv_func_printf_retval_c99="guessing no";; | |
356 aix*) gl_cv_func_printf_retval_c99="guessing yes";; | |
357 dnl 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
|
358 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
|
359 gl_cv_func_printf_retval_c99="guessing no";; |
8335 | 360 netbsd*) gl_cv_func_printf_retval_c99="guessing yes";; |
361 dnl Guess yes on BeOS. | |
362 beos*) gl_cv_func_printf_retval_c99="guessing yes";; | |
363 dnl If we don't know, assume the worst. | |
364 *) gl_cv_func_printf_retval_c99="guessing no";; | |
365 esac | |
366 changequote([,])dnl | |
367 ]) | |
368 ]) | |
369 ]) | |
370 | |
371 dnl The results of these tests on various platforms are: | |
372 dnl | |
373 dnl 1 = gl_PRINTF_SIZES_C99 | |
374 dnl 2 = gl_PRINTF_DIRECTIVE_A | |
375 dnl 3 = gl_PRINTF_DIRECTIVE_N | |
376 dnl 4 = gl_PRINTF_POSITIONS | |
377 dnl 5 = gl_SNPRINTF_PRESENCE | |
378 dnl 6 = gl_SNPRINTF_TRUNCATION_C99 | |
379 dnl 7 = gl_SNPRINTF_RETVAL_C99 | |
380 dnl | |
381 dnl 1 = checking whether printf supports size specifiers as in C99... | |
382 dnl 2 = checking whether printf supports the 'a' and 'A' directives... | |
383 dnl 3 = checking whether printf supports the 'n' directive... | |
384 dnl 4 = checking whether printf supports POSIX/XSI format strings with positions... | |
385 dnl 5 = checking for snprintf... | |
386 dnl 6 = checking whether snprintf truncates the result as in C99... | |
387 dnl 7 = checking whether snprintf returns a byte count as in C99... | |
388 dnl | |
389 dnl . = yes, # = no. | |
390 dnl | |
8348
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
391 dnl 1 2 3 4 5 6 7 |
8351 | 392 dnl glibc 2.5 . . . . . . . |
8348
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
393 dnl glibc 2.3.6 . # . . . . . |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
394 dnl FreeBSD 5.4, 6.1 . . . . . . . |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
395 dnl MacOS X 10.3.9 . # . . . . . |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
396 dnl OpenBSD 3.9 . # . . . . . |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
397 dnl Cygwin 2007 . # . . . . . |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
398 dnl Cygwin 2006 # # . . . . . |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
399 dnl Solaris 10 . # . . . . . |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
400 dnl Solaris 2.6 ... 9 # # . . . . . |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
401 dnl Solaris 2.5.1 # # . . # # # |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
402 dnl AIX 4.3.2, 5.1 # # . . . . . |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
403 dnl HP-UX 11.31 . # . . . . # |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
404 dnl HP-UX 10.20, 11.00, 11.11, 11.23 # # . . . . # |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
405 dnl IRIX 6.5 # # . . . . # |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
406 dnl OSF/1 5.1 # # . . . . # |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
407 dnl OSF/1 4.0d # # . . # # # |
8349
d1f886e7c41b
Add info about NetBSD 4, which has now borrowed the printf implementation
Bruno Haible <bruno@clisp.org>
parents:
8348
diff
changeset
|
408 dnl NetBSD 4.0 . . . . . . . |
8348
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
409 dnl NetBSD 3.0 . # . # . . . |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
410 dnl BeOS # # . # . . . |
9ee2a6750282
Update with info about HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
8347
diff
changeset
|
411 dnl mingw # # . # . # # |