From f480581dc6834f060592a11c256b08068b518d42 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 27 Nov 2010 04:08:53 +0100 Subject: [PATCH] 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. --- ChangeLog | 19 +++++++++++++++++++ lib/iconv.in.h | 45 +++++++++++++++++++++++++++------------------ m4/iconv.m4 | 9 ++++++++- m4/iconv_h.m4 | 4 +++- m4/iconv_open.m4 | 8 +------- modules/iconv | 1 + modules/iconv-h | 1 + tests/test-iconv-h-c++.cc | 10 ++++++---- tests/test-iconv-h.c | 4 ---- 9 files changed, 66 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index ef8ca49c9..5f32d447a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2010-11-26 Bruno Haible + + 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 ftoastr: comment fix diff --git a/lib/iconv.in.h b/lib/iconv.in.h index 6d0d9123a..1e452cf35 100644 --- 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 +# endif _GL_CXXALIASWARN (iconv_open); +#endif #if @REPLACE_ICONV_UTF@ /* Special constants for supporting UTF-{16,32}{BE,LE} encodings. @@ -66,10 +68,11 @@ _GL_CXXALIASWARN (iconv_open); # 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 @@ _GL_CXXALIAS_RPL (iconv, size_t, (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 +# endif _GL_CXXALIASWARN (iconv); - -#if @REPLACE_ICONV@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define iconv_close rpl_iconv_close +# ifndef ICONV_CONST +# define ICONV_CONST @ICONV_CONST@ # endif +#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 +# endif _GL_CXXALIASWARN (iconv_close); +#endif #endif /* _GL_ICONV_H */ diff --git a/m4/iconv.m4 b/m4/iconv.m4 index 425145c0a..7d1959423 100644 --- 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 @@ size_t iconv(); $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 . + 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 ]) diff --git a/m4/iconv_h.m4 b/m4/iconv_h.m4 index 7366cb98e..3b9987b0c 100644 --- 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_MODULE_INDICATOR], 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]) diff --git a/m4/iconv_open.m4 b/m4/iconv_open.m4 index 7b2488095..101671814 100644 --- 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_DEFUN([gl_FUNC_ICONV_OPEN_UTF], 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], [ diff --git a/modules/iconv b/modules/iconv index 5d81aa3db..ca8b04854 100644 --- a/modules/iconv +++ b/modules/iconv @@ -9,6 +9,7 @@ havelib configure.ac: AM_ICONV +gl_ICONV_MODULE_INDICATOR([iconv]) Makefile.am: diff --git a/modules/iconv-h b/modules/iconv-h index 46399cd2a..df0e07086 100644 --- a/modules/iconv-h +++ b/modules/iconv-h @@ -26,6 +26,7 @@ iconv.h: iconv.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -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' \ diff --git a/tests/test-iconv-h-c++.cc b/tests/test-iconv-h-c++.cc index f00758263..5fc49664d 100644 --- a/tests/test-iconv-h-c++.cc +++ b/tests/test-iconv-h-c++.cc @@ -22,20 +22,22 @@ #if HAVE_ICONV # include -# 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 diff --git a/tests/test-iconv-h.c b/tests/test-iconv-h.c index 10a8e3d69..c27c9ba5d 100644 --- a/tests/test-iconv-h.c +++ b/tests/test-iconv-h.c @@ -18,10 +18,6 @@ #if HAVE_ICONV # include - -# ifndef ICONV_CONST -# define ICONV_CONST /* empty */ -# endif #endif int -- 2.11.0