mirror of https://github.com/xiph/flac
Update iconv.m4
This commit is contained in:
parent
d6921ed6cd
commit
f5012d5e88
172
m4/iconv.m4
172
m4/iconv.m4
|
@ -1,11 +1,19 @@
|
||||||
# iconv.m4 serial 18 (gettext-0.18.2)
|
# iconv.m4
|
||||||
dnl Copyright (C) 2000-2002, 2007-2012 Free Software Foundation, Inc.
|
# serial 27
|
||||||
|
dnl Copyright (C) 2000-2002, 2007-2014, 2016-2024 Free Software Foundation,
|
||||||
|
dnl Inc.
|
||||||
dnl This file is free software; the Free Software Foundation
|
dnl This file is free software; the Free Software Foundation
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
dnl gives unlimited permission to copy and/or distribute it,
|
||||||
dnl with or without modifications, as long as this notice is preserved.
|
dnl with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
dnl From Bruno Haible.
|
dnl From Bruno Haible.
|
||||||
|
|
||||||
|
AC_PREREQ([2.64])
|
||||||
|
|
||||||
|
dnl Note: AM_ICONV is documented in the GNU gettext manual
|
||||||
|
dnl <https://www.gnu.org/software/gettext/manual/html_node/AM_005fICONV.html>.
|
||||||
|
dnl Don't make changes that are incompatible with that documentation!
|
||||||
|
|
||||||
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
|
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
|
||||||
[
|
[
|
||||||
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
|
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
|
||||||
|
@ -31,7 +39,7 @@ AC_DEFUN([AM_ICONV_LINK],
|
||||||
dnl because if the user has installed libiconv and not disabled its use
|
dnl because if the user has installed libiconv and not disabled its use
|
||||||
dnl via --without-libiconv-prefix, he wants to use it. The first
|
dnl via --without-libiconv-prefix, he wants to use it. The first
|
||||||
dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
|
dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
|
||||||
am_save_CPPFLAGS="$CPPFLAGS"
|
gl_saved_CPPFLAGS="$CPPFLAGS"
|
||||||
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
|
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
|
||||||
|
|
||||||
AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
|
AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
|
||||||
|
@ -48,7 +56,7 @@ AC_DEFUN([AM_ICONV_LINK],
|
||||||
iconv_close(cd);]])],
|
iconv_close(cd);]])],
|
||||||
[am_cv_func_iconv=yes])
|
[am_cv_func_iconv=yes])
|
||||||
if test "$am_cv_func_iconv" != yes; then
|
if test "$am_cv_func_iconv" != yes; then
|
||||||
am_save_LIBS="$LIBS"
|
gl_saved_LIBS="$LIBS"
|
||||||
LIBS="$LIBS $LIBICONV"
|
LIBS="$LIBS $LIBICONV"
|
||||||
AC_LINK_IFELSE(
|
AC_LINK_IFELSE(
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
|
@ -61,38 +69,45 @@ AC_DEFUN([AM_ICONV_LINK],
|
||||||
iconv_close(cd);]])],
|
iconv_close(cd);]])],
|
||||||
[am_cv_lib_iconv=yes]
|
[am_cv_lib_iconv=yes]
|
||||||
[am_cv_func_iconv=yes])
|
[am_cv_func_iconv=yes])
|
||||||
LIBS="$am_save_LIBS"
|
LIBS="$gl_saved_LIBS"
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
if test "$am_cv_func_iconv" = yes; then
|
if test "$am_cv_func_iconv" = yes; then
|
||||||
AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
|
AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
|
||||||
dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
|
dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
|
||||||
dnl Solaris 10.
|
dnl Solaris 10.
|
||||||
am_save_LIBS="$LIBS"
|
gl_saved_LIBS="$LIBS"
|
||||||
if test $am_cv_lib_iconv = yes; then
|
if test $am_cv_lib_iconv = yes; then
|
||||||
LIBS="$LIBS $LIBICONV"
|
LIBS="$LIBS $LIBICONV"
|
||||||
fi
|
fi
|
||||||
|
am_cv_func_iconv_works=no
|
||||||
|
for ac_iconv_const in '' 'const'; do
|
||||||
AC_RUN_IFELSE(
|
AC_RUN_IFELSE(
|
||||||
[AC_LANG_SOURCE([[
|
[AC_LANG_PROGRAM(
|
||||||
|
[[
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
int main ()
|
|
||||||
{
|
#ifndef ICONV_CONST
|
||||||
int result = 0;
|
# define ICONV_CONST $ac_iconv_const
|
||||||
/* Test against AIX 5.1 bug: Failures are not distinguishable from successful
|
#endif
|
||||||
returns. */
|
]],
|
||||||
|
[[int result = 0;
|
||||||
|
/* Test against AIX 5.1...7.2 bug: Failures are not distinguishable from
|
||||||
|
successful returns. This is even documented in
|
||||||
|
<https://www.ibm.com/support/knowledgecenter/ssw_aix_72/i_bostechref/iconv.html> */
|
||||||
{
|
{
|
||||||
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
|
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
|
||||||
if (cd_utf8_to_88591 != (iconv_t)(-1))
|
if (cd_utf8_to_88591 != (iconv_t)(-1))
|
||||||
{
|
{
|
||||||
static const char input[] = "\342\202\254"; /* EURO SIGN */
|
static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */
|
||||||
char buf[10];
|
char buf[10];
|
||||||
const char *inptr = input;
|
ICONV_CONST char *inptr = input;
|
||||||
size_t inbytesleft = strlen (input);
|
size_t inbytesleft = strlen (input);
|
||||||
char *outptr = buf;
|
char *outptr = buf;
|
||||||
size_t outbytesleft = sizeof (buf);
|
size_t outbytesleft = sizeof (buf);
|
||||||
size_t res = iconv (cd_utf8_to_88591,
|
size_t res = iconv (cd_utf8_to_88591,
|
||||||
(char **) &inptr, &inbytesleft,
|
&inptr, &inbytesleft,
|
||||||
&outptr, &outbytesleft);
|
&outptr, &outbytesleft);
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
result |= 1;
|
result |= 1;
|
||||||
|
@ -105,14 +120,14 @@ int main ()
|
||||||
iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
|
iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
|
||||||
if (cd_ascii_to_88591 != (iconv_t)(-1))
|
if (cd_ascii_to_88591 != (iconv_t)(-1))
|
||||||
{
|
{
|
||||||
static const char input[] = "\263";
|
static ICONV_CONST char input[] = "\263";
|
||||||
char buf[10];
|
char buf[10];
|
||||||
const char *inptr = input;
|
ICONV_CONST char *inptr = input;
|
||||||
size_t inbytesleft = strlen (input);
|
size_t inbytesleft = strlen (input);
|
||||||
char *outptr = buf;
|
char *outptr = buf;
|
||||||
size_t outbytesleft = sizeof (buf);
|
size_t outbytesleft = sizeof (buf);
|
||||||
size_t res = iconv (cd_ascii_to_88591,
|
size_t res = iconv (cd_ascii_to_88591,
|
||||||
(char **) &inptr, &inbytesleft,
|
&inptr, &inbytesleft,
|
||||||
&outptr, &outbytesleft);
|
&outptr, &outbytesleft);
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
result |= 2;
|
result |= 2;
|
||||||
|
@ -124,14 +139,14 @@ int main ()
|
||||||
iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
|
iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
|
||||||
if (cd_88591_to_utf8 != (iconv_t)(-1))
|
if (cd_88591_to_utf8 != (iconv_t)(-1))
|
||||||
{
|
{
|
||||||
static const char input[] = "\304";
|
static ICONV_CONST char input[] = "\304";
|
||||||
static char buf[2] = { (char)0xDE, (char)0xAD };
|
static char buf[2] = { (char)0xDE, (char)0xAD };
|
||||||
const char *inptr = input;
|
ICONV_CONST char *inptr = input;
|
||||||
size_t inbytesleft = 1;
|
size_t inbytesleft = 1;
|
||||||
char *outptr = buf;
|
char *outptr = buf;
|
||||||
size_t outbytesleft = 1;
|
size_t outbytesleft = 1;
|
||||||
size_t res = iconv (cd_88591_to_utf8,
|
size_t res = iconv (cd_88591_to_utf8,
|
||||||
(char **) &inptr, &inbytesleft,
|
&inptr, &inbytesleft,
|
||||||
&outptr, &outbytesleft);
|
&outptr, &outbytesleft);
|
||||||
if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
|
if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
|
||||||
result |= 4;
|
result |= 4;
|
||||||
|
@ -144,14 +159,14 @@ int main ()
|
||||||
iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
|
iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
|
||||||
if (cd_88591_to_utf8 != (iconv_t)(-1))
|
if (cd_88591_to_utf8 != (iconv_t)(-1))
|
||||||
{
|
{
|
||||||
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
|
static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
|
||||||
char buf[50];
|
char buf[50];
|
||||||
const char *inptr = input;
|
ICONV_CONST char *inptr = input;
|
||||||
size_t inbytesleft = strlen (input);
|
size_t inbytesleft = strlen (input);
|
||||||
char *outptr = buf;
|
char *outptr = buf;
|
||||||
size_t outbytesleft = sizeof (buf);
|
size_t outbytesleft = sizeof (buf);
|
||||||
size_t res = iconv (cd_88591_to_utf8,
|
size_t res = iconv (cd_88591_to_utf8,
|
||||||
(char **) &inptr, &inbytesleft,
|
&inptr, &inbytesleft,
|
||||||
&outptr, &outbytesleft);
|
&outptr, &outbytesleft);
|
||||||
if ((int)res > 0)
|
if ((int)res > 0)
|
||||||
result |= 8;
|
result |= 8;
|
||||||
|
@ -161,28 +176,37 @@ int main ()
|
||||||
#endif
|
#endif
|
||||||
/* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
|
/* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
|
||||||
provided. */
|
provided. */
|
||||||
if (/* Try standardized names. */
|
{
|
||||||
iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
|
/* Try standardized names. */
|
||||||
|
iconv_t cd1 = iconv_open ("UTF-8", "EUC-JP");
|
||||||
/* Try IRIX, OSF/1 names. */
|
/* Try IRIX, OSF/1 names. */
|
||||||
&& iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
|
iconv_t cd2 = iconv_open ("UTF-8", "eucJP");
|
||||||
/* Try AIX names. */
|
/* Try AIX names. */
|
||||||
&& iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
|
iconv_t cd3 = iconv_open ("UTF-8", "IBM-eucJP");
|
||||||
/* Try HP-UX names. */
|
/* Try HP-UX names. */
|
||||||
&& iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
|
iconv_t cd4 = iconv_open ("utf8", "eucJP");
|
||||||
|
if (cd1 == (iconv_t)(-1) && cd2 == (iconv_t)(-1)
|
||||||
|
&& cd3 == (iconv_t)(-1) && cd4 == (iconv_t)(-1))
|
||||||
result |= 16;
|
result |= 16;
|
||||||
|
if (cd1 != (iconv_t)(-1))
|
||||||
|
iconv_close (cd1);
|
||||||
|
if (cd2 != (iconv_t)(-1))
|
||||||
|
iconv_close (cd2);
|
||||||
|
if (cd3 != (iconv_t)(-1))
|
||||||
|
iconv_close (cd3);
|
||||||
|
if (cd4 != (iconv_t)(-1))
|
||||||
|
iconv_close (cd4);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}]])],
|
]])],
|
||||||
[am_cv_func_iconv_works=yes],
|
[am_cv_func_iconv_works=yes], ,
|
||||||
[am_cv_func_iconv_works=no],
|
[case "$host_os" in
|
||||||
[
|
|
||||||
changequote(,)dnl
|
|
||||||
case "$host_os" in
|
|
||||||
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
|
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
|
||||||
*) am_cv_func_iconv_works="guessing yes" ;;
|
*) am_cv_func_iconv_works="guessing yes" ;;
|
||||||
esac
|
esac])
|
||||||
changequote([,])dnl
|
test "$am_cv_func_iconv_works" = no || break
|
||||||
])
|
done
|
||||||
LIBS="$am_save_LIBS"
|
LIBS="$gl_saved_LIBS"
|
||||||
])
|
])
|
||||||
case "$am_cv_func_iconv_works" in
|
case "$am_cv_func_iconv_works" in
|
||||||
*no) am_func_iconv=no am_cv_lib_iconv=no ;;
|
*no) am_func_iconv=no am_cv_lib_iconv=no ;;
|
||||||
|
@ -201,7 +225,7 @@ changequote([,])dnl
|
||||||
else
|
else
|
||||||
dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
|
dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
|
||||||
dnl either.
|
dnl either.
|
||||||
CPPFLAGS="$am_save_CPPFLAGS"
|
CPPFLAGS="$gl_saved_CPPFLAGS"
|
||||||
LIBICONV=
|
LIBICONV=
|
||||||
LTLIBICONV=
|
LTLIBICONV=
|
||||||
fi
|
fi
|
||||||
|
@ -209,31 +233,15 @@ changequote([,])dnl
|
||||||
AC_SUBST([LTLIBICONV])
|
AC_SUBST([LTLIBICONV])
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
|
dnl Define AM_ICONV using AC_DEFUN_ONCE, in order to avoid warnings like
|
||||||
dnl avoid warnings like
|
|
||||||
dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
|
dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
|
||||||
dnl This is tricky because of the way 'aclocal' is implemented:
|
AC_DEFUN_ONCE([AM_ICONV],
|
||||||
dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
|
|
||||||
dnl Otherwise aclocal's initial scan pass would miss the macro definition.
|
|
||||||
dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
|
|
||||||
dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
|
|
||||||
dnl warnings.
|
|
||||||
m4_define([gl_iconv_AC_DEFUN],
|
|
||||||
m4_version_prereq([2.64],
|
|
||||||
[[AC_DEFUN_ONCE(
|
|
||||||
[$1], [$2])]],
|
|
||||||
[m4_ifdef([gl_00GNULIB],
|
|
||||||
[[AC_DEFUN_ONCE(
|
|
||||||
[$1], [$2])]],
|
|
||||||
[[AC_DEFUN(
|
|
||||||
[$1], [$2])]])]))
|
|
||||||
gl_iconv_AC_DEFUN([AM_ICONV],
|
|
||||||
[
|
[
|
||||||
AM_ICONV_LINK
|
AM_ICONV_LINK
|
||||||
if test "$am_cv_func_iconv" = yes; then
|
if test "$am_cv_func_iconv" = yes; then
|
||||||
AC_MSG_CHECKING([for iconv declaration])
|
AC_CACHE_CHECK([whether iconv is compatible with its POSIX signature],
|
||||||
AC_CACHE_VAL([am_cv_proto_iconv], [
|
[gl_cv_iconv_nonconst],
|
||||||
AC_COMPILE_IFELSE(
|
[AC_COMPILE_IFELSE(
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
[[
|
[[
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -242,27 +250,45 @@ extern
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
"C"
|
"C"
|
||||||
#endif
|
#endif
|
||||||
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
|
|
||||||
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
|
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
|
||||||
#else
|
|
||||||
size_t iconv();
|
|
||||||
#endif
|
|
||||||
]],
|
]],
|
||||||
[[]])],
|
[[]])],
|
||||||
[am_cv_proto_iconv_arg1=""],
|
[gl_cv_iconv_nonconst=yes],
|
||||||
[am_cv_proto_iconv_arg1="const"])
|
[gl_cv_iconv_nonconst=no])
|
||||||
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);"])
|
])
|
||||||
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
|
else
|
||||||
AC_MSG_RESULT([
|
dnl When compiling GNU libiconv on a system that does not have iconv yet,
|
||||||
$am_cv_proto_iconv])
|
dnl pick the POSIX compliant declaration without 'const'.
|
||||||
AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
|
gl_cv_iconv_nonconst=yes
|
||||||
|
fi
|
||||||
|
if test $gl_cv_iconv_nonconst = yes; then
|
||||||
|
iconv_arg1=""
|
||||||
|
else
|
||||||
|
iconv_arg1="const"
|
||||||
|
fi
|
||||||
|
AC_DEFINE_UNQUOTED([ICONV_CONST], [$iconv_arg1],
|
||||||
[Define as const if the declaration of iconv() needs const.])
|
[Define as const if the declaration of iconv() needs const.])
|
||||||
dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
|
dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
|
||||||
m4_ifdef([gl_ICONV_H_DEFAULTS],
|
m4_ifdef([gl_ICONV_H_DEFAULTS],
|
||||||
[AC_REQUIRE([gl_ICONV_H_DEFAULTS])
|
[AC_REQUIRE([gl_ICONV_H_DEFAULTS])
|
||||||
if test -n "$am_cv_proto_iconv_arg1"; then
|
if test $gl_cv_iconv_nonconst != yes; then
|
||||||
ICONV_CONST="const"
|
ICONV_CONST="const"
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl A summary result, for those packages which want to print a summary at the
|
||||||
|
dnl end of the configuration.
|
||||||
|
if test "$am_func_iconv" = yes; then
|
||||||
|
if test -n "$LIBICONV"; then
|
||||||
|
am_cv_func_iconv_summary='yes, in libiconv'
|
||||||
|
else
|
||||||
|
am_cv_func_iconv_summary='yes, in libc'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if test "$am_cv_func_iconv" = yes; then
|
||||||
|
am_cv_func_iconv_summary='not working, consider installing GNU libiconv'
|
||||||
|
else
|
||||||
|
am_cv_func_iconv_summary='no, consider installing GNU libiconv'
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in New Issue