1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

build: Update m4/iconv.m4.

* m4/iconv.m4: Update from gettext 0.20.1.

--

This includes fixes of file descriptor leaks.

GnuPG-bug-id: 4504
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2019-05-13 15:15:29 +09:00
parent 9662538be6
commit 1cd2aca03b

View File

@ -1,5 +1,6 @@
# iconv.m4 serial AM6 (gettext-0.17) # iconv.m4 serial 21
dnl Copyright (C) 2000-2002, 2007 Free Software Foundation, Inc. dnl Copyright (C) 2000-2002, 2007-2014, 2016-2019 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.
@ -30,61 +31,118 @@ AC_DEFUN([AM_ICONV_LINK],
dnl Add $INCICONV to CPPFLAGS before performing the following checks, dnl Add $INCICONV to CPPFLAGS before performing the following checks,
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_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
am_save_CPPFLAGS="$CPPFLAGS" am_save_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], [
am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_func_iconv="no, consider installing GNU libiconv"
am_cv_lib_iconv=no am_cv_lib_iconv=no
AC_TRY_LINK([#include <stdlib.h> AC_LINK_IFELSE(
#include <iconv.h>], [AC_LANG_PROGRAM(
[iconv_t cd = iconv_open("",""); [[
iconv(cd,NULL,NULL,NULL,NULL); #include <stdlib.h>
iconv_close(cd);], #include <iconv.h>
am_cv_func_iconv=yes) ]],
[[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);]])],
[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" am_save_LIBS="$LIBS"
LIBS="$LIBS $LIBICONV" LIBS="$LIBS $LIBICONV"
AC_TRY_LINK([#include <stdlib.h> AC_LINK_IFELSE(
#include <iconv.h>], [AC_LANG_PROGRAM(
[iconv_t cd = iconv_open("",""); [[
iconv(cd,NULL,NULL,NULL,NULL); #include <stdlib.h>
iconv_close(cd);], #include <iconv.h>
am_cv_lib_iconv=yes ]],
am_cv_func_iconv=yes) [[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);]])],
[am_cv_lib_iconv=yes]
[am_cv_func_iconv=yes])
LIBS="$am_save_LIBS" LIBS="$am_save_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 and 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.
am_save_LIBS="$LIBS" am_save_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
AC_TRY_RUN([ am_cv_func_iconv_works=no
for ac_iconv_const in '' 'const'; do
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <iconv.h> #include <iconv.h>
#include <string.h> #include <string.h>
int main ()
{ #ifndef ICONV_CONST
# define ICONV_CONST $ac_iconv_const
#endif
]],
[[int result = 0;
/* Test against AIX 5.1 bug: Failures are not distinguishable from successful /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
returns. */ returns. */
{ {
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)
return 1; result |= 1;
iconv_close (cd_utf8_to_88591);
}
}
/* Test against Solaris 10 bug: Failures are not distinguishable from
successful returns. */
{
iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
if (cd_ascii_to_88591 != (iconv_t)(-1))
{
static ICONV_CONST char input[] = "\263";
char buf[10];
ICONV_CONST char *inptr = input;
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_ascii_to_88591,
&inptr, &inbytesleft,
&outptr, &outbytesleft);
if (res == 0)
result |= 2;
iconv_close (cd_ascii_to_88591);
}
}
/* Test against AIX 6.1..7.1 bug: Buffer overrun. */
{
iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
if (cd_88591_to_utf8 != (iconv_t)(-1))
{
static ICONV_CONST char input[] = "\304";
static char buf[2] = { (char)0xDE, (char)0xAD };
ICONV_CONST char *inptr = input;
size_t inbytesleft = 1;
char *outptr = buf;
size_t outbytesleft = 1;
size_t res = iconv (cd_88591_to_utf8,
&inptr, &inbytesleft,
&outptr, &outbytesleft);
if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
result |= 4;
iconv_close (cd_88591_to_utf8);
} }
} }
#if 0 /* This bug could be worked around by the caller. */ #if 0 /* This bug could be worked around by the caller. */
@ -93,37 +151,53 @@ 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)
return 1; result |= 8;
iconv_close (cd_88591_to_utf8);
} }
} }
#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. */
/* Try IRIX, OSF/1 names. */ iconv_t cd1 = iconv_open ("UTF-8", "EUC-JP");
&& iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) /* Try IRIX, OSF/1 names. */
/* Try AIX names. */ iconv_t cd2 = iconv_open ("UTF-8", "eucJP");
&& iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) /* Try AIX names. */
/* Try HP-UX names. */ iconv_t cd3 = iconv_open ("UTF-8", "IBM-eucJP");
&& iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) /* Try HP-UX names. */
return 1; iconv_t cd4 = iconv_open ("utf8", "eucJP");
return 0; if (cd1 == (iconv_t)(-1) && cd2 == (iconv_t)(-1)
}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no], && cd3 == (iconv_t)(-1) && cd4 == (iconv_t)(-1))
[case "$host_os" in result |= 16;
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; if (cd1 != (iconv_t)(-1))
*) am_cv_func_iconv_works="guessing yes" ;; iconv_close (cd1);
esac]) 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;
]])],
[am_cv_func_iconv_works=yes], ,
[case "$host_os" in
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
*) am_cv_func_iconv_works="guessing yes" ;;
esac])
test "$am_cv_func_iconv_works" = no || break
done
LIBS="$am_save_LIBS" LIBS="$am_save_LIBS"
]) ])
case "$am_cv_func_iconv_works" in case "$am_cv_func_iconv_works" in
@ -134,7 +208,7 @@ int main ()
am_func_iconv=no am_cv_lib_iconv=no am_func_iconv=no am_cv_lib_iconv=no
fi fi
if test "$am_func_iconv" = yes; then if test "$am_func_iconv" = yes; then
AC_DEFINE(HAVE_ICONV, 1, AC_DEFINE([HAVE_ICONV], [1],
[Define if you have the iconv() function and it works.]) [Define if you have the iconv() function and it works.])
fi fi
if test "$am_cv_lib_iconv" = yes; then if test "$am_cv_lib_iconv" = yes; then
@ -147,34 +221,68 @@ int main ()
LIBICONV= LIBICONV=
LTLIBICONV= LTLIBICONV=
fi fi
AC_SUBST(LIBICONV) AC_SUBST([LIBICONV])
AC_SUBST(LTLIBICONV) AC_SUBST([LTLIBICONV])
]) ])
AC_DEFUN([AM_ICONV], dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
dnl avoid warnings like
dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
dnl This is tricky because of the way 'aclocal' is implemented:
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_MSG_CHECKING([for iconv declaration])
AC_CACHE_VAL(am_cv_proto_iconv, [ AC_CACHE_VAL([am_cv_proto_iconv], [
AC_TRY_COMPILE([ AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <stdlib.h> #include <stdlib.h>
#include <iconv.h> #include <iconv.h>
extern extern
#ifdef __cplusplus #ifdef __cplusplus
"C" "C"
#endif #endif
#if defined(__STDC__) || defined(__cplusplus) #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 #else
size_t iconv(); size_t iconv();
#endif #endif
], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") ]],
[[]])],
[am_cv_proto_iconv_arg1=""],
[am_cv_proto_iconv_arg1="const"])
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="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/( /(/'` am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
AC_MSG_RESULT([$]{ac_t:- AC_MSG_RESULT([
}[$]am_cv_proto_iconv) $am_cv_proto_iconv])
AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, else
[Define as const if the declaration of iconv() needs const.]) dnl When compiling GNU libiconv on a system that does not have iconv yet,
dnl pick the POSIX compliant declaration without 'const'.
am_cv_proto_iconv_arg1=""
fi fi
AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
[Define as const if the declaration of iconv() needs const.])
dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
m4_ifdef([gl_ICONV_H_DEFAULTS],
[AC_REQUIRE([gl_ICONV_H_DEFAULTS])
if test -n "$am_cv_proto_iconv_arg1"; then
ICONV_CONST="const"
fi
])
]) ])