+2008-12-21 Bruno Haible <bruno@clisp.org>
+
+ Work around a btowc() bug on IRIX 6.5.
+ * lib/wchar.in.h (btowc): Override if REPLACE_BTOWC is set.
+ * m4/btowc.m4 (gl_FUNC_BTOWC): Test whether btowc(EOF) is correct. Set
+ REPLACE_WTOBC if not.
+ * m4/wchar.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_BTOWC.
+ * modules/wchar (Makefile.am): Substitute REPLACE_BTOWC.
+ * doc/posix-functions/btowc.texi: Mention the IRIX bug.
+
2008-12-21 Bruno Haible <bruno@clisp.org>
* modules/wcrtomb-tests: New file.
@item
This function is missing on some platforms:
HP-UX 11.00, IRIX 5.3, Solaris 2.6, mingw, Interix 3.5.
+@item
+This function does not return WEOF for an EOF argument on some platforms:
+IRIX 6.5.
@end itemize
Portability problems not fixed by Gnulib:
/* Convert a single-byte character to a wide character. */
#if @GNULIB_BTOWC@
-# if !@HAVE_BTOWC@
+# if @REPLACE_BTOWC@
+# undef btowc
+# define btowc rpl_btowc
+# endif
+# if !@HAVE_BTOWC@ || @REPLACE_BTOWC@
extern wint_t btowc (int c);
# endif
#elif defined GNULIB_POSIXCHECK
-# btowc.m4 serial 2
+# btowc.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_CHECK_FUNCS_ONCE([btowc])
if test $ac_cv_func_btowc = no; then
HAVE_BTOWC=0
+ else
+
+ dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF.
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([gt_LOCALE_FR])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether btowc(EOF) is correct],
+ [gl_cv_func_btowc_eof],
+ [
+ dnl Initial guess, used when cross-compiling or when no suitable locale
+ dnl is present.
+changequote(,)dnl
+ case "$host_os" in
+ # Guess no on IRIX.
+ irix*) gl_cv_func_btowc_eof="guessing no" ;;
+ # Guess yes otherwise.
+ *) gl_cv_func_btowc_eof="guessing yes" ;;
+ esac
+changequote([,])dnl
+ if test $LOCALE_FR != none; then
+ AC_TRY_RUN([
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+ if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+ {
+ if (btowc (EOF) != WEOF)
+ return 1;
+ }
+ return 0;
+}],
+ [gl_cv_func_btowc_eof=yes],
+ [gl_cv_func_btowc_eof=no],
+ [])
+ fi
+ ])
+ case "$gl_cv_func_btowc_eof" in
+ *yes) ;;
+ *) REPLACE_BTOWC=1 ;;
+ esac
+ fi
+ if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then
gl_REPLACE_WCHAR_H
AC_LIBOBJ([btowc])
gl_PREREQ_BTOWC
dnl Written by Eric Blake.
-# wchar.m4 serial 17
+# wchar.m4 serial 18
AC_DEFUN([gl_WCHAR_H],
[
HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB])
HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
+ REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC])
REPLACE_WCTOB=0; AC_SUBST([REPLACE_WCTOB])
REPLACE_MBSINIT=0; AC_SUBST([REPLACE_MBSINIT])
REPLACE_MBRTOWC=0; AC_SUBST([REPLACE_MBRTOWC])
-e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \
-e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
-e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \
+ -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \
-e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \
-e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \
-e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \