aboutsummaryrefslogtreecommitdiff
path: root/m4/iconv.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/iconv.m4')
-rw-r--r--m4/iconv.m4143
1 files changed, 128 insertions, 15 deletions
diff --git a/m4/iconv.m4 b/m4/iconv.m4
index 654c415..e2041b9 100644
--- a/m4/iconv.m4
+++ b/m4/iconv.m4
@@ -1,5 +1,5 @@
1# iconv.m4 serial AM4 (gettext-0.11.3) 1# iconv.m4 serial 11 (gettext-0.18.1)
2dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2007-2010 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.
@@ -21,6 +21,7 @@ AC_DEFUN([AM_ICONV_LINK],
21[ 21[
22 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and 22 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
23 dnl those with the standalone portable GNU libiconv installed). 23 dnl those with the standalone portable GNU libiconv installed).
24 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
24 25
25 dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV 26 dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
26 dnl accordingly. 27 dnl accordingly.
@@ -33,7 +34,7 @@ AC_DEFUN([AM_ICONV_LINK],
33 am_save_CPPFLAGS="$CPPFLAGS" 34 am_save_CPPFLAGS="$CPPFLAGS"
34 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) 35 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
35 36
36 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [ 37 AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
37 am_cv_func_iconv="no, consider installing GNU libiconv" 38 am_cv_func_iconv="no, consider installing GNU libiconv"
38 am_cv_lib_iconv=no 39 am_cv_lib_iconv=no
39 AC_TRY_LINK([#include <stdlib.h> 40 AC_TRY_LINK([#include <stdlib.h>
@@ -41,7 +42,7 @@ AC_DEFUN([AM_ICONV_LINK],
41 [iconv_t cd = iconv_open("",""); 42 [iconv_t cd = iconv_open("","");
42 iconv(cd,NULL,NULL,NULL,NULL); 43 iconv(cd,NULL,NULL,NULL,NULL);
43 iconv_close(cd);], 44 iconv_close(cd);],
44 am_cv_func_iconv=yes) 45 [am_cv_func_iconv=yes])
45 if test "$am_cv_func_iconv" != yes; then 46 if test "$am_cv_func_iconv" != yes; then
46 am_save_LIBS="$LIBS" 47 am_save_LIBS="$LIBS"
47 LIBS="$LIBS $LIBICONV" 48 LIBS="$LIBS $LIBICONV"
@@ -50,13 +51,110 @@ AC_DEFUN([AM_ICONV_LINK],
50 [iconv_t cd = iconv_open("",""); 51 [iconv_t cd = iconv_open("","");
51 iconv(cd,NULL,NULL,NULL,NULL); 52 iconv(cd,NULL,NULL,NULL,NULL);
52 iconv_close(cd);], 53 iconv_close(cd);],
53 am_cv_lib_iconv=yes 54 [am_cv_lib_iconv=yes]
54 am_cv_func_iconv=yes) 55 [am_cv_func_iconv=yes])
55 LIBS="$am_save_LIBS" 56 LIBS="$am_save_LIBS"
56 fi 57 fi
57 ]) 58 ])
58 if test "$am_cv_func_iconv" = yes; then 59 if test "$am_cv_func_iconv" = yes; then
59 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) 60 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.
62 am_save_LIBS="$LIBS"
63 if test $am_cv_lib_iconv = yes; then
64 LIBS="$LIBS $LIBICONV"
65 fi
66 AC_TRY_RUN([
67#include <iconv.h>
68#include <string.h>
69int main ()
70{
71 /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
72 returns. */
73 {
74 iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
75 if (cd_utf8_to_88591 != (iconv_t)(-1))
76 {
77 static const char input[] = "\342\202\254"; /* EURO SIGN */
78 char buf[10];
79 const char *inptr = input;
80 size_t inbytesleft = strlen (input);
81 char *outptr = buf;
82 size_t outbytesleft = sizeof (buf);
83 size_t res = iconv (cd_utf8_to_88591,
84 (char **) &inptr, &inbytesleft,
85 &outptr, &outbytesleft);
86 if (res == 0)
87 return 1;
88 }
89 }
90 /* Test against Solaris 10 bug: Failures are not distinguishable from
91 successful returns. */
92 {
93 iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
94 if (cd_ascii_to_88591 != (iconv_t)(-1))
95 {
96 static const char input[] = "\263";
97 char buf[10];
98 const char *inptr = input;
99 size_t inbytesleft = strlen (input);
100 char *outptr = buf;
101 size_t outbytesleft = sizeof (buf);
102 size_t res = iconv (cd_ascii_to_88591,
103 (char **) &inptr, &inbytesleft,
104 &outptr, &outbytesleft);
105 if (res == 0)
106 return 1;
107 }
108 }
109#if 0 /* This bug could be worked around by the caller. */
110 /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
111 {
112 iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
113 if (cd_88591_to_utf8 != (iconv_t)(-1))
114 {
115 static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
116 char buf[50];
117 const char *inptr = input;
118 size_t inbytesleft = strlen (input);
119 char *outptr = buf;
120 size_t outbytesleft = sizeof (buf);
121 size_t res = iconv (cd_88591_to_utf8,
122 (char **) &inptr, &inbytesleft,
123 &outptr, &outbytesleft);
124 if ((int)res > 0)
125 return 1;
126 }
127 }
128#endif
129 /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
130 provided. */
131 if (/* Try standardized names. */
132 iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
133 /* Try IRIX, OSF/1 names. */
134 && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
135 /* Try AIX names. */
136 && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
137 /* Try HP-UX names. */
138 && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
139 return 1;
140 return 0;
141}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no],
142 [case "$host_os" in
143 aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
144 *) am_cv_func_iconv_works="guessing yes" ;;
145 esac])
146 LIBS="$am_save_LIBS"
147 ])
148 case "$am_cv_func_iconv_works" in
149 *no) am_func_iconv=no am_cv_lib_iconv=no ;;
150 *) am_func_iconv=yes ;;
151 esac
152 else
153 am_func_iconv=no am_cv_lib_iconv=no
154 fi
155 if test "$am_func_iconv" = yes; then
156 AC_DEFINE([HAVE_ICONV], [1],
157 [Define if you have the iconv() function and it works.])
60 fi 158 fi
61 if test "$am_cv_lib_iconv" = yes; then 159 if test "$am_cv_lib_iconv" = yes; then
62 AC_MSG_CHECKING([how to link with libiconv]) 160 AC_MSG_CHECKING([how to link with libiconv])
@@ -68,16 +166,31 @@ AC_DEFUN([AM_ICONV_LINK],
68 LIBICONV= 166 LIBICONV=
69 LTLIBICONV= 167 LTLIBICONV=
70 fi 168 fi
71 AC_SUBST(LIBICONV) 169 AC_SUBST([LIBICONV])
72 AC_SUBST(LTLIBICONV) 170 AC_SUBST([LTLIBICONV])
73]) 171])
74 172
75AC_DEFUN([AM_ICONV], 173dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
174dnl avoid warnings like
175dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
176dnl This is tricky because of the way 'aclocal' is implemented:
177dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
178dnl Otherwise aclocal's initial scan pass would miss the macro definition.
179dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
180dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
181dnl warnings.
182m4_define([gl_iconv_AC_DEFUN],
183 m4_version_prereq([2.64],
184 [[AC_DEFUN_ONCE(
185 [$1], [$2])]],
186 [[AC_DEFUN(
187 [$1], [$2])]]))
188gl_iconv_AC_DEFUN([AM_ICONV],
76[ 189[
77 AM_ICONV_LINK 190 AM_ICONV_LINK
78 if test "$am_cv_func_iconv" = yes; then 191 if test "$am_cv_func_iconv" = yes; then
79 AC_MSG_CHECKING([for iconv declaration]) 192 AC_MSG_CHECKING([for iconv declaration])
80 AC_CACHE_VAL(am_cv_proto_iconv, [ 193 AC_CACHE_VAL([am_cv_proto_iconv], [
81 AC_TRY_COMPILE([ 194 AC_TRY_COMPILE([
82#include <stdlib.h> 195#include <stdlib.h>
83#include <iconv.h> 196#include <iconv.h>
@@ -90,12 +203,12 @@ size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, si
90#else 203#else
91size_t iconv(); 204size_t iconv();
92#endif 205#endif
93], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") 206], [], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"])
94 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);"]) 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);"])
95 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` 208 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
96 AC_MSG_RESULT([$]{ac_t:- 209 AC_MSG_RESULT([
97 }[$]am_cv_proto_iconv) 210 $am_cv_proto_iconv])
98 AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, 211 AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
99 [Define as const if the declaration of iconv() needs const.]) 212 [Define as const if the declaration of iconv() needs const.])
100 fi 213 fi
101]) 214])