diff options
Diffstat (limited to 'm4/iconv.m4')
-rw-r--r-- | m4/iconv.m4 | 118 |
1 files changed, 69 insertions, 49 deletions
diff --git a/m4/iconv.m4 b/m4/iconv.m4 index 41aa44a56..e593b7270 100644 --- a/m4/iconv.m4 +++ b/m4/iconv.m4 | |||
@@ -1,5 +1,6 @@ | |||
1 | # iconv.m4 serial 18 (gettext-0.18.2) | 1 | # iconv.m4 serial 21 |
2 | dnl Copyright (C) 2000-2002, 2007-2013 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2000-2002, 2007-2014, 2016-2020 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. |
@@ -29,7 +30,7 @@ AC_DEFUN([AM_ICONV_LINK], | |||
29 | 30 | ||
30 | dnl Add $INCICONV to CPPFLAGS before performing the following checks, | 31 | dnl Add $INCICONV to CPPFLAGS before performing the following checks, |
31 | dnl because if the user has installed libiconv and not disabled its use | 32 | dnl because if the user has installed libiconv and not disabled its use |
32 | dnl via --without-libiconv-prefix, they want to use it. The first | 33 | dnl via --without-libiconv-prefix, he wants to use it. The first |
33 | dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed. | 34 | dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed. |
34 | am_save_CPPFLAGS="$CPPFLAGS" | 35 | am_save_CPPFLAGS="$CPPFLAGS" |
35 | AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) | 36 | AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) |
@@ -72,27 +73,33 @@ AC_DEFUN([AM_ICONV_LINK], | |||
72 | if test $am_cv_lib_iconv = yes; then | 73 | if test $am_cv_lib_iconv = yes; then |
73 | LIBS="$LIBS $LIBICONV" | 74 | LIBS="$LIBS $LIBICONV" |
74 | fi | 75 | fi |
75 | AC_RUN_IFELSE( | 76 | am_cv_func_iconv_works=no |
76 | [AC_LANG_SOURCE([[ | 77 | for ac_iconv_const in '' 'const'; do |
78 | AC_RUN_IFELSE( | ||
79 | [AC_LANG_PROGRAM( | ||
80 | [[ | ||
77 | #include <iconv.h> | 81 | #include <iconv.h> |
78 | #include <string.h> | 82 | #include <string.h> |
79 | int main () | 83 | |
80 | { | 84 | #ifndef ICONV_CONST |
81 | int result = 0; | 85 | # define ICONV_CONST $ac_iconv_const |
86 | #endif | ||
87 | ]], | ||
88 | [[int result = 0; | ||
82 | /* Test against AIX 5.1 bug: Failures are not distinguishable from successful | 89 | /* Test against AIX 5.1 bug: Failures are not distinguishable from successful |
83 | returns. */ | 90 | returns. */ |
84 | { | 91 | { |
85 | iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); | 92 | iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); |
86 | if (cd_utf8_to_88591 != (iconv_t)(-1)) | 93 | if (cd_utf8_to_88591 != (iconv_t)(-1)) |
87 | { | 94 | { |
88 | static const char input[] = "\342\202\254"; /* EURO SIGN */ | 95 | static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ |
89 | char buf[10]; | 96 | char buf[10]; |
90 | const char *inptr = input; | 97 | ICONV_CONST char *inptr = input; |
91 | size_t inbytesleft = strlen (input); | 98 | size_t inbytesleft = strlen (input); |
92 | char *outptr = buf; | 99 | char *outptr = buf; |
93 | size_t outbytesleft = sizeof (buf); | 100 | size_t outbytesleft = sizeof (buf); |
94 | size_t res = iconv (cd_utf8_to_88591, | 101 | size_t res = iconv (cd_utf8_to_88591, |
95 | (char **) &inptr, &inbytesleft, | 102 | &inptr, &inbytesleft, |
96 | &outptr, &outbytesleft); | 103 | &outptr, &outbytesleft); |
97 | if (res == 0) | 104 | if (res == 0) |
98 | result |= 1; | 105 | result |= 1; |
@@ -105,14 +112,14 @@ int main () | |||
105 | iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); | 112 | iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); |
106 | if (cd_ascii_to_88591 != (iconv_t)(-1)) | 113 | if (cd_ascii_to_88591 != (iconv_t)(-1)) |
107 | { | 114 | { |
108 | static const char input[] = "\263"; | 115 | static ICONV_CONST char input[] = "\263"; |
109 | char buf[10]; | 116 | char buf[10]; |
110 | const char *inptr = input; | 117 | ICONV_CONST char *inptr = input; |
111 | size_t inbytesleft = strlen (input); | 118 | size_t inbytesleft = strlen (input); |
112 | char *outptr = buf; | 119 | char *outptr = buf; |
113 | size_t outbytesleft = sizeof (buf); | 120 | size_t outbytesleft = sizeof (buf); |
114 | size_t res = iconv (cd_ascii_to_88591, | 121 | size_t res = iconv (cd_ascii_to_88591, |
115 | (char **) &inptr, &inbytesleft, | 122 | &inptr, &inbytesleft, |
116 | &outptr, &outbytesleft); | 123 | &outptr, &outbytesleft); |
117 | if (res == 0) | 124 | if (res == 0) |
118 | result |= 2; | 125 | result |= 2; |
@@ -124,14 +131,14 @@ int main () | |||
124 | iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); | 131 | iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); |
125 | if (cd_88591_to_utf8 != (iconv_t)(-1)) | 132 | if (cd_88591_to_utf8 != (iconv_t)(-1)) |
126 | { | 133 | { |
127 | static const char input[] = "\304"; | 134 | static ICONV_CONST char input[] = "\304"; |
128 | static char buf[2] = { (char)0xDE, (char)0xAD }; | 135 | static char buf[2] = { (char)0xDE, (char)0xAD }; |
129 | const char *inptr = input; | 136 | ICONV_CONST char *inptr = input; |
130 | size_t inbytesleft = 1; | 137 | size_t inbytesleft = 1; |
131 | char *outptr = buf; | 138 | char *outptr = buf; |
132 | size_t outbytesleft = 1; | 139 | size_t outbytesleft = 1; |
133 | size_t res = iconv (cd_88591_to_utf8, | 140 | size_t res = iconv (cd_88591_to_utf8, |
134 | (char **) &inptr, &inbytesleft, | 141 | &inptr, &inbytesleft, |
135 | &outptr, &outbytesleft); | 142 | &outptr, &outbytesleft); |
136 | if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) | 143 | if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) |
137 | result |= 4; | 144 | result |= 4; |
@@ -144,14 +151,14 @@ int main () | |||
144 | iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); | 151 | iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); |
145 | if (cd_88591_to_utf8 != (iconv_t)(-1)) | 152 | if (cd_88591_to_utf8 != (iconv_t)(-1)) |
146 | { | 153 | { |
147 | static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; | 154 | static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; |
148 | char buf[50]; | 155 | char buf[50]; |
149 | const char *inptr = input; | 156 | ICONV_CONST char *inptr = input; |
150 | size_t inbytesleft = strlen (input); | 157 | size_t inbytesleft = strlen (input); |
151 | char *outptr = buf; | 158 | char *outptr = buf; |
152 | size_t outbytesleft = sizeof (buf); | 159 | size_t outbytesleft = sizeof (buf); |
153 | size_t res = iconv (cd_88591_to_utf8, | 160 | size_t res = iconv (cd_88591_to_utf8, |
154 | (char **) &inptr, &inbytesleft, | 161 | &inptr, &inbytesleft, |
155 | &outptr, &outbytesleft); | 162 | &outptr, &outbytesleft); |
156 | if ((int)res > 0) | 163 | if ((int)res > 0) |
157 | result |= 8; | 164 | result |= 8; |
@@ -161,27 +168,36 @@ int main () | |||
161 | #endif | 168 | #endif |
162 | /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is | 169 | /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is |
163 | provided. */ | 170 | provided. */ |
164 | if (/* Try standardized names. */ | 171 | { |
165 | iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) | 172 | /* Try standardized names. */ |
166 | /* Try IRIX, OSF/1 names. */ | 173 | iconv_t cd1 = iconv_open ("UTF-8", "EUC-JP"); |
167 | && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) | 174 | /* Try IRIX, OSF/1 names. */ |
168 | /* Try AIX names. */ | 175 | iconv_t cd2 = iconv_open ("UTF-8", "eucJP"); |
169 | && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) | 176 | /* Try AIX names. */ |
170 | /* Try HP-UX names. */ | 177 | iconv_t cd3 = iconv_open ("UTF-8", "IBM-eucJP"); |
171 | && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) | 178 | /* Try HP-UX names. */ |
172 | result |= 16; | 179 | iconv_t cd4 = iconv_open ("utf8", "eucJP"); |
180 | if (cd1 == (iconv_t)(-1) && cd2 == (iconv_t)(-1) | ||
181 | && cd3 == (iconv_t)(-1) && cd4 == (iconv_t)(-1)) | ||
182 | result |= 16; | ||
183 | if (cd1 != (iconv_t)(-1)) | ||
184 | iconv_close (cd1); | ||
185 | if (cd2 != (iconv_t)(-1)) | ||
186 | iconv_close (cd2); | ||
187 | if (cd3 != (iconv_t)(-1)) | ||
188 | iconv_close (cd3); | ||
189 | if (cd4 != (iconv_t)(-1)) | ||
190 | iconv_close (cd4); | ||
191 | } | ||
173 | return result; | 192 | return result; |
174 | }]])], | 193 | ]])], |
175 | [am_cv_func_iconv_works=yes], | 194 | [am_cv_func_iconv_works=yes], , |
176 | [am_cv_func_iconv_works=no], | 195 | [case "$host_os" in |
177 | [ | 196 | aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; |
178 | changequote(,)dnl | 197 | *) am_cv_func_iconv_works="guessing yes" ;; |
179 | case "$host_os" in | 198 | esac]) |
180 | aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; | 199 | test "$am_cv_func_iconv_works" = no || break |
181 | *) am_cv_func_iconv_works="guessing yes" ;; | 200 | done |
182 | esac | ||
183 | changequote([,])dnl | ||
184 | ]) | ||
185 | LIBS="$am_save_LIBS" | 201 | LIBS="$am_save_LIBS" |
186 | ]) | 202 | ]) |
187 | case "$am_cv_func_iconv_works" in | 203 | case "$am_cv_func_iconv_works" in |
@@ -255,14 +271,18 @@ size_t iconv(); | |||
255 | am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` | 271 | am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` |
256 | AC_MSG_RESULT([ | 272 | AC_MSG_RESULT([ |
257 | $am_cv_proto_iconv]) | 273 | $am_cv_proto_iconv]) |
258 | AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], | 274 | else |
259 | [Define as const if the declaration of iconv() needs const.]) | 275 | dnl When compiling GNU libiconv on a system that does not have iconv yet, |
260 | dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>. | 276 | dnl pick the POSIX compliant declaration without 'const'. |
261 | m4_ifdef([gl_ICONV_H_DEFAULTS], | 277 | am_cv_proto_iconv_arg1="" |
262 | [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) | ||
263 | if test -n "$am_cv_proto_iconv_arg1"; then | ||
264 | ICONV_CONST="const" | ||
265 | fi | ||
266 | ]) | ||
267 | fi | 278 | fi |
279 | AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], | ||
280 | [Define as const if the declaration of iconv() needs const.]) | ||
281 | dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>. | ||
282 | m4_ifdef([gl_ICONV_H_DEFAULTS], | ||
283 | [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) | ||
284 | if test -n "$am_cv_proto_iconv_arg1"; then | ||
285 | ICONV_CONST="const" | ||
286 | fi | ||
287 | ]) | ||
268 | ]) | 288 | ]) |