summaryrefslogtreecommitdiffstats
path: root/gl/m4/iconv.m4
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2021-11-17 01:05:54 +0100
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2022-07-24 19:35:11 +0200
commita405fc138596f552581d2011fd6de02d5c8186c4 (patch)
tree4c084700b5cb5e9fcedf982a2d921bbc41d9935a /gl/m4/iconv.m4
parent9f2a9ca3d72023ff9b5707d1872c54d65edc9017 (diff)
downloadmonitoring-plugins-a405fc138596f552581d2011fd6de02d5c8186c4.tar.gz
Sync with the latest Gnulib code (1a268176f)
Diffstat (limited to 'gl/m4/iconv.m4')
-rw-r--r--gl/m4/iconv.m4171
1 files changed, 93 insertions, 78 deletions
diff --git a/gl/m4/iconv.m4 b/gl/m4/iconv.m4
index a5036465..d0e61de2 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 24
2dnl Copyright (C) 2000-2002, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2007-2014, 2016-2021 Free Software Foundation,
3dnl Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
6 7
7dnl From Bruno Haible. 8dnl From Bruno Haible.
8 9
10AC_PREREQ([2.64])
11
12dnl Note: AM_ICONV is documented in the GNU gettext manual
13dnl <https://www.gnu.org/software/gettext/manual/html_node/AM_005fICONV.html>.
14dnl Don't make changes that are incompatible with that documentation!
15
9AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], 16AC_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>
79int 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" ;;
178changequote(,)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
183changequote([,])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,8 +232,7 @@ changequote([,])dnl
209 AC_SUBST([LTLIBICONV]) 232 AC_SUBST([LTLIBICONV])
210]) 233])
211 234
212dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to 235dnl Define AM_ICONV using AC_DEFUN_ONCE, in order to avoid warnings like
213dnl avoid warnings like
214dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". 236dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
215dnl This is tricky because of the way 'aclocal' is implemented: 237dnl This is tricky because of the way 'aclocal' is implemented:
216dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. 238dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
@@ -218,51 +240,44 @@ dnl Otherwise aclocal's initial scan pass would miss the macro definition.
218dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. 240dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
219dnl Otherwise aclocal would emit many "Use of uninitialized value $1" 241dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
220dnl warnings. 242dnl warnings.
221m4_define([gl_iconv_AC_DEFUN], 243AC_DEFUN_ONCE([AM_ICONV],
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])]])]))
230gl_iconv_AC_DEFUN([AM_ICONV],
231[ 244[
232 AM_ICONV_LINK 245 AM_ICONV_LINK
233 if test "$am_cv_func_iconv" = yes; then 246 if test "$am_cv_func_iconv" = yes; then
234 AC_MSG_CHECKING([for iconv declaration]) 247 AC_CACHE_CHECK([whether iconv is compatible with its POSIX signature],
235 AC_CACHE_VAL([am_cv_proto_iconv], [ 248 [gl_cv_iconv_nonconst],
236 AC_COMPILE_IFELSE( 249 [AC_COMPILE_IFELSE(
237 [AC_LANG_PROGRAM( 250 [AC_LANG_PROGRAM(
238 [[ 251 [[
239#include <stdlib.h> 252#include <stdlib.h>
240#include <iconv.h> 253#include <iconv.h>
241extern 254extern
242#ifdef __cplusplus 255#ifdef __cplusplus
243"C" 256"C"
244#endif 257#endif
245#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
246size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); 258size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
247#else 259 ]],
248size_t iconv(); 260 [[]])],
249#endif 261 [gl_cv_iconv_nonconst=yes],
250 ]], 262 [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 ]) 263 ])
264 else
265 dnl When compiling GNU libiconv on a system that does not have iconv yet,
266 dnl pick the POSIX compliant declaration without 'const'.
267 gl_cv_iconv_nonconst=yes
267 fi 268 fi
269 if test $gl_cv_iconv_nonconst = yes; then
270 iconv_arg1=""
271 else
272 iconv_arg1="const"
273 fi
274 AC_DEFINE_UNQUOTED([ICONV_CONST], [$iconv_arg1],
275 [Define as const if the declaration of iconv() needs const.])
276 dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
277 m4_ifdef([gl_ICONV_H_DEFAULTS],
278 [AC_REQUIRE([gl_ICONV_H_DEFAULTS])
279 if test $gl_cv_iconv_nonconst != yes; then
280 ICONV_CONST="const"
281 fi
282 ])
268]) 283])