From: Bruno Haible Date: Sun, 21 Dec 2008 00:22:07 +0000 (+0100) Subject: Work around wctob bug on Solaris 9. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1876e6e277008edfa4d9e66b19ba2bb939c6b00;p=pspp Work around wctob bug on Solaris 9. --- diff --git a/ChangeLog b/ChangeLog index ad623c7f2f..91792f1548 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-12-20 Bruno Haible + + 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 * doc/posix-functions/select.texi: Mention Solaris 2.6 bug with diff --git a/doc/posix-functions/wctob.texi b/doc/posix-functions/wctob.texi index d61066064b..b6585f7a5e 100644 --- a/doc/posix-functions/wctob.texi +++ b/doc/posix-functions/wctob.texi @@ -12,6 +12,9 @@ Portability problems fixed by Gnulib: 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 diff --git a/lib/wchar.in.h b/lib/wchar.in.h index 2a8f839efd..e4647331e3 100644 --- a/lib/wchar.in.h +++ b/lib/wchar.in.h @@ -97,7 +97,11 @@ extern wint_t btowc (int c); /* 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 diff --git a/m4/wchar.m4 b/m4/wchar.m4 index d7455f74ab..02e7f188c9 100644 --- a/m4/wchar.m4 +++ b/m4/wchar.m4 @@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl Written by Eric Blake. -# wchar.m4 serial 12 +# wchar.m4 serial 13 AC_DEFUN([gl_WCHAR_H], [ @@ -76,6 +76,7 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS], 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]) ]) diff --git a/m4/wctob.m4 b/m4/wctob.m4 index b9b83872d3..40cb70986e 100644 --- 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_DEFUN([gl_FUNC_WCTOB], 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 +#include +#include +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: must be included before . BSD/OS 4.0.1 has a bug: , and must be included @@ -26,9 +77,10 @@ AC_DEFUN([gl_FUNC_WCTOB], #include #include ]) - 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 ]) diff --git a/modules/wchar b/modules/wchar index e38a6daefa..f0bbe92775 100644 --- a/modules/wchar +++ b/modules/wchar @@ -40,6 +40,7 @@ wchar.h: wchar.in.h -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; \ diff --git a/modules/wctob b/modules/wctob index d32cbcbea0..c4dc155694 100644 --- a/modules/wctob +++ b/modules/wctob @@ -4,6 +4,7 @@ wctob() function: convert wide character to unibyte character. Files: lib/wctob.c m4/wctob.m4 +m4/locale-fr.m4 Depends-on: wchar