bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libiconv detection failure


From: Daiki Ueno
Subject: Re: libiconv detection failure
Date: Wed, 22 Oct 2014 12:58:29 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

Eric Blake <address@hidden> writes:

> m4_foreach causes the loop to be expanded at m4 time (a larger configure
> file).  In this case, you could probably easily get by with a shell loop
> instead, for a smaller configure file (untested):
>
>        for type in 'char **' 'const char **'; do
>          AC_RUN_IFELSE([AC_LANG_PROGRAM([[
>            ...
>            typedef $type gl_iconv_buf_t;

Yes, thanks for the suggestion.  I've ended up with the attached patch,
with some more cleanup.

Eli: I think it is sufficient to compare the configure output of
     before/after the change, using test packages:
     Before: http://du-a.org/~ueno/junk/test-iconv-0.tar.gz
     After: http://du-a.org/~ueno/junk/test-iconv-1.tar.gz

Thanks,
--
Daiki Ueno
>From 46969a8560460084f6770f3c21025f0faac33f9f Mon Sep 17 00:00:00 2001
From: Daiki Ueno <address@hidden>
Date: Tue, 21 Oct 2014 18:07:00 +0900
Subject: [PATCH] iconv: avoid false detection of non-working iconv

The INBUF/OUTBUF arguments of iconv can be either 'const char **'
or 'char **'.  If CC is g++, the difference causes a compile error
and thus leads to a false detection of non-working iconv.
Reported by Eli Zaretskii and Werner LEMBERG in:
<https://lists.gnu.org/archive/html/bug-gnulib/2014-10/msg00023.html>.
* m4/iconv.m4 (AM_ICONV_LINK): Try all possible argument types of
iconv.  Bump serial number.
---
 ChangeLog   | 11 +++++++++++
 m4/iconv.m4 | 51 ++++++++++++++++++++++++++-------------------------
 2 files changed, 37 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 23234b7..49639fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2014-10-21  Daiki Ueno  <address@hidden>
+
+       iconv: avoid false detection of non-working iconv
+       The INBUF/OUTBUF arguments of iconv can be either 'const char **'
+       or 'char **'.  If CC is g++, the difference causes a compile error
+       and thus leads to a false detection of non-working iconv.
+       Reported by Eli Zaretskii and Werner LEMBERG in:
+       <https://lists.gnu.org/archive/html/bug-gnulib/2014-10/msg00023.html>.
+       * m4/iconv.m4 (AM_ICONV_LINK): Try all possible argument types of
+       iconv.  Bump serial number.
+
 2014-10-18  Paul Eggert  <address@hidden>
 
        symlinkat: port to AIX 7.1
diff --git a/m4/iconv.m4 b/m4/iconv.m4
index 4b29c5f..2c3085f 100644
--- a/m4/iconv.m4
+++ b/m4/iconv.m4
@@ -1,4 +1,4 @@
-# iconv.m4 serial 18 (gettext-0.18.2)
+# iconv.m4 serial 19 (gettext-0.18.2)
 dnl Copyright (C) 2000-2002, 2007-2014 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -72,13 +72,17 @@ AC_DEFUN([AM_ICONV_LINK],
       if test $am_cv_lib_iconv = yes; then
         LIBS="$LIBS $LIBICONV"
       fi
-      AC_RUN_IFELSE(
-        [AC_LANG_SOURCE([[
+      am_cv_func_iconv_works=no
+      for ac_type in 'char **' 'const char **'; do
+        AC_RUN_IFELSE(
+          [AC_LANG_PROGRAM(
+             [[
 #include <iconv.h>
 #include <string.h>
-int main ()
-{
-  int result = 0;
+
+typedef $ac_type gl_iconv_buf_t;
+             ]],
+             [[int result = 0;
   /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
      returns.  */
   {
@@ -92,8 +96,8 @@ int main ()
         char *outptr = buf;
         size_t outbytesleft = sizeof (buf);
         size_t res = iconv (cd_utf8_to_88591,
-                            (char **) &inptr, &inbytesleft,
-                            &outptr, &outbytesleft);
+                            (gl_iconv_buf_t) &inptr, &inbytesleft,
+                            (gl_iconv_buf_t) &outptr, &outbytesleft);
         if (res == 0)
           result |= 1;
         iconv_close (cd_utf8_to_88591);
@@ -112,8 +116,8 @@ int main ()
         char *outptr = buf;
         size_t outbytesleft = sizeof (buf);
         size_t res = iconv (cd_ascii_to_88591,
-                            (char **) &inptr, &inbytesleft,
-                            &outptr, &outbytesleft);
+                            (gl_iconv_buf_t) &inptr, &inbytesleft,
+                            (gl_iconv_buf_t) &outptr, &outbytesleft);
         if (res == 0)
           result |= 2;
         iconv_close (cd_ascii_to_88591);
@@ -131,8 +135,8 @@ int main ()
         char *outptr = buf;
         size_t outbytesleft = 1;
         size_t res = iconv (cd_88591_to_utf8,
-                            (char **) &inptr, &inbytesleft,
-                            &outptr, &outbytesleft);
+                            (gl_iconv_buf_t) &inptr, &inbytesleft,
+                            (gl_iconv_buf_t) &outptr, &outbytesleft);
         if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
           result |= 4;
         iconv_close (cd_88591_to_utf8);
@@ -151,8 +155,8 @@ int main ()
         char *outptr = buf;
         size_t outbytesleft = sizeof (buf);
         size_t res = iconv (cd_88591_to_utf8,
-                            (char **) &inptr, &inbytesleft,
-                            &outptr, &outbytesleft);
+                            (gl_iconv_buf_t) &inptr, &inbytesleft,
+                            (gl_iconv_buf_t) &outptr, &outbytesleft);
         if ((int)res > 0)
           result |= 8;
         iconv_close (cd_88591_to_utf8);
@@ -171,17 +175,14 @@ int main ()
       && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
     result |= 16;
   return result;
-}]])],
-        [am_cv_func_iconv_works=yes],
-        [am_cv_func_iconv_works=no],
-        [
-changequote(,)dnl
-         case "$host_os" in
-           aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
-           *)            am_cv_func_iconv_works="guessing yes" ;;
-         esac
-changequote([,])dnl
-        ])
+]])],
+          [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"
     ])
     case "$am_cv_func_iconv_works" in
-- 
1.9.3


reply via email to

[Prev in Thread] Current Thread [Next in Thread]