Mercurial > hg > octave-lyh > gnulib-hg
changeset 10938:84611717fa6c
Work around a btowc() bug on IRIX 6.5.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 21 Dec 2008 17:35:30 +0100 |
parents | 0f69cfb5fbf7 |
children | 4ee0271437dd |
files | ChangeLog doc/posix-functions/btowc.texi lib/wchar.in.h m4/btowc.m4 m4/wchar.m4 modules/wchar |
diffstat | 6 files changed, 67 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +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.
--- a/doc/posix-functions/btowc.texi +++ b/doc/posix-functions/btowc.texi @@ -11,6 +11,9 @@ @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:
--- a/lib/wchar.in.h +++ b/lib/wchar.in.h @@ -84,7 +84,11 @@ /* 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
--- a/m4/btowc.m4 +++ b/m4/btowc.m4 @@ -1,4 +1,4 @@ -# 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, @@ -11,6 +11,51 @@ 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
--- a/m4/wchar.m4 +++ b/m4/wchar.m4 @@ -7,7 +7,7 @@ dnl Written by Eric Blake. -# wchar.m4 serial 17 +# wchar.m4 serial 18 AC_DEFUN([gl_WCHAR_H], [ @@ -81,6 +81,7 @@ 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])
--- a/modules/wchar +++ b/modules/wchar @@ -45,6 +45,7 @@ -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' \