summaryrefslogtreecommitdiffstats
path: root/gl/m4/iconv.m4
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-08-19 23:27:12 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-08-19 23:27:12 +0200
commit26fbe7f1e68bb0c96da32491efcf3696fe6c299b (patch)
treec4d95289187a64e9c7517bf73d8208026c3d2fb3 /gl/m4/iconv.m4
parent5f79e3e9f62ca5487d9881973149136ba1d19d3e (diff)
downloadmonitoring-plugins-26fbe7f1e68bb0c96da32491efcf3696fe6c299b.tar.gz
Sync with the latest Gnulib code (6f2d632)
Diffstat (limited to 'gl/m4/iconv.m4')
-rw-r--r--gl/m4/iconv.m4110
1 files changed, 82 insertions, 28 deletions
diff --git a/gl/m4/iconv.m4 b/gl/m4/iconv.m4
index e2041b9b..a5036465 100644
--- a/gl/m4/iconv.m4
+++ b/gl/m4/iconv.m4
@@ -1,5 +1,5 @@
1# iconv.m4 serial 11 (gettext-0.18.1) 1# iconv.m4 serial 18 (gettext-0.18.2)
2dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2007-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -30,27 +30,35 @@ AC_DEFUN([AM_ICONV_LINK],
30 dnl Add $INCICONV to CPPFLAGS before performing the following checks, 30 dnl Add $INCICONV to CPPFLAGS before performing the following checks,
31 dnl because if the user has installed libiconv and not disabled its use 31 dnl because if the user has installed libiconv and not disabled its use
32 dnl via --without-libiconv-prefix, he wants to use it. The first 32 dnl via --without-libiconv-prefix, he wants to use it. The first
33 dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. 33 dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
34 am_save_CPPFLAGS="$CPPFLAGS" 34 am_save_CPPFLAGS="$CPPFLAGS"
35 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) 35 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
36 36
37 AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ 37 AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
38 am_cv_func_iconv="no, consider installing GNU libiconv" 38 am_cv_func_iconv="no, consider installing GNU libiconv"
39 am_cv_lib_iconv=no 39 am_cv_lib_iconv=no
40 AC_TRY_LINK([#include <stdlib.h> 40 AC_LINK_IFELSE(
41#include <iconv.h>], 41 [AC_LANG_PROGRAM(
42 [iconv_t cd = iconv_open("",""); 42 [[
43 iconv(cd,NULL,NULL,NULL,NULL); 43#include <stdlib.h>
44 iconv_close(cd);], 44#include <iconv.h>
45 ]],
46 [[iconv_t cd = iconv_open("","");
47 iconv(cd,NULL,NULL,NULL,NULL);
48 iconv_close(cd);]])],
45 [am_cv_func_iconv=yes]) 49 [am_cv_func_iconv=yes])
46 if test "$am_cv_func_iconv" != yes; then 50 if test "$am_cv_func_iconv" != yes; then
47 am_save_LIBS="$LIBS" 51 am_save_LIBS="$LIBS"
48 LIBS="$LIBS $LIBICONV" 52 LIBS="$LIBS $LIBICONV"
49 AC_TRY_LINK([#include <stdlib.h> 53 AC_LINK_IFELSE(
50#include <iconv.h>], 54 [AC_LANG_PROGRAM(
51 [iconv_t cd = iconv_open("",""); 55 [[
52 iconv(cd,NULL,NULL,NULL,NULL); 56#include <stdlib.h>
53 iconv_close(cd);], 57#include <iconv.h>
58 ]],
59 [[iconv_t cd = iconv_open("","");
60 iconv(cd,NULL,NULL,NULL,NULL);
61 iconv_close(cd);]])],
54 [am_cv_lib_iconv=yes] 62 [am_cv_lib_iconv=yes]
55 [am_cv_func_iconv=yes]) 63 [am_cv_func_iconv=yes])
56 LIBS="$am_save_LIBS" 64 LIBS="$am_save_LIBS"
@@ -58,16 +66,19 @@ AC_DEFUN([AM_ICONV_LINK],
58 ]) 66 ])
59 if test "$am_cv_func_iconv" = yes; then 67 if test "$am_cv_func_iconv" = yes; then
60 AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ 68 AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
61 dnl This tests against bugs in AIX 5.1, HP-UX 11.11, Solaris 10. 69 dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
70 dnl Solaris 10.
62 am_save_LIBS="$LIBS" 71 am_save_LIBS="$LIBS"
63 if test $am_cv_lib_iconv = yes; then 72 if test $am_cv_lib_iconv = yes; then
64 LIBS="$LIBS $LIBICONV" 73 LIBS="$LIBS $LIBICONV"
65 fi 74 fi
66 AC_TRY_RUN([ 75 AC_RUN_IFELSE(
76 [AC_LANG_SOURCE([[
67#include <iconv.h> 77#include <iconv.h>
68#include <string.h> 78#include <string.h>
69int main () 79int main ()
70{ 80{
81 int result = 0;
71 /* Test against AIX 5.1 bug: Failures are not distinguishable from successful 82 /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
72 returns. */ 83 returns. */
73 { 84 {
@@ -84,7 +95,8 @@ int main ()
84 (char **) &inptr, &inbytesleft, 95 (char **) &inptr, &inbytesleft,
85 &outptr, &outbytesleft); 96 &outptr, &outbytesleft);
86 if (res == 0) 97 if (res == 0)
87 return 1; 98 result |= 1;
99 iconv_close (cd_utf8_to_88591);
88 } 100 }
89 } 101 }
90 /* Test against Solaris 10 bug: Failures are not distinguishable from 102 /* Test against Solaris 10 bug: Failures are not distinguishable from
@@ -103,7 +115,27 @@ int main ()
103 (char **) &inptr, &inbytesleft, 115 (char **) &inptr, &inbytesleft,
104 &outptr, &outbytesleft); 116 &outptr, &outbytesleft);
105 if (res == 0) 117 if (res == 0)
106 return 1; 118 result |= 2;
119 iconv_close (cd_ascii_to_88591);
120 }
121 }
122 /* Test against AIX 6.1..7.1 bug: Buffer overrun. */
123 {
124 iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
125 if (cd_88591_to_utf8 != (iconv_t)(-1))
126 {
127 static const char input[] = "\304";
128 static char buf[2] = { (char)0xDE, (char)0xAD };
129 const char *inptr = input;
130 size_t inbytesleft = 1;
131 char *outptr = buf;
132 size_t outbytesleft = 1;
133 size_t res = iconv (cd_88591_to_utf8,
134 (char **) &inptr, &inbytesleft,
135 &outptr, &outbytesleft);
136 if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
137 result |= 4;
138 iconv_close (cd_88591_to_utf8);
107 } 139 }
108 } 140 }
109#if 0 /* This bug could be worked around by the caller. */ 141#if 0 /* This bug could be worked around by the caller. */
@@ -122,7 +154,8 @@ int main ()
122 (char **) &inptr, &inbytesleft, 154 (char **) &inptr, &inbytesleft,
123 &outptr, &outbytesleft); 155 &outptr, &outbytesleft);
124 if ((int)res > 0) 156 if ((int)res > 0)
125 return 1; 157 result |= 8;
158 iconv_close (cd_88591_to_utf8);
126 } 159 }
127 } 160 }
128#endif 161#endif
@@ -136,13 +169,19 @@ int main ()
136 && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) 169 && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
137 /* Try HP-UX names. */ 170 /* Try HP-UX names. */
138 && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) 171 && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
139 return 1; 172 result |= 16;
140 return 0; 173 return result;
141}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no], 174}]])],
142 [case "$host_os" in 175 [am_cv_func_iconv_works=yes],
176 [am_cv_func_iconv_works=no],
177 [
178changequote(,)dnl
179 case "$host_os" in
143 aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; 180 aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
144 *) am_cv_func_iconv_works="guessing yes" ;; 181 *) am_cv_func_iconv_works="guessing yes" ;;
145 esac]) 182 esac
183changequote([,])dnl
184 ])
146 LIBS="$am_save_LIBS" 185 LIBS="$am_save_LIBS"
147 ]) 186 ])
148 case "$am_cv_func_iconv_works" in 187 case "$am_cv_func_iconv_works" in
@@ -183,32 +222,47 @@ m4_define([gl_iconv_AC_DEFUN],
183 m4_version_prereq([2.64], 222 m4_version_prereq([2.64],
184 [[AC_DEFUN_ONCE( 223 [[AC_DEFUN_ONCE(
185 [$1], [$2])]], 224 [$1], [$2])]],
186 [[AC_DEFUN( 225 [m4_ifdef([gl_00GNULIB],
187 [$1], [$2])]])) 226 [[AC_DEFUN_ONCE(
227 [$1], [$2])]],
228 [[AC_DEFUN(
229 [$1], [$2])]])]))
188gl_iconv_AC_DEFUN([AM_ICONV], 230gl_iconv_AC_DEFUN([AM_ICONV],
189[ 231[
190 AM_ICONV_LINK 232 AM_ICONV_LINK
191 if test "$am_cv_func_iconv" = yes; then 233 if test "$am_cv_func_iconv" = yes; then
192 AC_MSG_CHECKING([for iconv declaration]) 234 AC_MSG_CHECKING([for iconv declaration])
193 AC_CACHE_VAL([am_cv_proto_iconv], [ 235 AC_CACHE_VAL([am_cv_proto_iconv], [
194 AC_TRY_COMPILE([ 236 AC_COMPILE_IFELSE(
237 [AC_LANG_PROGRAM(
238 [[
195#include <stdlib.h> 239#include <stdlib.h>
196#include <iconv.h> 240#include <iconv.h>
197extern 241extern
198#ifdef __cplusplus 242#ifdef __cplusplus
199"C" 243"C"
200#endif 244#endif
201#if defined(__STDC__) || defined(__cplusplus) 245#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
202size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); 246size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
203#else 247#else
204size_t iconv(); 248size_t iconv();
205#endif 249#endif
206], [], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"]) 250 ]],
251 [[]])],
252 [am_cv_proto_iconv_arg1=""],
253 [am_cv_proto_iconv_arg1="const"])
207 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);"]) 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);"])
208 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` 255 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
209 AC_MSG_RESULT([ 256 AC_MSG_RESULT([
210 $am_cv_proto_iconv]) 257 $am_cv_proto_iconv])
211 AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], 258 AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
212 [Define as const if the declaration of iconv() needs const.]) 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 ])
213 fi 267 fi
214]) 268])