+2008-12-20 Bruno Haible <bruno@clisp.org>
+
+ Work around wctob bug on Solaris <= 9.
+ * lib/wchar.in.h (wctob): Redefine if REPLACE_WCTOB is set.
+ * m4/wctob.m4 (gl_FUNC_WCTOB): Test whether wctob works.
+ * m4/wchar.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_WCTOB.
+ * modules/wchar (Makefile.am): Substitute REPLACE_WCTOB.
+ * modules/wctob (Files): Add m4/locale-fr.m4.
+ * doc/posix-functions/wctob.texi: Mention the Solaris bug.
+
2008-12-20 Bruno Haible <bruno@clisp.org>
* doc/posix-functions/select.texi: Mention Solaris 2.6 bug with
/* Convert a wide character to a single-byte character. */
#if @GNULIB_WCTOB@
-# if !defined wctob && !@HAVE_DECL_WCTOB@
+# if @REPLACE_WCTOB@
+# undef wctob
+# define wctob rpl_wctob
+# endif
+# if (!defined wctob && !@HAVE_DECL_WCTOB@) || @REPLACE_WCTOB@
/* wctob is provided by gnulib, or wctob exists but is not declared. */
extern int wctob (wint_t wc);
# endif
dnl Written by Eric Blake.
-# wchar.m4 serial 12
+# wchar.m4 serial 13
AC_DEFUN([gl_WCHAR_H],
[
HAVE_MBSRTOWCS=1; AC_SUBST([HAVE_MBSRTOWCS])
HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB])
HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
+ REPLACE_WCTOB=0; AC_SUBST([REPLACE_WCTOB])
REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
WCHAR_H=''; AC_SUBST([WCHAR_H])
])
-# wctob.m4 serial 2
+# wctob.m4 serial 3
dnl Copyright (C) 2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_LIBOBJ([wctob])
gl_PREREQ_WCTOB
else
- dnl IRIX 6.5 has the wctob() function but does not declare it.
- AC_CHECK_DECLS([wctob], [], [], [
+
+ dnl Solaris 9 has the wctob() function but it does not work.
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([gt_LOCALE_FR])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether wctob works],
+ [gl_cv_func_wctob_works],
+ [
+ dnl Initial guess, used when cross-compiling or when no suitable locale
+ dnl is present.
+changequote(,)dnl
+ case "$host_os" in
+ # Guess no on Solaris <= 9.
+ solaris2.[1-9] | solaris2.[1-9].*)
+ gl_cv_func_wctob_works="guessing no" ;;
+ # Guess yes otherwise.
+ *) gl_cv_func_wctob_works="guessing yes" ;;
+ esac
+changequote([,])dnl
+ if test $LOCALE_FR != none; then
+ AC_TRY_RUN([
+#include <locale.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+ if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+ {
+ wchar_t wc;
+
+ if (mbtowc (&wc, "\374", 1) == 1)
+ if (wctob (wc) != (unsigned char) '\374')
+ return 1;
+ }
+ return 0;
+}],
+ [gl_cv_func_wctob_works=yes],
+ [gl_cv_func_wctob_works=no],
+ [])
+ fi
+ ])
+ case "$gl_cv_func_wctob_works" in
+ *yes) ;;
+ *) REPLACE_WCTOB=1 ;;
+ esac
+ if test $REPLACE_WCTOB = 1; then
+ gl_REPLACE_WCHAR_H
+ AC_LIBOBJ([wctob])
+ gl_PREREQ_WCTOB
+ else
+
+ dnl IRIX 6.5 has the wctob() function but does not declare it.
+ AC_CHECK_DECLS([wctob], [], [], [
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
<wchar.h>.
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
#include <time.h>
#include <wchar.h>
])
- if test $ac_cv_have_decl_wctob != yes; then
- HAVE_DECL_WCTOB=0
- gl_REPLACE_WCHAR_H
+ if test $ac_cv_have_decl_wctob != yes; then
+ HAVE_DECL_WCTOB=0
+ gl_REPLACE_WCHAR_H
+ fi
fi
fi
])
-e 's|@''HAVE_MBSRTOWCS''@|$(HAVE_MBSRTOWCS)|g' \
-e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \
-e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
+ -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \
-e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
< $(srcdir)/wchar.in.h; \