changeset 13898:9e1ca99d049e

iconv-h: Fix test-iconv-h-c++ failure on Solaris 11 2010-11. * lib/iconv.in.h (iconv_open, iconv, iconv_close): Define only if the 'iconv' module is present. (ICONV_CONST): New macro. * m4/iconv_h.m4 (gl_ICONV_H_DEFAULTS): Initialize GNULIB_ICONV and ICONV_CONST. * m4/iconv.m4 (AM_ICONV): If the gnulib module 'iconv-h' is present, set ICONV_CONST. * m4/iconv_open.m4 (gl_FUNC_ICONV_OPEN_UTF): Don't set ICONV_CONST here. * modules/iconv (configure.ac): Invoke gl_ICONV_MODULE_INDICATOR. * modules/iconv-h (Makefile.am): Substitute GNULIB_ICONV. * tests/test-iconv-h.c (ICONV_CONST): Don't define here. * tests/test-iconv-h-c++.cc (ICONV_CONST): Don't define here. (iconv_open, iconv, iconv_close): Test only if the 'iconv' module is present.
author Bruno Haible <bruno@clisp.org>
date Sat, 27 Nov 2010 04:08:53 +0100
parents 66a5a281cd30
children e28478fcd1f9
files ChangeLog lib/iconv.in.h m4/iconv.m4 m4/iconv_h.m4 m4/iconv_open.m4 modules/iconv modules/iconv-h tests/test-iconv-h-c++.cc tests/test-iconv-h.c
diffstat 9 files changed, 66 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2010-11-26  Bruno Haible  <bruno@clisp.org>
+
+	iconv-h: Fix test-iconv-h-c++ failure on Solaris 11 2010-11.
+	* lib/iconv.in.h (iconv_open, iconv, iconv_close): Define only if the
+	'iconv' module is present.
+	(ICONV_CONST): New macro.
+	* m4/iconv_h.m4 (gl_ICONV_H_DEFAULTS): Initialize GNULIB_ICONV and
+	ICONV_CONST.
+	* m4/iconv.m4 (AM_ICONV): If the gnulib module 'iconv-h' is present,
+	set ICONV_CONST.
+	* m4/iconv_open.m4 (gl_FUNC_ICONV_OPEN_UTF): Don't set ICONV_CONST
+	here.
+	* modules/iconv (configure.ac): Invoke gl_ICONV_MODULE_INDICATOR.
+	* modules/iconv-h (Makefile.am): Substitute GNULIB_ICONV.
+	* tests/test-iconv-h.c (ICONV_CONST): Don't define here.
+	* tests/test-iconv-h-c++.cc (ICONV_CONST): Don't define here.
+	(iconv_open, iconv, iconv_close): Test only if the 'iconv' module is
+	present.
+
 2010-11-25  Paul Eggert  <eggert@cs.ucla.edu>
 
 	ftoastr: comment fix
--- a/lib/iconv.in.h
+++ b/lib/iconv.in.h
@@ -36,22 +36,24 @@
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
 
-#if @REPLACE_ICONV_OPEN@
+#if @GNULIB_ICONV@
+# if @REPLACE_ICONV_OPEN@
 /* An iconv_open wrapper that supports the IANA standardized encoding names
    ("ISO-8859-1" etc.) as far as possible.  */
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#  define iconv_open rpl_iconv_open
-# endif
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define iconv_open rpl_iconv_open
+#  endif
 _GL_FUNCDECL_RPL (iconv_open, iconv_t,
                   (const char *tocode, const char *fromcode)
                   _GL_ARG_NONNULL ((1, 2)));
 _GL_CXXALIAS_RPL (iconv_open, iconv_t,
                   (const char *tocode, const char *fromcode));
-#else
+# else
 _GL_CXXALIAS_SYS (iconv_open, iconv_t,
                   (const char *tocode, const char *fromcode));
+# endif
+_GL_CXXALIASWARN (iconv_open);
 #endif
-_GL_CXXALIASWARN (iconv_open);
 
 #if @REPLACE_ICONV_UTF@
 /* Special constants for supporting UTF-{16,32}{BE,LE} encodings.
@@ -66,10 +68,11 @@
 # define _ICONV_UTF32LE_UTF8 (iconv_t)(-168)
 #endif
 
-#if @REPLACE_ICONV@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#  define iconv rpl_iconv
-# endif
+#if @GNULIB_ICONV@
+# if @REPLACE_ICONV@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define iconv rpl_iconv
+#  endif
 _GL_FUNCDECL_RPL (iconv, size_t,
                   (iconv_t cd,
                    @ICONV_CONST@ char **inbuf, size_t *inbytesleft,
@@ -78,24 +81,30 @@
                   (iconv_t cd,
                    @ICONV_CONST@ char **inbuf, size_t *inbytesleft,
                    char **outbuf, size_t *outbytesleft));
-#else
+# else
 _GL_CXXALIAS_SYS (iconv, size_t,
                   (iconv_t cd,
                    @ICONV_CONST@ char **inbuf, size_t *inbytesleft,
                    char **outbuf, size_t *outbytesleft));
+# endif
+_GL_CXXALIASWARN (iconv);
+# ifndef ICONV_CONST
+#  define ICONV_CONST @ICONV_CONST@
+# endif
 #endif
-_GL_CXXALIASWARN (iconv);
 
-#if @REPLACE_ICONV@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#  define iconv_close rpl_iconv_close
-# endif
+#if @GNULIB_ICONV@
+# if @REPLACE_ICONV@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define iconv_close rpl_iconv_close
+#  endif
 _GL_FUNCDECL_RPL (iconv_close, int, (iconv_t cd));
 _GL_CXXALIAS_RPL (iconv_close, int, (iconv_t cd));
-#else
+# else
 _GL_CXXALIAS_SYS (iconv_close, int, (iconv_t cd));
+# endif
+_GL_CXXALIASWARN (iconv_close);
 #endif
-_GL_CXXALIASWARN (iconv_close);
 
 
 #endif /* _GL_ICONV_H */
--- a/m4/iconv.m4
+++ b/m4/iconv.m4
@@ -1,4 +1,4 @@
-# iconv.m4 serial 15 (gettext-0.18.2)
+# iconv.m4 serial 16 (gettext-0.18.2)
 dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -252,5 +252,12 @@
          $am_cv_proto_iconv])
     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
+      ])
   fi
 ])
--- a/m4/iconv_h.m4
+++ b/m4/iconv_h.m4
@@ -1,4 +1,4 @@
-# iconv_h.m4 serial 6
+# iconv_h.m4 serial 7
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -29,7 +29,9 @@
 
 AC_DEFUN([gl_ICONV_H_DEFAULTS],
 [
+  GNULIB_ICONV=0;       AC_SUBST([GNULIB_ICONV])
   dnl Assume proper GNU behavior unless another module says otherwise.
+  ICONV_CONST=;         AC_SUBST([ICONV_CONST])
   REPLACE_ICONV=0;      AC_SUBST([REPLACE_ICONV])
   REPLACE_ICONV_OPEN=0; AC_SUBST([REPLACE_ICONV_OPEN])
   REPLACE_ICONV_UTF=0;  AC_SUBST([REPLACE_ICONV_UTF])
--- a/m4/iconv_open.m4
+++ b/m4/iconv_open.m4
@@ -1,4 +1,4 @@
-# iconv_open.m4 serial 9
+# iconv_open.m4 serial 10
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -52,12 +52,6 @@
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   AC_REQUIRE([gl_ICONV_H_DEFAULTS])
   if test "$am_cv_func_iconv" = yes; then
-    if test -n "$am_cv_proto_iconv_arg1"; then
-      ICONV_CONST="const"
-    else
-      ICONV_CONST=
-    fi
-    AC_SUBST([ICONV_CONST])
     AC_CACHE_CHECK([whether iconv supports conversion between UTF-8 and UTF-{16,32}{BE,LE}],
       [gl_cv_func_iconv_supports_utf],
       [
--- a/modules/iconv
+++ b/modules/iconv
@@ -9,6 +9,7 @@
 
 configure.ac:
 AM_ICONV
+gl_ICONV_MODULE_INDICATOR([iconv])
 
 Makefile.am:
 
--- a/modules/iconv-h
+++ b/modules/iconv-h
@@ -26,6 +26,7 @@
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
 	      -e 's|@''NEXT_ICONV_H''@|$(NEXT_ICONV_H)|g' \
+	      -e 's|@''GNULIB_ICONV''@|$(GNULIB_ICONV)|g' \
 	      -e 's|@''ICONV_CONST''@|$(ICONV_CONST)|g' \
 	      -e 's|@''REPLACE_ICONV''@|$(REPLACE_ICONV)|g' \
 	      -e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \
--- a/tests/test-iconv-h-c++.cc
+++ b/tests/test-iconv-h-c++.cc
@@ -22,20 +22,22 @@
 #if HAVE_ICONV
 # include <iconv.h>
 
-# ifndef ICONV_CONST
-#  define ICONV_CONST /* empty */
-# endif
-
 # include "signature.h"
 
 
+#if GNULIB_TEST_ICONV
 SIGNATURE_CHECK (GNULIB_NAMESPACE::iconv_open, iconv_t,
                  (const char *, const char *));
+#endif
 
+#if GNULIB_TEST_ICONV
 SIGNATURE_CHECK (GNULIB_NAMESPACE::iconv, size_t,
                  (iconv_t, ICONV_CONST char **, size_t *, char **, size_t *));
+#endif
 
+#if GNULIB_TEST_ICONV
 SIGNATURE_CHECK (GNULIB_NAMESPACE::iconv_close, int, (iconv_t));
+#endif
 
 #endif
 
--- a/tests/test-iconv-h.c
+++ b/tests/test-iconv-h.c
@@ -18,10 +18,6 @@
 
 #if HAVE_ICONV
 # include <iconv.h>
-
-# ifndef ICONV_CONST
-#  define ICONV_CONST /* empty */
-# endif
 #endif
 
 int