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