Mercurial > hg > octave-lyh > gnulib-hg
changeset 10922:91831148c181
Work around wctob bug on Solaris 9.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 21 Dec 2008 01:22:07 +0100 |
parents | bafc6771d75a |
children | ecb63809e77e |
files | ChangeLog doc/posix-functions/wctob.texi lib/wchar.in.h m4/wchar.m4 m4/wctob.m4 modules/wchar modules/wctob |
diffstat | 7 files changed, 80 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +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
--- a/doc/posix-functions/wctob.texi +++ b/doc/posix-functions/wctob.texi @@ -12,6 +12,9 @@ This function is missing on some platforms: HP-UX 11, IRIX 5.3, Solaris 2.6, mingw, Interix 3.5. @item +This function does not work on some platforms: +Solaris 9. +@item This function is missing a declaration on some platforms: IRIX 6.5. @end itemize
--- a/lib/wchar.in.h +++ b/lib/wchar.in.h @@ -97,7 +97,11 @@ /* 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
--- a/m4/wchar.m4 +++ b/m4/wchar.m4 @@ -7,7 +7,7 @@ dnl Written by Eric Blake. -# wchar.m4 serial 12 +# wchar.m4 serial 13 AC_DEFUN([gl_WCHAR_H], [ @@ -76,6 +76,7 @@ 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]) ])
--- a/m4/wctob.m4 +++ b/m4/wctob.m4 @@ -1,4 +1,4 @@ -# 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, @@ -15,8 +15,59 @@ 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 @@ -26,9 +77,10 @@ #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 ])
--- a/modules/wchar +++ b/modules/wchar @@ -40,6 +40,7 @@ -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; \