50
51
[iconv_t cd = iconv_open("","");
51
52
iconv(cd,NULL,NULL,NULL,NULL);
55
[am_cv_func_iconv=yes])
55
56
LIBS="$am_save_LIBS"
58
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.
63
if test $am_cv_lib_iconv = yes; then
64
LIBS="$LIBS $LIBICONV"
71
/* Test against AIX 5.1 bug: Failures are not distinguishable from successful
74
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
75
if (cd_utf8_to_88591 != (iconv_t)(-1))
77
static const char input[] = "\342\202\254"; /* EURO SIGN */
79
const char *inptr = input;
80
size_t inbytesleft = strlen (input);
82
size_t outbytesleft = sizeof (buf);
83
size_t res = iconv (cd_utf8_to_88591,
84
(char **) &inptr, &inbytesleft,
85
&outptr, &outbytesleft);
90
/* Test against Solaris 10 bug: Failures are not distinguishable from
91
successful returns. */
93
iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
94
if (cd_ascii_to_88591 != (iconv_t)(-1))
96
static const char input[] = "\263";
98
const char *inptr = input;
99
size_t inbytesleft = strlen (input);
101
size_t outbytesleft = sizeof (buf);
102
size_t res = iconv (cd_ascii_to_88591,
103
(char **) &inptr, &inbytesleft,
104
&outptr, &outbytesleft);
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. */
112
iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
113
if (cd_88591_to_utf8 != (iconv_t)(-1))
115
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
117
const char *inptr = input;
118
size_t inbytesleft = strlen (input);
120
size_t outbytesleft = sizeof (buf);
121
size_t res = iconv (cd_88591_to_utf8,
122
(char **) &inptr, &inbytesleft,
123
&outptr, &outbytesleft);
129
/* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
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)
136
&& iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
137
/* Try HP-UX names. */
138
&& iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
141
}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no],
143
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
144
*) am_cv_func_iconv_works="guessing yes" ;;
148
case "$am_cv_func_iconv_works" in
149
*no) am_func_iconv=no am_cv_lib_iconv=no ;;
150
*) am_func_iconv=yes ;;
153
am_func_iconv=no am_cv_lib_iconv=no
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.])
61
159
if test "$am_cv_lib_iconv" = yes; then
62
160
AC_MSG_CHECKING([how to link with libiconv])
170
AC_SUBST([LTLIBICONV])
173
dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
174
dnl avoid warnings like
175
dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
176
dnl This is tricky because of the way 'aclocal' is implemented:
177
dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
178
dnl Otherwise aclocal's initial scan pass would miss the macro definition.
179
dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
180
dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
182
m4_define([gl_iconv_AC_DEFUN],
183
m4_version_prereq([2.64],
188
gl_iconv_AC_DEFUN([AM_ICONV],
78
191
if test "$am_cv_func_iconv" = yes; then
79
192
AC_MSG_CHECKING([for iconv declaration])
80
AC_CACHE_VAL(am_cv_proto_iconv, [
193
AC_CACHE_VAL([am_cv_proto_iconv], [
82
195
#include <stdlib.h>
83
196
#include <iconv.h>
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
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
208
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
96
AC_MSG_RESULT([$]{ac_t:-
97
}[$]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
212
[Define as const if the declaration of iconv() needs const.])