diff options
Diffstat (limited to 'gl/m4/iconv.m4')
-rw-r--r-- | gl/m4/iconv.m4 | 193 |
1 files changed, 109 insertions, 84 deletions
diff --git a/gl/m4/iconv.m4 b/gl/m4/iconv.m4 index a5036465..2065c977 100644 --- a/gl/m4/iconv.m4 +++ b/gl/m4/iconv.m4 | |||
@@ -1,11 +1,18 @@ | |||
1 | # iconv.m4 serial 18 (gettext-0.18.2) | 1 | # iconv.m4 serial 26 |
2 | dnl Copyright (C) 2000-2002, 2007-2013 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2000-2002, 2007-2014, 2016-2022 Free Software Foundation, |
3 | dnl Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | 4 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 5 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 6 | dnl with or without modifications, as long as this notice is preserved. |
6 | 7 | ||
7 | dnl From Bruno Haible. | 8 | dnl From Bruno Haible. |
8 | 9 | ||
10 | AC_PREREQ([2.64]) | ||
11 | |||
12 | dnl Note: AM_ICONV is documented in the GNU gettext manual | ||
13 | dnl <https://www.gnu.org/software/gettext/manual/html_node/AM_005fICONV.html>. | ||
14 | dnl Don't make changes that are incompatible with that documentation! | ||
15 | |||
9 | AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], | 16 | AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], |
10 | [ | 17 | [ |
11 | dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. | 18 | dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. |
@@ -72,27 +79,34 @@ AC_DEFUN([AM_ICONV_LINK], | |||
72 | if test $am_cv_lib_iconv = yes; then | 79 | if test $am_cv_lib_iconv = yes; then |
73 | LIBS="$LIBS $LIBICONV" | 80 | LIBS="$LIBS $LIBICONV" |
74 | fi | 81 | fi |
75 | AC_RUN_IFELSE( | 82 | am_cv_func_iconv_works=no |
76 | [AC_LANG_SOURCE([[ | 83 | for ac_iconv_const in '' 'const'; do |
84 | AC_RUN_IFELSE( | ||
85 | [AC_LANG_PROGRAM( | ||
86 | [[ | ||
77 | #include <iconv.h> | 87 | #include <iconv.h> |
78 | #include <string.h> | 88 | #include <string.h> |
79 | int main () | 89 | |
80 | { | 90 | #ifndef ICONV_CONST |
81 | int result = 0; | 91 | # define ICONV_CONST $ac_iconv_const |
82 | /* Test against AIX 5.1 bug: Failures are not distinguishable from successful | 92 | #endif |
83 | returns. */ | 93 | ]], |
94 | [[int result = 0; | ||
95 | /* Test against AIX 5.1...7.2 bug: Failures are not distinguishable from | ||
96 | successful returns. This is even documented in | ||
97 | <https://www.ibm.com/support/knowledgecenter/ssw_aix_72/i_bostechref/iconv.html> */ | ||
84 | { | 98 | { |
85 | iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); | 99 | iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); |
86 | if (cd_utf8_to_88591 != (iconv_t)(-1)) | 100 | if (cd_utf8_to_88591 != (iconv_t)(-1)) |
87 | { | 101 | { |
88 | static const char input[] = "\342\202\254"; /* EURO SIGN */ | 102 | static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ |
89 | char buf[10]; | 103 | char buf[10]; |
90 | const char *inptr = input; | 104 | ICONV_CONST char *inptr = input; |
91 | size_t inbytesleft = strlen (input); | 105 | size_t inbytesleft = strlen (input); |
92 | char *outptr = buf; | 106 | char *outptr = buf; |
93 | size_t outbytesleft = sizeof (buf); | 107 | size_t outbytesleft = sizeof (buf); |
94 | size_t res = iconv (cd_utf8_to_88591, | 108 | size_t res = iconv (cd_utf8_to_88591, |
95 | (char **) &inptr, &inbytesleft, | 109 | &inptr, &inbytesleft, |
96 | &outptr, &outbytesleft); | 110 | &outptr, &outbytesleft); |
97 | if (res == 0) | 111 | if (res == 0) |
98 | result |= 1; | 112 | result |= 1; |
@@ -105,14 +119,14 @@ int main () | |||
105 | iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); | 119 | iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); |
106 | if (cd_ascii_to_88591 != (iconv_t)(-1)) | 120 | if (cd_ascii_to_88591 != (iconv_t)(-1)) |
107 | { | 121 | { |
108 | static const char input[] = "\263"; | 122 | static ICONV_CONST char input[] = "\263"; |
109 | char buf[10]; | 123 | char buf[10]; |
110 | const char *inptr = input; | 124 | ICONV_CONST char *inptr = input; |
111 | size_t inbytesleft = strlen (input); | 125 | size_t inbytesleft = strlen (input); |
112 | char *outptr = buf; | 126 | char *outptr = buf; |
113 | size_t outbytesleft = sizeof (buf); | 127 | size_t outbytesleft = sizeof (buf); |
114 | size_t res = iconv (cd_ascii_to_88591, | 128 | size_t res = iconv (cd_ascii_to_88591, |
115 | (char **) &inptr, &inbytesleft, | 129 | &inptr, &inbytesleft, |
116 | &outptr, &outbytesleft); | 130 | &outptr, &outbytesleft); |
117 | if (res == 0) | 131 | if (res == 0) |
118 | result |= 2; | 132 | result |= 2; |
@@ -124,14 +138,14 @@ int main () | |||
124 | iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); | 138 | iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); |
125 | if (cd_88591_to_utf8 != (iconv_t)(-1)) | 139 | if (cd_88591_to_utf8 != (iconv_t)(-1)) |
126 | { | 140 | { |
127 | static const char input[] = "\304"; | 141 | static ICONV_CONST char input[] = "\304"; |
128 | static char buf[2] = { (char)0xDE, (char)0xAD }; | 142 | static char buf[2] = { (char)0xDE, (char)0xAD }; |
129 | const char *inptr = input; | 143 | ICONV_CONST char *inptr = input; |
130 | size_t inbytesleft = 1; | 144 | size_t inbytesleft = 1; |
131 | char *outptr = buf; | 145 | char *outptr = buf; |
132 | size_t outbytesleft = 1; | 146 | size_t outbytesleft = 1; |
133 | size_t res = iconv (cd_88591_to_utf8, | 147 | size_t res = iconv (cd_88591_to_utf8, |
134 | (char **) &inptr, &inbytesleft, | 148 | &inptr, &inbytesleft, |
135 | &outptr, &outbytesleft); | 149 | &outptr, &outbytesleft); |
136 | if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) | 150 | if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) |
137 | result |= 4; | 151 | result |= 4; |
@@ -144,14 +158,14 @@ int main () | |||
144 | iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); | 158 | iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); |
145 | if (cd_88591_to_utf8 != (iconv_t)(-1)) | 159 | if (cd_88591_to_utf8 != (iconv_t)(-1)) |
146 | { | 160 | { |
147 | static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; | 161 | static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; |
148 | char buf[50]; | 162 | char buf[50]; |
149 | const char *inptr = input; | 163 | ICONV_CONST char *inptr = input; |
150 | size_t inbytesleft = strlen (input); | 164 | size_t inbytesleft = strlen (input); |
151 | char *outptr = buf; | 165 | char *outptr = buf; |
152 | size_t outbytesleft = sizeof (buf); | 166 | size_t outbytesleft = sizeof (buf); |
153 | size_t res = iconv (cd_88591_to_utf8, | 167 | size_t res = iconv (cd_88591_to_utf8, |
154 | (char **) &inptr, &inbytesleft, | 168 | &inptr, &inbytesleft, |
155 | &outptr, &outbytesleft); | 169 | &outptr, &outbytesleft); |
156 | if ((int)res > 0) | 170 | if ((int)res > 0) |
157 | result |= 8; | 171 | result |= 8; |
@@ -161,27 +175,36 @@ int main () | |||
161 | #endif | 175 | #endif |
162 | /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is | 176 | /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is |
163 | provided. */ | 177 | provided. */ |
164 | if (/* Try standardized names. */ | 178 | { |
165 | iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) | 179 | /* Try standardized names. */ |
166 | /* Try IRIX, OSF/1 names. */ | 180 | iconv_t cd1 = iconv_open ("UTF-8", "EUC-JP"); |
167 | && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) | 181 | /* Try IRIX, OSF/1 names. */ |
168 | /* Try AIX names. */ | 182 | iconv_t cd2 = iconv_open ("UTF-8", "eucJP"); |
169 | && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) | 183 | /* Try AIX names. */ |
170 | /* Try HP-UX names. */ | 184 | iconv_t cd3 = iconv_open ("UTF-8", "IBM-eucJP"); |
171 | && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) | 185 | /* Try HP-UX names. */ |
172 | result |= 16; | 186 | iconv_t cd4 = iconv_open ("utf8", "eucJP"); |
187 | if (cd1 == (iconv_t)(-1) && cd2 == (iconv_t)(-1) | ||
188 | && cd3 == (iconv_t)(-1) && cd4 == (iconv_t)(-1)) | ||
189 | result |= 16; | ||
190 | if (cd1 != (iconv_t)(-1)) | ||
191 | iconv_close (cd1); | ||
192 | if (cd2 != (iconv_t)(-1)) | ||
193 | iconv_close (cd2); | ||
194 | if (cd3 != (iconv_t)(-1)) | ||
195 | iconv_close (cd3); | ||
196 | if (cd4 != (iconv_t)(-1)) | ||
197 | iconv_close (cd4); | ||
198 | } | ||
173 | return result; | 199 | return result; |
174 | }]])], | 200 | ]])], |
175 | [am_cv_func_iconv_works=yes], | 201 | [am_cv_func_iconv_works=yes], , |
176 | [am_cv_func_iconv_works=no], | 202 | [case "$host_os" in |
177 | [ | 203 | aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; |
178 | changequote(,)dnl | 204 | *) am_cv_func_iconv_works="guessing yes" ;; |
179 | case "$host_os" in | 205 | esac]) |
180 | aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; | 206 | test "$am_cv_func_iconv_works" = no || break |
181 | *) am_cv_func_iconv_works="guessing yes" ;; | 207 | done |
182 | esac | ||
183 | changequote([,])dnl | ||
184 | ]) | ||
185 | LIBS="$am_save_LIBS" | 208 | LIBS="$am_save_LIBS" |
186 | ]) | 209 | ]) |
187 | case "$am_cv_func_iconv_works" in | 210 | case "$am_cv_func_iconv_works" in |
@@ -209,60 +232,62 @@ changequote([,])dnl | |||
209 | AC_SUBST([LTLIBICONV]) | 232 | AC_SUBST([LTLIBICONV]) |
210 | ]) | 233 | ]) |
211 | 234 | ||
212 | dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to | 235 | dnl Define AM_ICONV using AC_DEFUN_ONCE, in order to avoid warnings like |
213 | dnl avoid warnings like | ||
214 | dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". | 236 | dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". |
215 | dnl This is tricky because of the way 'aclocal' is implemented: | 237 | AC_DEFUN_ONCE([AM_ICONV], |
216 | dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. | ||
217 | dnl Otherwise aclocal's initial scan pass would miss the macro definition. | ||
218 | dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. | ||
219 | dnl Otherwise aclocal would emit many "Use of uninitialized value $1" | ||
220 | dnl warnings. | ||
221 | m4_define([gl_iconv_AC_DEFUN], | ||
222 | m4_version_prereq([2.64], | ||
223 | [[AC_DEFUN_ONCE( | ||
224 | [$1], [$2])]], | ||
225 | [m4_ifdef([gl_00GNULIB], | ||
226 | [[AC_DEFUN_ONCE( | ||
227 | [$1], [$2])]], | ||
228 | [[AC_DEFUN( | ||
229 | [$1], [$2])]])])) | ||
230 | gl_iconv_AC_DEFUN([AM_ICONV], | ||
231 | [ | 238 | [ |
232 | AM_ICONV_LINK | 239 | AM_ICONV_LINK |
233 | if test "$am_cv_func_iconv" = yes; then | 240 | if test "$am_cv_func_iconv" = yes; then |
234 | AC_MSG_CHECKING([for iconv declaration]) | 241 | AC_CACHE_CHECK([whether iconv is compatible with its POSIX signature], |
235 | AC_CACHE_VAL([am_cv_proto_iconv], [ | 242 | [gl_cv_iconv_nonconst], |
236 | AC_COMPILE_IFELSE( | 243 | [AC_COMPILE_IFELSE( |
237 | [AC_LANG_PROGRAM( | 244 | [AC_LANG_PROGRAM( |
238 | [[ | 245 | [[ |
239 | #include <stdlib.h> | 246 | #include <stdlib.h> |
240 | #include <iconv.h> | 247 | #include <iconv.h> |
241 | extern | 248 | extern |
242 | #ifdef __cplusplus | 249 | #ifdef __cplusplus |
243 | "C" | 250 | "C" |
244 | #endif | 251 | #endif |
245 | #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) | ||
246 | size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); | 252 | size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); |
247 | #else | 253 | ]], |
248 | size_t iconv(); | 254 | [[]])], |
249 | #endif | 255 | [gl_cv_iconv_nonconst=yes], |
250 | ]], | 256 | [gl_cv_iconv_nonconst=no]) |
251 | [[]])], | ||
252 | [am_cv_proto_iconv_arg1=""], | ||
253 | [am_cv_proto_iconv_arg1="const"]) | ||
254 | am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) | ||
255 | am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` | ||
256 | AC_MSG_RESULT([ | ||
257 | $am_cv_proto_iconv]) | ||
258 | AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], | ||
259 | [Define as const if the declaration of iconv() needs const.]) | ||
260 | dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>. | ||
261 | m4_ifdef([gl_ICONV_H_DEFAULTS], | ||
262 | [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) | ||
263 | if test -n "$am_cv_proto_iconv_arg1"; then | ||
264 | ICONV_CONST="const" | ||
265 | fi | ||
266 | ]) | 257 | ]) |
258 | else | ||
259 | dnl When compiling GNU libiconv on a system that does not have iconv yet, | ||
260 | dnl pick the POSIX compliant declaration without 'const'. | ||
261 | gl_cv_iconv_nonconst=yes | ||
262 | fi | ||
263 | if test $gl_cv_iconv_nonconst = yes; then | ||
264 | iconv_arg1="" | ||
265 | else | ||
266 | iconv_arg1="const" | ||
267 | fi | ||
268 | AC_DEFINE_UNQUOTED([ICONV_CONST], [$iconv_arg1], | ||
269 | [Define as const if the declaration of iconv() needs const.]) | ||
270 | dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>. | ||
271 | m4_ifdef([gl_ICONV_H_DEFAULTS], | ||
272 | [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) | ||
273 | if test $gl_cv_iconv_nonconst != yes; then | ||
274 | ICONV_CONST="const" | ||
275 | fi | ||
276 | ]) | ||
277 | |||
278 | dnl A summary result, for those packages which want to print a summary at the | ||
279 | dnl end of the configuration. | ||
280 | if test "$am_func_iconv" = yes; then | ||
281 | if test -n "$LIBICONV"; then | ||
282 | am_cv_func_iconv_summary='yes, in libiconv' | ||
283 | else | ||
284 | am_cv_func_iconv_summary='yes, in libc' | ||
285 | fi | ||
286 | else | ||
287 | if test "$am_cv_func_iconv" = yes; then | ||
288 | am_cv_func_iconv_summary='not working, consider installing GNU libiconv' | ||
289 | else | ||
290 | am_cv_func_iconv_summary='no, consider installing GNU libiconv' | ||
291 | fi | ||
267 | fi | 292 | fi |
268 | ]) | 293 | ]) |