Mercurial > hg > octave-shane > gnulib-hg
annotate m4/printf.m4 @ 15905:53e09ee0d19a
*printf: Fix for platforms where 'long double' == 'double'.
* m4/printf.m4 (gl_PRINTF_INFINITE_LONG_DOUBLE): Require
gl_LONG_DOUBLE_VS_DOUBLE. Don't blindly assume 80-bit 'long double'.
* modules/dprintf-posix (Files): Add m4/math_h.m4.
* modules/fprintf-posix (Files): Likewise.
* modules/obstack-printf-posix (Files): Likewise.
* modules/snprintf-posix (Files): Likewise.
* modules/sprintf-posix (Files): Likewise.
* modules/vasnprintf (Files): Likewise.
* modules/vasnprintf-posix (Files): Likewise.
* modules/vasprintf-posix (Files): Likewise.
* modules/vdprintf-posix (Files): Likewise.
* modules/vfprintf-posix (Files): Likewise.
* modules/vsnprintf-posix (Files): Likewise.
* modules/vsprintf-posix (Files): Likewise.
* modules/unistdio/u8-vasnprintf (Files): Likewise.
* modules/unistdio/u8-u8-vasnprintf (Files): Likewise.
* modules/unistdio/u16-vasnprintf (Files): Likewise.
* modules/unistdio/u16-u16-vasnprintf (Files): Likewise.
* modules/unistdio/u32-vasnprintf (Files): Likewise.
* modules/unistdio/u32-u32-vasnprintf (Files): Likewise.
* modules/unistdio/ulc-vasnprintf (Files): Likewise.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 09 Oct 2011 13:06:52 +0200 |
parents | 328819af1c02 |
children | 8250f2777afc |
rev | line source |
---|---|
15905
53e09ee0d19a
*printf: Fix for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
15595
diff
changeset
|
1 # printf.m4 serial 46 |
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; |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
181 if (sprintf (buf, "%f", 1.0 / zero) < 0 |
8840
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; |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
184 if (sprintf (buf, "%f", -1.0 / zero) < 0 |
8840
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; |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
190 if (sprintf (buf, "%e", 1.0 / zero) < 0 |
8840
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; |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
193 if (sprintf (buf, "%e", -1.0 / zero) < 0 |
8840
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; |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
199 if (sprintf (buf, "%g", 1.0 / zero) < 0 |
8840
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; |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
202 if (sprintf (buf, "%g", -1.0 / zero) < 0 |
8840
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]) |
15905
53e09ee0d19a
*printf: Fix for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
15595
diff
changeset
|
254 AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
255 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
|
256 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
|
257 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
|
258 if test -n "$gl_printf_safe"; then |
11007
f6cba5a556ce
many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents:
10973
diff
changeset
|
259 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
|
260 [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
|
261 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
|
262 fi |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
263 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
|
264 *yes) |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
265 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
|
266 [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
|
267 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
268 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
269 [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
|
270 ]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
|
271 #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
|
272 #include <stdio.h> |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
273 #include <string.h> |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
274 static int |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
275 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
|
276 { |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
277 if (start_index < end_index) |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
278 { |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
279 if (string[start_index] == '-') |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
280 start_index++; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
281 if (start_index + 3 <= end_index |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
282 && 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
|
283 { |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
284 start_index += 3; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
285 if (start_index == end_index |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
286 || (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
|
287 return 1; |
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 } |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
290 return 0; |
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
291 } |
9214
39a1b395c333
Make the buffer large enough, to avoid a buffer overflow.
Bruno Haible <bruno@clisp.org>
parents:
8977
diff
changeset
|
292 static char buf[10000]; |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
293 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
|
294 int main () |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
295 { |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13917
diff
changeset
|
296 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
|
297 nocrash_init(); |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
298 if (sprintf (buf, "%Lf", 1.0L / zeroL) < 0 |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
299 || (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
|
300 result |= 1; |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
301 if (sprintf (buf, "%Lf", -1.0L / zeroL) < 0 |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
302 || (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
|
303 result |= 1; |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
304 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
|
305 || !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
|
306 result |= 1; |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
307 if (sprintf (buf, "%Le", 1.0L / zeroL) < 0 |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
308 || (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
|
309 result |= 1; |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
310 if (sprintf (buf, "%Le", -1.0L / zeroL) < 0 |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
311 || (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
|
312 result |= 1; |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
313 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
|
314 || !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
|
315 result |= 1; |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
316 if (sprintf (buf, "%Lg", 1.0L / zeroL) < 0 |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
317 || (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
|
318 result |= 1; |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
319 if (sprintf (buf, "%Lg", -1.0L / zeroL) < 0 |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
320 || (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
|
321 result |= 1; |
8865
9e203d8ade65
Stricter check for printf result for NaN arguments.
Bruno Haible <bruno@clisp.org>
parents:
8864
diff
changeset
|
322 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
|
323 || !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
|
324 result |= 1; |
15905
53e09ee0d19a
*printf: Fix for platforms where 'long double' == 'double'.
Bruno Haible <bruno@clisp.org>
parents:
15595
diff
changeset
|
325 #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE |
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
|
326 /* 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
|
327 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
|
328 # 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
|
329 # 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
|
330 { ((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
|
331 ((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
|
332 (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
|
333 } |
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 # 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
|
335 # 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
|
336 { 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
|
337 # 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
|
338 { /* 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
|
339 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
|
340 { 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
|
341 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
|
342 || !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
|
343 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
|
344 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
|
345 || !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
|
346 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
|
347 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
|
348 || !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
|
349 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
|
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 { |
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 /* 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
|
353 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
|
354 { 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
|
355 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
|
356 || !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
|
357 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
|
358 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
|
359 || !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
|
360 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
|
361 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
|
362 || !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
|
363 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
|
364 } |
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 { /* 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
|
366 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
|
367 { 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
|
368 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
|
369 || !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
|
370 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
|
371 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
|
372 || !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
|
373 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
|
374 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
|
375 || !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
|
376 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
|
377 } |
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 { /* 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
|
379 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
|
380 { 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
|
381 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
|
382 || !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
|
383 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
|
384 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
|
385 || !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
|
386 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
|
387 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
|
388 || !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
|
389 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
|
390 } |
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 { /* 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
|
392 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
|
393 { 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
|
394 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
|
395 || !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
|
396 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
|
397 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
|
398 || !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
|
399 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
|
400 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
|
401 || !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
|
402 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
|
403 } |
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 { /* 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
|
405 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
|
406 { 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
|
407 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
|
408 || !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
|
409 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
|
410 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
|
411 || !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
|
412 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
|
413 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
|
414 || !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
|
415 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
|
416 } |
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 { /* 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
|
418 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
|
419 { 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
|
420 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
|
421 || !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
|
422 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
|
423 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
|
424 || !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
|
425 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
|
426 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
|
427 || !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
|
428 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
|
429 } |
2ebbd8b55714
Fix *printf so that it recognizes non-IEEE numbers on i386, x86_64, ia64.
Bruno Haible <bruno@clisp.org>
parents:
8865
diff
changeset
|
430 #endif |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13917
diff
changeset
|
431 return result; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
432 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
433 [gl_cv_func_printf_infinite_long_double=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
434 [gl_cv_func_printf_infinite_long_double=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
435 [ |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
436 changequote(,)dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
437 case "$host_cpu" in |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
438 # Guess no on ia64, x86_64, i386. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
439 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
|
440 *) |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
441 case "$host_os" in |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
442 # Guess yes on glibc systems. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
443 *-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
|
444 # Guess yes on FreeBSD >= 6. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
445 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
|
446 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
|
447 # Guess yes on HP-UX >= 11. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
448 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
|
449 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
|
450 # If we don't know, assume the worst. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
451 *) gl_cv_func_printf_infinite_long_double="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
452 esac |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
453 ;; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
454 esac |
8860
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
455 changequote([,])dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
456 ]) |
8860
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 *) |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
460 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
|
461 ;; |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
462 esac |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
463 ]) |
771a56a41b5b
Fix *printf result for NaN, Inf on AIX, Solaris, OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
8849
diff
changeset
|
464 |
8335 | 465 dnl Test whether the *printf family of functions supports the 'a' and 'A' |
466 dnl conversion specifier for hexadecimal output of floating-point numbers. | |
467 dnl (ISO C99, POSIX:2001) | |
468 dnl Result is gl_cv_func_printf_directive_a. | |
469 | |
470 AC_DEFUN([gl_PRINTF_DIRECTIVE_A], | |
471 [ | |
472 AC_REQUIRE([AC_PROG_CC]) | |
473 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
474 AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives], | |
8847 | 475 [gl_cv_func_printf_directive_a], |
8335 | 476 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
477 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
478 [AC_LANG_SOURCE([[ |
8335 | 479 #include <stdio.h> |
480 #include <string.h> | |
481 static char buf[100]; | |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
482 static double zero = 0.0; |
8335 | 483 int main () |
484 { | |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13917
diff
changeset
|
485 int result = 0; |
8335 | 486 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
|
487 || (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
|
488 && 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
|
489 && 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
|
490 && 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
|
491 result |= 1; |
8335 | 492 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
|
493 || (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
|
494 && 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
|
495 && 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
|
496 && 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
|
497 result |= 2; |
8643
013fc89d552c
Catch a bug of printf "%a" on FreeBSD 6.1.
Bruno Haible <bruno@clisp.org>
parents:
8383
diff
changeset
|
498 /* 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
|
499 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
|
500 || (strcmp (buf, "0x1.83p+0 33") != 0 |
e2189cab039d
The 2007-04-04 patch was broken.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
501 && strcmp (buf, "0x3.05p-1 33") != 0 |
e2189cab039d
The 2007-04-04 patch was broken.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
502 && strcmp (buf, "0x6.0ap-2 33") != 0 |
e2189cab039d
The 2007-04-04 patch was broken.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
503 && 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
|
504 result |= 4; |
8662
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
505 /* This catches a FreeBSD 6.1 bug. See |
023aa5c883a7
Guard against FreeBSD 6.1 bug.
Bruno Haible <bruno@clisp.org>
parents:
8648
diff
changeset
|
506 <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
507 if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0 |
8663
e2189cab039d
The 2007-04-04 patch was broken.
Bruno Haible <bruno@clisp.org>
parents:
8662
diff
changeset
|
508 || 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
|
509 result |= 8; |
8344
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
510 /* 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
|
511 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
|
512 || (strcmp (buf, "0x1.0p+1") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
513 && strcmp (buf, "0x2.0p+0") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
514 && strcmp (buf, "0x4.0p-1") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
515 && 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
|
516 result |= 16; |
8344
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
517 /* 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
|
518 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
|
519 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
|
520 || (strcmp (buf, "0x1.0p+1") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
521 && strcmp (buf, "0x2.0p+0") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
522 && strcmp (buf, "0x4.0p-1") != 0 |
c8055280f68e
Test a corner case. Exclude two buggy implementations.
Bruno Haible <bruno@clisp.org>
parents:
8335
diff
changeset
|
523 && 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
|
524 result |= 32; |
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13917
diff
changeset
|
525 return result; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
526 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
527 [gl_cv_func_printf_directive_a=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
528 [gl_cv_func_printf_directive_a=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
529 [ |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
530 case "$host_os" in |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
531 # Guess yes on glibc >= 2.5 systems. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
532 *-gnu*) |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
533 AC_EGREP_CPP([BZ2908], [ |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
534 #include <features.h> |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
535 #ifdef __GNU_LIBRARY__ |
13885 | 536 #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
|
537 BZ2908 |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
538 #endif |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
539 #endif |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
540 ], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
541 [gl_cv_func_printf_directive_a="guessing yes"], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
542 [gl_cv_func_printf_directive_a="guessing no"]) |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
543 ;; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
544 # If we don't know, assume the worst. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
545 *) gl_cv_func_printf_directive_a="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
546 esac |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
547 ]) |
8335 | 548 ]) |
549 ]) | |
550 | |
8664
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
551 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
|
552 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
|
553 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
|
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_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
|
556 [ |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
557 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
|
558 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
|
559 AC_CACHE_CHECK([whether printf supports the 'F' directive], |
8847 | 560 [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
|
561 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
562 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
563 [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
|
564 #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
|
565 #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
|
566 static char buf[100]; |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
567 static double zero = 0.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 int main () |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
569 { |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13917
diff
changeset
|
570 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
|
571 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
|
572 || 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
|
573 result |= 1; |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
574 if (sprintf (buf, "%F", 1.0 / zero) < 0 |
8664
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
575 || (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
|
576 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
|
577 /* 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
|
578 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
|
579 || 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
|
580 result |= 4; |
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13917
diff
changeset
|
581 return result; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
582 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
583 [gl_cv_func_printf_directive_f=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
584 [gl_cv_func_printf_directive_f=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
585 [ |
8666
7ff0dd9e3d4f
Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
8665
diff
changeset
|
586 changequote(,)dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
587 case "$host_os" in |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
588 # Guess yes on glibc systems. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
589 *-gnu*) 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 FreeBSD >= 6. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
591 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
|
592 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
|
593 # Guess yes on MacOS X >= 10.3. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
594 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
|
595 darwin*) gl_cv_func_printf_directive_f="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
596 # 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
|
597 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
|
598 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
|
599 # If we don't know, assume the worst. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
600 *) gl_cv_func_printf_directive_f="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
601 esac |
8666
7ff0dd9e3d4f
Better guessing in gl_PRINTF_DIRECTIVE_F when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents:
8665
diff
changeset
|
602 changequote([,])dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
603 ]) |
8664
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
604 ]) |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
605 ]) |
40c507f55b0f
Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents:
8663
diff
changeset
|
606 |
8335 | 607 dnl Test whether the *printf family of functions supports the %n format |
608 dnl directive. (ISO C99, POSIX:2001) | |
609 dnl Result is gl_cv_func_printf_directive_n. | |
610 | |
611 AC_DEFUN([gl_PRINTF_DIRECTIVE_N], | |
612 [ | |
613 AC_REQUIRE([AC_PROG_CC]) | |
614 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
615 AC_CACHE_CHECK([whether printf supports the 'n' directive], | |
8847 | 616 [gl_cv_func_printf_directive_n], |
8335 | 617 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
618 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
619 [AC_LANG_SOURCE([[ |
8335 | 620 #include <stdio.h> |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
621 #include <stdlib.h> |
8335 | 622 #include <string.h> |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
623 #ifdef _MSC_VER |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
624 /* See page about "Parameter Validation" on msdn.microsoft.com. */ |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
625 static void cdecl |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
626 invalid_parameter_handler (const wchar_t *expression, |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
627 const wchar_t *function, |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
628 const wchar_t *file, unsigned int line, |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
629 uintptr_t dummy) |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
630 { |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
631 exit (1); |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
632 } |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
633 #endif |
9359
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
634 static char fmtstring[10]; |
8335 | 635 static char buf[100]; |
636 int main () | |
637 { | |
638 int count = -1; | |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
639 #ifdef _MSC_VER |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
640 _set_invalid_parameter_handler (invalid_parameter_handler); |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
641 #endif |
9359
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
642 /* 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
|
643 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
|
644 memory. */ |
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
645 strcpy (fmtstring, "%d %n"); |
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
646 if (sprintf (buf, fmtstring, 123, &count, 33, 44, 55) < 0 |
8335 | 647 || strcmp (buf, "123 ") != 0 |
648 || count != 4) | |
649 return 1; | |
650 return 0; | |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
651 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
652 [gl_cv_func_printf_directive_n=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
653 [gl_cv_func_printf_directive_n=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
654 [ |
8335 | 655 changequote(,)dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
656 case "$host_os" in |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
657 mingw*) gl_cv_func_printf_directive_n="guessing no";; |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
658 *) gl_cv_func_printf_directive_n="guessing yes";; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
659 esac |
8335 | 660 changequote([,])dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
661 ]) |
8335 | 662 ]) |
663 ]) | |
664 | |
11219
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
665 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
|
666 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
|
667 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
|
668 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
|
669 dnl the precision. |
11219
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
670 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
|
671 |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
672 AC_DEFUN([gl_PRINTF_DIRECTIVE_LS], |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
673 [ |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
674 AC_REQUIRE([AC_PROG_CC]) |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
675 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
|
676 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
|
677 [gl_cv_func_printf_directive_ls], |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
678 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
679 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
680 [AC_LANG_SOURCE([[ |
11219
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
681 /* 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
|
682 <wchar.h>. |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
683 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
|
684 included before <wchar.h>. */ |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
685 #include <stddef.h> |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
686 #include <stdio.h> |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
687 #include <time.h> |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
688 #include <wchar.h> |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
689 #include <string.h> |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
690 int main () |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
691 { |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13917
diff
changeset
|
692 int result = 0; |
11219
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
693 char buf[100]; |
11223
41012a39667b
Work around a *printf bug with %ls on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
11221
diff
changeset
|
694 /* 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
|
695 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
|
696 Cygwin 1.5. */ |
11223
41012a39667b
Work around a *printf bug with %ls on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
11221
diff
changeset
|
697 { |
11234
cf3001cea096
Separate two tests. Mention the platforms in canonical order.
Bruno Haible <bruno@clisp.org>
parents:
11228
diff
changeset
|
698 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
|
699 buf[0] = '\0'; |
41012a39667b
Work around a *printf bug with %ls on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
11221
diff
changeset
|
700 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
|
701 || 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
|
702 result |= 1; |
11234
cf3001cea096
Separate two tests. Mention the platforms in canonical order.
Bruno Haible <bruno@clisp.org>
parents:
11228
diff
changeset
|
703 } |
cf3001cea096
Separate two tests. Mention the platforms in canonical order.
Bruno Haible <bruno@clisp.org>
parents:
11228
diff
changeset
|
704 /* 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
|
705 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
|
706 { |
cf3001cea096
Separate two tests. Mention the platforms in canonical order.
Bruno Haible <bruno@clisp.org>
parents:
11228
diff
changeset
|
707 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
|
708 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
|
709 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
|
710 || 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
|
711 result |= 2; |
11223
41012a39667b
Work around a *printf bug with %ls on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
11221
diff
changeset
|
712 } |
41012a39667b
Work around a *printf bug with %ls on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
11221
diff
changeset
|
713 /* 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
|
714 section 7.19.6.1: |
41012a39667b
Work around a *printf bug with %ls on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
11221
diff
changeset
|
715 "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
|
716 (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
|
717 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
|
718 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
|
719 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
|
720 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
|
721 { |
41012a39667b
Work around a *printf bug with %ls on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
11221
diff
changeset
|
722 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
|
723 buf[0] = '\0'; |
41012a39667b
Work around a *printf bug with %ls on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
11221
diff
changeset
|
724 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
|
725 || 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
|
726 result |= 8; |
11223
41012a39667b
Work around a *printf bug with %ls on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
11221
diff
changeset
|
727 } |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13917
diff
changeset
|
728 return result; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
729 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
730 [gl_cv_func_printf_directive_ls=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
731 [gl_cv_func_printf_directive_ls=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
732 [ |
11219
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
733 changequote(,)dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
734 case "$host_os" in |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
735 openbsd*) gl_cv_func_printf_directive_ls="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
736 irix*) gl_cv_func_printf_directive_ls="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
737 solaris*) gl_cv_func_printf_directive_ls="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
738 cygwin*) gl_cv_func_printf_directive_ls="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
739 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
|
740 *) gl_cv_func_printf_directive_ls="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
741 esac |
11219
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
742 changequote([,])dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
743 ]) |
11219
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
744 ]) |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
745 ]) |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
746 |
8335 | 747 dnl Test whether the *printf family of functions supports POSIX/XSI format |
748 dnl strings with positions. (POSIX:2001) | |
749 dnl Result is gl_cv_func_printf_positions. | |
750 | |
751 AC_DEFUN([gl_PRINTF_POSITIONS], | |
752 [ | |
753 AC_REQUIRE([AC_PROG_CC]) | |
754 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
755 AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions], | |
8847 | 756 [gl_cv_func_printf_positions], |
8335 | 757 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
758 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
759 [AC_LANG_SOURCE([[ |
8335 | 760 #include <stdio.h> |
761 #include <string.h> | |
762 /* The string "%2$d %1$d", with dollar characters protected from the shell's | |
763 dollar expansion (possibly an autoconf bug). */ | |
764 static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; | |
765 static char buf[100]; | |
766 int main () | |
767 { | |
768 sprintf (buf, format, 33, 55); | |
769 return (strcmp (buf, "55 33") != 0); | |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
770 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
771 [gl_cv_func_printf_positions=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
772 [gl_cv_func_printf_positions=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
773 [ |
8335 | 774 changequote(,)dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
775 case "$host_os" in |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
776 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
|
777 gl_cv_func_printf_positions="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
778 beos*) gl_cv_func_printf_positions="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
779 mingw* | pw*) gl_cv_func_printf_positions="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
780 *) gl_cv_func_printf_positions="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
781 esac |
8335 | 782 changequote([,])dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
783 ]) |
8335 | 784 ]) |
785 ]) | |
786 | |
8803
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
787 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
|
788 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
|
789 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
|
790 |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
791 AC_DEFUN([gl_PRINTF_FLAG_GROUPING], |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
792 [ |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
793 AC_REQUIRE([AC_PROG_CC]) |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
794 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
|
795 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
|
796 [gl_cv_func_printf_flag_grouping], |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
797 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
798 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
799 [AC_LANG_SOURCE([[ |
8803
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
800 #include <stdio.h> |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
801 #include <string.h> |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
802 static char buf[100]; |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
803 int main () |
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 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
|
806 || buf[strlen (buf) - 1] != '9') |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
807 return 1; |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
808 return 0; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
809 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
810 [gl_cv_func_printf_flag_grouping=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
811 [gl_cv_func_printf_flag_grouping=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
812 [ |
8803
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
813 changequote(,)dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
814 case "$host_os" in |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
815 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
816 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
817 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
|
818 *) gl_cv_func_printf_flag_grouping="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
819 esac |
8803
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
820 changequote([,])dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
821 ]) |
8803
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
822 ]) |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
823 ]) |
6c1d98929550
Work around lack of support of grouping flag.
Bruno Haible <bruno@clisp.org>
parents:
8763
diff
changeset
|
824 |
9674
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
825 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
|
826 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
|
827 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
|
828 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
|
829 |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
830 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
|
831 [ |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
832 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
|
833 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
|
834 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
|
835 [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
|
836 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
837 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
838 [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
|
839 #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
|
840 #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
|
841 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
|
842 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
|
843 { |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
844 /* 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
|
845 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
|
846 || 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
|
847 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
|
848 return 0; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
849 }]])], |
9674
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
850 [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
|
851 [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
|
852 [ |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
853 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
|
854 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
|
855 # 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
|
856 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
|
857 # 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
|
858 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
|
859 # 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
|
860 *) 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
|
861 esac |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
862 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
|
863 ]) |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
864 ]) |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
865 ]) |
b69f1141e94f
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Bruno Haible <bruno@clisp.org>
parents:
9533
diff
changeset
|
866 |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
867 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
|
868 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
|
869 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
|
870 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
|
871 |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
872 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
|
873 [ |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
874 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
|
875 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
|
876 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
|
877 [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
|
878 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
879 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
880 [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
|
881 #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
|
882 #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
|
883 static char buf[100]; |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
884 static double zero = 0.0; |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
885 int main () |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
886 { |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15591
diff
changeset
|
887 if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0 |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
888 || (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
|
889 && 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
|
890 return 1; |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
891 return 0; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
892 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
893 [gl_cv_func_printf_flag_zero=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
894 [gl_cv_func_printf_flag_zero=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
895 [ |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
896 changequote(,)dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
897 case "$host_os" in |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
898 # Guess yes on glibc systems. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
899 *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
900 # Guess yes on BeOS. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
901 beos*) gl_cv_func_printf_flag_zero="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
902 # If we don't know, assume the worst. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
903 *) gl_cv_func_printf_flag_zero="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
904 esac |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
905 changequote([,])dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
906 ]) |
8804
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
907 ]) |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
908 ]) |
6ce313658b4d
Work around an incorrect implementation of the 0 flag on most platforms.
Bruno Haible <bruno@clisp.org>
parents:
8803
diff
changeset
|
909 |
9446
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
910 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
|
911 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
|
912 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
|
913 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
|
914 dnl precisions larger than 510 in floating-point output yield wrong results. |
15296
fa0d7f167907
sprintf-posix: Fix test failure on AIX 7.1.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
915 dnl On AIX 7.1, precisions larger than 998 in floating-point output yield |
fa0d7f167907
sprintf-posix: Fix test failure on AIX 7.1.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
916 dnl wrong results. 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
|
917 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
|
918 |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
919 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
|
920 [ |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
921 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
|
922 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
|
923 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
|
924 [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
|
925 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
926 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
927 [AC_LANG_SOURCE([[ |
9446
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
928 #include <stdio.h> |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
929 #include <string.h> |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
930 static char buf[5000]; |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
931 int main () |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
932 { |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13917
diff
changeset
|
933 int result = 0; |
9446
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
934 #ifdef __BEOS__ |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
935 /* 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
|
936 return 1; |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
937 #endif |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
938 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
|
939 result |= 1; |
13908
4b4e2b0d175e
*printf-posix: Detect a bug on Solaris 10/x86.
Bruno Haible <bruno@clisp.org>
parents:
13892
diff
changeset
|
940 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
|
941 result |= 2; |
14005
f585ecc144aa
*printf: Detect large precisions bug on Solaris 10/SPARC.
Bruno Haible <bruno@clisp.org>
parents:
13972
diff
changeset
|
942 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
|
943 || buf[0] != '1') |
f585ecc144aa
*printf: Detect large precisions bug on Solaris 10/SPARC.
Bruno Haible <bruno@clisp.org>
parents:
13972
diff
changeset
|
944 result |= 4; |
15296
fa0d7f167907
sprintf-posix: Fix test failure on AIX 7.1.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
945 if (sprintf (buf, "%.999f %d", 1.0, 33, 44) < 999 + 5 |
fa0d7f167907
sprintf-posix: Fix test failure on AIX 7.1.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
946 || buf[0] != '1') |
fa0d7f167907
sprintf-posix: Fix test failure on AIX 7.1.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
947 result |= 4; |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13917
diff
changeset
|
948 return result; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
949 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
950 [gl_cv_func_printf_precision=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
951 [gl_cv_func_printf_precision=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
952 [ |
9446
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
953 changequote(,)dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
954 case "$host_os" in |
13908
4b4e2b0d175e
*printf-posix: Detect a bug on Solaris 10/x86.
Bruno Haible <bruno@clisp.org>
parents:
13892
diff
changeset
|
955 # 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
|
956 solaris*) gl_cv_func_printf_precision="guessing no" ;; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
957 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
958 beos*) gl_cv_func_printf_precision="guessing no" ;; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
959 *) gl_cv_func_printf_precision="guessing yes" ;; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
960 esac |
9446
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
961 changequote([,])dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
962 ]) |
9446
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
963 ]) |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
964 ]) |
0519fc8ce06a
Fix *printf behaviour for large precisions on mingw and BeOS.
Bruno Haible <bruno@clisp.org>
parents:
9442
diff
changeset
|
965 |
9442
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
966 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
|
967 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
|
968 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
|
969 |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
970 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
|
971 [ |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
972 AC_REQUIRE([AC_PROG_CC]) |
10973
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
973 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
|
974 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
|
975 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
|
976 [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
|
977 [ |
10783
7f50373172eb
Guess that printf on Haiku survives out-of-memory conditions.
Bruno Haible <bruno@clisp.org>
parents:
9940
diff
changeset
|
978 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
|
979 if test "$cross_compiling" = no; then |
10973
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
980 if test $APPLE_UNIVERSAL_BUILD = 0; then |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
981 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
|
982 ]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
|
983 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
|
984 #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
|
985 #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
|
986 #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
|
987 #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
|
988 #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
|
989 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
|
990 { |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
991 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
|
992 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
|
993 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
|
994 /* 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
|
995 /* 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
|
996 #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
|
997 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
|
998 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
|
999 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
|
1000 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
|
1001 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
|
1002 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
|
1003 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
|
1004 #endif |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
1005 /* 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
|
1006 #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
|
1007 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
|
1008 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
|
1009 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
|
1010 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
|
1011 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
|
1012 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
|
1013 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
|
1014 #endif |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
1015 /* 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
|
1016 #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
|
1017 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
|
1018 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
|
1019 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
|
1020 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
|
1021 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
|
1022 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
|
1023 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
|
1024 #endif |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
1025 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
|
1026 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
|
1027 } |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
1028 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
|
1029 ])]) |
10973
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
1030 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
|
1031 (./conftest |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
1032 result=$? |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
1033 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
|
1034 exit $result |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
1035 ) >/dev/null 2>/dev/null |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
1036 case $? in |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
1037 0) gl_cv_func_printf_enomem="yes" ;; |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
1038 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
|
1039 *) gl_cv_func_printf_enomem="no" ;; |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
1040 esac |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
1041 else |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
1042 gl_cv_func_printf_enomem="guessing no" |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
1043 fi |
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
1044 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
|
1045 else |
10973
e1a3422c4e90
Add support for universal builds to vasnprintf.
Bruno Haible <bruno@clisp.org>
parents:
10783
diff
changeset
|
1046 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
|
1047 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
|
1048 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
|
1049 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
|
1050 fi |
10783
7f50373172eb
Guess that printf on Haiku survives out-of-memory conditions.
Bruno Haible <bruno@clisp.org>
parents:
9940
diff
changeset
|
1051 fi |
7f50373172eb
Guess that printf on Haiku survives out-of-memory conditions.
Bruno Haible <bruno@clisp.org>
parents:
9940
diff
changeset
|
1052 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
|
1053 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
|
1054 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
|
1055 # 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
|
1056 *-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
|
1057 # 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
|
1058 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
|
1059 # 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
|
1060 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
|
1061 # 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
|
1062 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
|
1063 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
|
1064 *) 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
|
1065 esac |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
1066 ;; |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
1067 # 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
|
1068 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
|
1069 # 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
|
1070 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
|
1071 # 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
|
1072 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
|
1073 # Guess yes on Haiku. |
7f50373172eb
Guess that printf on Haiku survives out-of-memory conditions.
Bruno Haible <bruno@clisp.org>
parents:
9940
diff
changeset
|
1074 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
|
1075 # 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
|
1076 *) 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
|
1077 esac |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
1078 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
|
1079 fi |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
1080 ]) |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
1081 ]) |
ad275322f8f1
Fix *printf behaviour in out-of-memory situations on MacOS X and *BSD.
Bruno Haible <bruno@clisp.org>
parents:
9359
diff
changeset
|
1082 |
8335 | 1083 dnl Test whether the snprintf function exists. (ISO C99, POSIX:2001) |
1084 dnl Result is ac_cv_func_snprintf. | |
1085 | |
1086 AC_DEFUN([gl_SNPRINTF_PRESENCE], | |
1087 [ | |
1088 AC_CHECK_FUNCS_ONCE([snprintf]) | |
1089 ]) | |
1090 | |
1091 dnl Test whether the string produced by the snprintf function is always NUL | |
1092 dnl terminated. (ISO C99, POSIX:2001) | |
1093 dnl Result is gl_cv_func_snprintf_truncation_c99. | |
1094 | |
1095 AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99], | |
1096 [ | |
1097 AC_REQUIRE([AC_PROG_CC]) | |
1098 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1099 AC_REQUIRE([gl_SNPRINTF_PRESENCE]) |
8335 | 1100 AC_CACHE_CHECK([whether snprintf truncates the result as in C99], |
8847 | 1101 [gl_cv_func_snprintf_truncation_c99], |
8335 | 1102 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1103 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1104 [AC_LANG_SOURCE([[ |
8335 | 1105 #include <stdio.h> |
1106 #include <string.h> | |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1107 #if HAVE_SNPRINTF |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1108 # define my_snprintf snprintf |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1109 #else |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1110 # include <stdarg.h> |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1111 static int my_snprintf (char *buf, int size, const char *format, ...) |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1112 { |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1113 va_list args; |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1114 int ret; |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1115 va_start (args, format); |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1116 ret = vsnprintf (buf, size, format, args); |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1117 va_end (args); |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1118 return ret; |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1119 } |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1120 #endif |
8335 | 1121 static char buf[100]; |
1122 int main () | |
1123 { | |
1124 strcpy (buf, "ABCDEF"); | |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1125 my_snprintf (buf, 3, "%d %d", 4567, 89); |
8335 | 1126 if (memcmp (buf, "45\0DEF", 6) != 0) |
1127 return 1; | |
1128 return 0; | |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1129 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1130 [gl_cv_func_snprintf_truncation_c99=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1131 [gl_cv_func_snprintf_truncation_c99=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1132 [ |
8335 | 1133 changequote(,)dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1134 case "$host_os" in |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1135 # Guess yes on glibc systems. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1136 *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1137 # Guess yes on FreeBSD >= 5. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1138 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
|
1139 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
|
1140 # Guess yes on MacOS X >= 10.3. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1141 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
|
1142 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1143 # Guess yes on OpenBSD >= 3.9. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1144 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1145 gl_cv_func_snprintf_truncation_c99="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1146 openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1147 # Guess yes on Solaris >= 2.6. |
13972
258e995bb973
Fix cross-compilation guesses on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
13971
diff
changeset
|
1148 solaris2.[0-5] | solaris2.[0-5].*) |
258e995bb973
Fix cross-compilation guesses on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
13971
diff
changeset
|
1149 gl_cv_func_snprintf_truncation_c99="guessing no";; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1150 solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1151 # Guess yes on AIX >= 4. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1152 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
|
1153 aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1154 # Guess yes on HP-UX >= 11. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1155 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
|
1156 hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1157 # Guess yes on IRIX >= 6.5. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1158 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
|
1159 # Guess yes on OSF/1 >= 5. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1160 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
|
1161 osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1162 # Guess yes on NetBSD >= 3. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1163 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
|
1164 gl_cv_func_snprintf_truncation_c99="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1165 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1166 # Guess yes on BeOS. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1167 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1168 # If we don't know, assume the worst. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1169 *) gl_cv_func_snprintf_truncation_c99="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1170 esac |
8335 | 1171 changequote([,])dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1172 ]) |
8335 | 1173 ]) |
1174 ]) | |
1175 | |
1176 dnl Test whether the return value of the snprintf function is the number | |
1177 dnl of bytes (excluding the terminating NUL) that would have been produced | |
1178 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
|
1179 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
|
1180 dnl --------------------------------------------------------------------- |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1181 dnl #include <stdio.h> |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1182 dnl int main() |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1183 dnl { |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1184 dnl static char buf[8]; |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1185 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
|
1186 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
|
1187 dnl } |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1188 dnl --------------------------------------------------------------------- |
8353 | 1189 dnl Result is gl_cv_func_snprintf_retval_c99. |
8335 | 1190 |
13404
2a548c2eb40e
printf.m4: avoid autoconf's "Expanded Before Required" warning
Jim Meyering <meyering@redhat.com>
parents:
12559
diff
changeset
|
1191 AC_DEFUN_ONCE([gl_SNPRINTF_RETVAL_C99], |
8335 | 1192 [ |
1193 AC_REQUIRE([AC_PROG_CC]) | |
1194 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1195 AC_REQUIRE([gl_SNPRINTF_PRESENCE]) |
8335 | 1196 AC_CACHE_CHECK([whether snprintf returns a byte count as in C99], |
8847 | 1197 [gl_cv_func_snprintf_retval_c99], |
8335 | 1198 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1199 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1200 [AC_LANG_SOURCE([[ |
8335 | 1201 #include <stdio.h> |
1202 #include <string.h> | |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1203 #if HAVE_SNPRINTF |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1204 # define my_snprintf snprintf |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1205 #else |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1206 # include <stdarg.h> |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1207 static int my_snprintf (char *buf, int size, const char *format, ...) |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1208 { |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1209 va_list args; |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1210 int ret; |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1211 va_start (args, format); |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1212 ret = vsnprintf (buf, size, format, args); |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1213 va_end (args); |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1214 return ret; |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1215 } |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1216 #endif |
8335 | 1217 static char buf[100]; |
1218 int main () | |
1219 { | |
1220 strcpy (buf, "ABCDEF"); | |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1221 if (my_snprintf (buf, 3, "%d %d", 4567, 89) != 7) |
8335 | 1222 return 1; |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1223 if (my_snprintf (buf, 0, "%d %d", 4567, 89) != 7) |
13971
9679af58bfe7
snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9
Paul Eggert <eggert@cs.ucla.edu>
parents:
13918
diff
changeset
|
1224 return 2; |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1225 if (my_snprintf (NULL, 0, "%d %d", 4567, 89) != 7) |
13971
9679af58bfe7
snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9
Paul Eggert <eggert@cs.ucla.edu>
parents:
13918
diff
changeset
|
1226 return 3; |
8335 | 1227 return 0; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1228 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1229 [gl_cv_func_snprintf_retval_c99=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1230 [gl_cv_func_snprintf_retval_c99=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1231 [ |
8335 | 1232 changequote(,)dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1233 case "$host_os" in |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1234 # Guess yes on glibc systems. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1235 *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1236 # Guess yes on FreeBSD >= 5. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1237 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
|
1238 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
|
1239 # Guess yes on MacOS X >= 10.3. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1240 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
|
1241 darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1242 # Guess yes on OpenBSD >= 3.9. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1243 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1244 gl_cv_func_snprintf_retval_c99="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1245 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
|
1246 # 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
|
1247 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
|
1248 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
|
1249 # Guess yes on AIX >= 4. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1250 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
|
1251 aix*) gl_cv_func_snprintf_retval_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1252 # Guess yes on NetBSD >= 3. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1253 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
|
1254 gl_cv_func_snprintf_retval_c99="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1255 netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1256 # Guess yes on BeOS. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1257 beos*) gl_cv_func_snprintf_retval_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1258 # If we don't know, assume the worst. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1259 *) gl_cv_func_snprintf_retval_c99="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1260 esac |
8335 | 1261 changequote([,])dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1262 ]) |
8335 | 1263 ]) |
1264 ]) | |
1265 | |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1266 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
|
1267 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
|
1268 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
|
1269 |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1270 AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N], |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1271 [ |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1272 AC_REQUIRE([AC_PROG_CC]) |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1273 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1274 AC_REQUIRE([gl_SNPRINTF_PRESENCE]) |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1275 AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive], |
8847 | 1276 [gl_cv_func_snprintf_directive_n], |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1277 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1278 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1279 [AC_LANG_SOURCE([[ |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1280 #include <stdio.h> |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1281 #include <string.h> |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1282 #if HAVE_SNPRINTF |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1283 # define my_snprintf snprintf |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1284 #else |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1285 # include <stdarg.h> |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1286 static int my_snprintf (char *buf, int size, const char *format, ...) |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1287 { |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1288 va_list args; |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1289 int ret; |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1290 va_start (args, format); |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1291 ret = vsnprintf (buf, size, format, args); |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1292 va_end (args); |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1293 return ret; |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1294 } |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1295 #endif |
9359
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
1296 static char fmtstring[10]; |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1297 static char buf[100]; |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1298 int main () |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1299 { |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1300 int count = -1; |
9359
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
1301 /* 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
|
1302 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
|
1303 memory. */ |
568979a9f3d0
Improve detection of whether %n is supported or not.
Bruno Haible <bruno@clisp.org>
parents:
9214
diff
changeset
|
1304 strcpy (fmtstring, "%d %n"); |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1305 my_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
|
1306 if (count != 6) |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1307 return 1; |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1308 return 0; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1309 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1310 [gl_cv_func_snprintf_directive_n=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1311 [gl_cv_func_snprintf_directive_n=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1312 [ |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1313 changequote(,)dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1314 case "$host_os" in |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1315 # Guess yes on glibc systems. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1316 *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1317 # Guess yes on FreeBSD >= 5. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1318 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
|
1319 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
|
1320 # Guess yes on MacOS X >= 10.3. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1321 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
|
1322 darwin*) gl_cv_func_snprintf_directive_n="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1323 # Guess yes on Solaris >= 2.6. |
13972
258e995bb973
Fix cross-compilation guesses on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
13971
diff
changeset
|
1324 solaris2.[0-5] | solaris2.[0-5].*) |
258e995bb973
Fix cross-compilation guesses on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
13971
diff
changeset
|
1325 gl_cv_func_snprintf_directive_n="guessing no";; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1326 solaris*) gl_cv_func_snprintf_directive_n="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1327 # Guess yes on AIX >= 4. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1328 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
|
1329 aix*) gl_cv_func_snprintf_directive_n="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1330 # Guess yes on IRIX >= 6.5. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1331 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
|
1332 # Guess yes on OSF/1 >= 5. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1333 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
|
1334 osf*) gl_cv_func_snprintf_directive_n="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1335 # Guess yes on NetBSD >= 3. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1336 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
|
1337 gl_cv_func_snprintf_directive_n="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1338 netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1339 # Guess yes on BeOS. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1340 beos*) gl_cv_func_snprintf_directive_n="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1341 # If we don't know, assume the worst. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1342 *) gl_cv_func_snprintf_directive_n="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1343 esac |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1344 changequote([,])dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1345 ]) |
8352
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1346 ]) |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1347 ]) |
741f8a5caa9c
Add an 8th test, against HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
8351
diff
changeset
|
1348 |
9940
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1349 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
|
1350 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
|
1351 dnl case on Linux libc5. |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1352 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
|
1353 |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1354 AC_DEFUN([gl_SNPRINTF_SIZE1], |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1355 [ |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1356 AC_REQUIRE([AC_PROG_CC]) |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1357 AC_REQUIRE([gl_SNPRINTF_PRESENCE]) |
9940
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1358 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
|
1359 [gl_cv_func_snprintf_size1], |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1360 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1361 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1362 [AC_LANG_SOURCE([[ |
9940
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1363 #include <stdio.h> |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1364 #if HAVE_SNPRINTF |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1365 # define my_snprintf snprintf |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1366 #else |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1367 # include <stdarg.h> |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1368 static int my_snprintf (char *buf, int size, const char *format, ...) |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1369 { |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1370 va_list args; |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1371 int ret; |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1372 va_start (args, format); |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1373 ret = vsnprintf (buf, size, format, args); |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1374 va_end (args); |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1375 return ret; |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1376 } |
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1377 #endif |
9940
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1378 int main() |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1379 { |
11021
9118fd8fdd2f
Use an array initializer syntax that also works in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
1380 static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1381 my_snprintf (buf, 1, "%d", 12345); |
9940
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1382 return buf[1] != 'E'; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1383 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1384 [gl_cv_func_snprintf_size1=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1385 [gl_cv_func_snprintf_size1=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1386 [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
|
1387 ]) |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1388 ]) |
0471a8660b70
Work around snprintf bug on Linux libc5.
Bruno Haible <bruno@clisp.org>
parents:
9674
diff
changeset
|
1389 |
8763
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1390 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
|
1391 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
|
1392 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
|
1393 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
|
1394 dnl --------------------------------------------------------------------- |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1395 dnl #include <stdio.h> |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1396 dnl int main() |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1397 dnl { |
11021
9118fd8fdd2f
Use an array initializer syntax that also works in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
1398 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
|
1399 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
|
1400 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
|
1401 dnl } |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1402 dnl --------------------------------------------------------------------- |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1403 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
|
1404 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
|
1405 dnl --------------------------------------------------------------------- |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1406 dnl #include <stdarg.h> |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1407 dnl #include <stdio.h> |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1408 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
|
1409 dnl { |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1410 dnl va_list args; |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1411 dnl int ret; |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1412 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
|
1413 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
|
1414 dnl va_end (args); |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1415 dnl return ret; |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1416 dnl } |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1417 dnl int main() |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1418 dnl { |
11021
9118fd8fdd2f
Use an array initializer syntax that also works in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
1419 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
|
1420 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
|
1421 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
|
1422 dnl } |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1423 dnl --------------------------------------------------------------------- |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1424 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
|
1425 |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1426 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
|
1427 [ |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1428 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
|
1429 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
|
1430 AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99], |
8847 | 1431 [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
|
1432 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1433 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1434 [AC_LANG_SOURCE([[ |
8763
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1435 #include <stdarg.h> |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1436 #include <stdio.h> |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1437 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
|
1438 { |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1439 va_list args; |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1440 int ret; |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1441 va_start (args, format); |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1442 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
|
1443 va_end (args); |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1444 return ret; |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1445 } |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1446 int main() |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1447 { |
11021
9118fd8fdd2f
Use an array initializer syntax that also works in C++ mode.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
1448 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
|
1449 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
|
1450 return buf[0] != 'D'; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1451 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1452 [gl_cv_func_vsnprintf_zerosize_c99=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1453 [gl_cv_func_vsnprintf_zerosize_c99=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1454 [ |
8763
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1455 changequote(,)dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1456 case "$host_os" in |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1457 # Guess yes on glibc systems. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1458 *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1459 # Guess yes on FreeBSD >= 5. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1460 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
|
1461 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
|
1462 # Guess yes on MacOS X >= 10.3. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1463 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
|
1464 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1465 # Guess yes on Cygwin. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1466 cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1467 # Guess yes on Solaris >= 2.6. |
13972
258e995bb973
Fix cross-compilation guesses on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
13971
diff
changeset
|
1468 solaris2.[0-5] | solaris2.[0-5].*) |
258e995bb973
Fix cross-compilation guesses on Solaris.
Bruno Haible <bruno@clisp.org>
parents:
13971
diff
changeset
|
1469 gl_cv_func_vsnprintf_zerosize_c99="guessing no";; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1470 solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1471 # Guess yes on AIX >= 4. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1472 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
|
1473 aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1474 # Guess yes on IRIX >= 6.5. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1475 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
|
1476 # Guess yes on NetBSD >= 3. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1477 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
|
1478 gl_cv_func_vsnprintf_zerosize_c99="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1479 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1480 # Guess yes on BeOS. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1481 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1482 # Guess yes on mingw. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1483 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
|
1484 # If we don't know, assume the worst. |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1485 *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1486 esac |
8763
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1487 changequote([,])dnl |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13495
diff
changeset
|
1488 ]) |
8763
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1489 ]) |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1490 ]) |
39bb5430fc0e
Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents:
8676
diff
changeset
|
1491 |
8335 | 1492 dnl The results of these tests on various platforms are: |
1493 dnl | |
1494 dnl 1 = gl_PRINTF_SIZES_C99 | |
8849 | 1495 dnl 2 = gl_PRINTF_LONG_DOUBLE |
1496 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
|
1497 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
|
1498 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
|
1499 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
|
1500 dnl 7 = gl_PRINTF_DIRECTIVE_N |
11219
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1501 dnl 8 = gl_PRINTF_DIRECTIVE_LS |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1502 dnl 9 = gl_PRINTF_POSITIONS |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1503 dnl 10 = gl_PRINTF_FLAG_GROUPING |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1504 dnl 11 = gl_PRINTF_FLAG_LEFTADJUST |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1505 dnl 12 = gl_PRINTF_FLAG_ZERO |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1506 dnl 13 = gl_PRINTF_PRECISION |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1507 dnl 14 = gl_PRINTF_ENOMEM |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1508 dnl 15 = gl_SNPRINTF_PRESENCE |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1509 dnl 16 = gl_SNPRINTF_TRUNCATION_C99 |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1510 dnl 17 = gl_SNPRINTF_RETVAL_C99 |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1511 dnl 18 = gl_SNPRINTF_DIRECTIVE_N |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1512 dnl 19 = gl_SNPRINTF_SIZE1 |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1513 dnl 20 = gl_VSNPRINTF_ZEROSIZE_C99 |
8335 | 1514 dnl |
1515 dnl 1 = checking whether printf supports size specifiers as in C99... | |
8849 | 1516 dnl 2 = checking whether printf supports 'long double' arguments... |
1517 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
|
1518 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
|
1519 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
|
1520 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
|
1521 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
|
1522 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
|
1523 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
|
1524 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
|
1525 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
|
1526 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
|
1527 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
|
1528 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
|
1529 dnl 15 = checking for snprintf... |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1530 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
|
1531 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
|
1532 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
|
1533 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
|
1534 dnl 20 = checking whether vsnprintf respects a zero size as in C99... |
8335 | 1535 dnl |
1536 dnl . = yes, # = no. | |
1537 dnl | |
11219
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1538 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
|
1539 dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . . |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1540 dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . . |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1541 dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . . |
13890 | 1542 dnl MacOS X 10.5.8 . . . # # . . . . . . # . . . . . . . . |
11219
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1543 dnl MacOS X 10.3.9 . . . . # . . . . . . # . # . . . . . . |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1544 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
|
1545 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
|
1546 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
|
1547 dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . . |
13917
3bbfc7e37ec2
Update for Solaris 11 2010-11.
Bruno Haible <bruno@clisp.org>
parents:
13908
diff
changeset
|
1548 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
|
1549 dnl Solaris 10 . . # # # . . # . . . # # . . . . . . . |
14005
f585ecc144aa
*printf: Detect large precisions bug on Solaris 10/SPARC.
Bruno Haible <bruno@clisp.org>
parents:
13972
diff
changeset
|
1550 dnl Solaris 2.6 ... 9 # . # # # # . # . . . # # . . . # . . . |
11219
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1551 dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # # |
15296
fa0d7f167907
sprintf-posix: Fix test failure on AIX 7.1.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
1552 dnl AIX 7.1 . . # # # . . . . . . # # . . . . . . . |
fa0d7f167907
sprintf-posix: Fix test failure on AIX 7.1.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
1553 dnl AIX 5.2 . . # # # . . . . . . # . . . . . . . . |
13971
9679af58bfe7
snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9
Paul Eggert <eggert@cs.ucla.edu>
parents:
13918
diff
changeset
|
1554 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
|
1555 dnl HP-UX 11.31 . . . . # . . . . . . # . . . . # # . . |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1556 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
|
1557 dnl HP-UX 10.20 # . # . # # . ? . . # # . . . . # # ? # |
11219
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1558 dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . . |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1559 dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . # |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1560 dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # # |
13892 | 1561 dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . . |
11219
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1562 dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ? |
aaeb2f86d096
Fix *printf behaviour regarding the %ls directive.
Bruno Haible <bruno@clisp.org>
parents:
11053
diff
changeset
|
1563 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
|
1564 dnl Haiku . . . # # # . # . . . . . ? . . ? . . . |
9679af58bfe7
snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9
Paul Eggert <eggert@cs.ucla.edu>
parents:
13918
diff
changeset
|
1565 dnl BeOS # # . # # # . ? # . ? . # ? . . ? . . . |
15351 | 1566 dnl old mingw / msvcrt # # # # # # . . # # . # # ? . # # # . . |
15591
2171e9d2231b
*printf: Add support for MSVC compiler.
Bruno Haible <bruno@clisp.org>
parents:
15351
diff
changeset
|
1567 dnl MSVC 9 # # # # # # # . # # . # # ? # # # # . . |
15351 | 1568 dnl mingw 2009-2011 . # . # . . . . # # . . . ? . . . . . . |
1569 dnl mingw-w64 2011 # # # # # # . . # # . # # ? . # # # . . |