From 5feb6a2ef2c57b51ebe76ed8a173cd1acc77b4bc Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 22 Apr 2008 01:56:52 +0200 Subject: [PATCH] Replace the isw* functions on Linux libc5. --- ChangeLog | 22 ++++++++++++++++++++ doc/posix-functions/iswalnum.texi | 11 ++++++---- doc/posix-functions/iswalpha.texi | 11 ++++++---- doc/posix-functions/iswblank.texi | 5 ++++- doc/posix-functions/iswcntrl.texi | 11 ++++++---- doc/posix-functions/iswdigit.texi | 11 ++++++---- doc/posix-functions/iswgraph.texi | 11 ++++++---- doc/posix-functions/iswlower.texi | 11 ++++++---- doc/posix-functions/iswprint.texi | 11 ++++++---- doc/posix-functions/iswpunct.texi | 11 ++++++---- doc/posix-functions/iswspace.texi | 11 ++++++---- doc/posix-functions/iswupper.texi | 11 ++++++---- doc/posix-functions/iswxdigit.texi | 11 ++++++---- lib/wctype.in.h | 21 +++++++++++++++++-- m4/wctype.m4 | 33 ++++++++++++++++++++++++++++-- modules/wctype | 1 + 16 files changed, 154 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index e8e952595d..21b435dcf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2008-04-21 Bruno Haible + + * lib/wctype.in.h (iswalnum, iswalpha, iswblank, iswcntrl, iswdigit, + iswgraph, iswlower, iswprint, iswpunct, iswspace, iswupper, iswxdigit): + Define to replacements if REPLACE_ISWCNTRL is 1. + * m4/wctype.m4 (gl_WCTYPE_H): Test whether the isw* functions work. + If not, set WCTYPE_H to nonempty and REPLACE_ISWCNTRL to 1. + * modules/wctype (Makefile.am): Substitute REPLACE_ISWCNTRL. + * doc/posix-functions/iswalnum.texi: Mention the 'wctype' module and + what it fixes. + * doc/posix-functions/iswalpha.texi: Likewise. + * doc/posix-functions/iswblank.texi: Likewise. + * doc/posix-functions/iswcntrl.texi: Likewise. + * doc/posix-functions/iswdigit.texi: Likewise. + * doc/posix-functions/iswgraph.texi: Likewise. + * doc/posix-functions/iswlower.texi: Likewise. + * doc/posix-functions/iswprint.texi: Likewise. + * doc/posix-functions/iswpunct.texi: Likewise. + * doc/posix-functions/iswspace.texi: Likewise. + * doc/posix-functions/iswupper.texi: Likewise. + * doc/posix-functions/iswxdigit.texi: Likewise. + 2008-04-21 Bruno Haible * m4/vsnprintf.m4 (gl_FUNC_VSNPRINTF): Fix typo in last commit. diff --git a/doc/posix-functions/iswalnum.texi b/doc/posix-functions/iswalnum.texi index 4eedee4dac..ca0ceeaec8 100644 --- a/doc/posix-functions/iswalnum.texi +++ b/doc/posix-functions/iswalnum.texi @@ -4,18 +4,21 @@ POSIX specification: @url{http://www.opengroup.org/susv3xsh/iswalnum.html} -Gnulib module: --- +Gnulib module: wctype Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +Solaris 2.5.1. +@item +This function returns 0 for all possible arguments on some platforms: +Linux libc5. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -Solaris 2.5.1. -@item On Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. @end itemize diff --git a/doc/posix-functions/iswalpha.texi b/doc/posix-functions/iswalpha.texi index 80bba7969d..6e491f922e 100644 --- a/doc/posix-functions/iswalpha.texi +++ b/doc/posix-functions/iswalpha.texi @@ -4,18 +4,21 @@ POSIX specification: @url{http://www.opengroup.org/susv3xsh/iswalpha.html} -Gnulib module: --- +Gnulib module: wctype Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +Solaris 2.5.1. +@item +This function returns 0 for all possible arguments on some platforms: +Linux libc5. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -Solaris 2.5.1. -@item On Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. @end itemize diff --git a/doc/posix-functions/iswblank.texi b/doc/posix-functions/iswblank.texi index 9ea0d9145b..d229808ea6 100644 --- a/doc/posix-functions/iswblank.texi +++ b/doc/posix-functions/iswblank.texi @@ -4,10 +4,13 @@ POSIX specification: @url{http://www.opengroup.org/susv3xsh/iswblank.html} -Gnulib module: --- +Gnulib module: wctype Portability problems fixed by Gnulib: @itemize +@item +This function returns 0 for all possible arguments on some platforms: +Linux libc5. @end itemize Portability problems not fixed by Gnulib: diff --git a/doc/posix-functions/iswcntrl.texi b/doc/posix-functions/iswcntrl.texi index a9602c730a..a60ced6f2b 100644 --- a/doc/posix-functions/iswcntrl.texi +++ b/doc/posix-functions/iswcntrl.texi @@ -4,18 +4,21 @@ POSIX specification: @url{http://www.opengroup.org/susv3xsh/iswcntrl.html} -Gnulib module: --- +Gnulib module: wctype Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +Solaris 2.5.1. +@item +This function returns 0 for all possible arguments on some platforms: +Linux libc5. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -Solaris 2.5.1. -@item On Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. @end itemize diff --git a/doc/posix-functions/iswdigit.texi b/doc/posix-functions/iswdigit.texi index a73f05ce14..8e747fcaee 100644 --- a/doc/posix-functions/iswdigit.texi +++ b/doc/posix-functions/iswdigit.texi @@ -4,18 +4,21 @@ POSIX specification: @url{http://www.opengroup.org/susv3xsh/iswdigit.html} -Gnulib module: --- +Gnulib module: wctype Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +Solaris 2.5.1. +@item +This function returns 0 for all possible arguments on some platforms: +Linux libc5. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -Solaris 2.5.1. -@item On Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. @end itemize diff --git a/doc/posix-functions/iswgraph.texi b/doc/posix-functions/iswgraph.texi index 76b8459ab6..42fd60a61e 100644 --- a/doc/posix-functions/iswgraph.texi +++ b/doc/posix-functions/iswgraph.texi @@ -4,18 +4,21 @@ POSIX specification: @url{http://www.opengroup.org/susv3xsh/iswgraph.html} -Gnulib module: --- +Gnulib module: wctype Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +Solaris 2.5.1. +@item +This function returns 0 for all possible arguments on some platforms: +Linux libc5. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -Solaris 2.5.1. -@item On Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. @end itemize diff --git a/doc/posix-functions/iswlower.texi b/doc/posix-functions/iswlower.texi index 9f89a9b1a9..8c8c7940ab 100644 --- a/doc/posix-functions/iswlower.texi +++ b/doc/posix-functions/iswlower.texi @@ -4,18 +4,21 @@ POSIX specification: @url{http://www.opengroup.org/susv3xsh/iswlower.html} -Gnulib module: --- +Gnulib module: wctype Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +Solaris 2.5.1. +@item +This function returns 0 for all possible arguments on some platforms: +Linux libc5. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -Solaris 2.5.1. -@item On Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. @end itemize diff --git a/doc/posix-functions/iswprint.texi b/doc/posix-functions/iswprint.texi index d2cef7e81b..e8ba9003ae 100644 --- a/doc/posix-functions/iswprint.texi +++ b/doc/posix-functions/iswprint.texi @@ -4,18 +4,21 @@ POSIX specification: @url{http://www.opengroup.org/susv3xsh/iswprint.html} -Gnulib module: --- +Gnulib module: wctype Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +Solaris 2.5.1. +@item +This function returns 0 for all possible arguments on some platforms: +Linux libc5. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -Solaris 2.5.1. -@item On Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. @end itemize diff --git a/doc/posix-functions/iswpunct.texi b/doc/posix-functions/iswpunct.texi index c79b9c1f63..58b7e0769f 100644 --- a/doc/posix-functions/iswpunct.texi +++ b/doc/posix-functions/iswpunct.texi @@ -4,18 +4,21 @@ POSIX specification: @url{http://www.opengroup.org/susv3xsh/iswpunct.html} -Gnulib module: --- +Gnulib module: wctype Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +Solaris 2.5.1. +@item +This function returns 0 for all possible arguments on some platforms: +Linux libc5. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -Solaris 2.5.1. -@item On Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. @end itemize diff --git a/doc/posix-functions/iswspace.texi b/doc/posix-functions/iswspace.texi index 5a43254fc2..671e14fff2 100644 --- a/doc/posix-functions/iswspace.texi +++ b/doc/posix-functions/iswspace.texi @@ -4,18 +4,21 @@ POSIX specification: @url{http://www.opengroup.org/susv3xsh/iswspace.html} -Gnulib module: --- +Gnulib module: wctype Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +Solaris 2.5.1. +@item +This function returns 0 for all possible arguments on some platforms: +Linux libc5. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -Solaris 2.5.1. -@item On Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. @end itemize diff --git a/doc/posix-functions/iswupper.texi b/doc/posix-functions/iswupper.texi index dbe04c2992..3d5fae9aaf 100644 --- a/doc/posix-functions/iswupper.texi +++ b/doc/posix-functions/iswupper.texi @@ -4,18 +4,21 @@ POSIX specification: @url{http://www.opengroup.org/susv3xsh/iswupper.html} -Gnulib module: --- +Gnulib module: wctype Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +Solaris 2.5.1. +@item +This function returns 0 for all possible arguments on some platforms: +Linux libc5. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -Solaris 2.5.1. -@item On Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. @end itemize diff --git a/doc/posix-functions/iswxdigit.texi b/doc/posix-functions/iswxdigit.texi index fe1837beae..c7dab23fa6 100644 --- a/doc/posix-functions/iswxdigit.texi +++ b/doc/posix-functions/iswxdigit.texi @@ -4,18 +4,21 @@ POSIX specification: @url{http://www.opengroup.org/susv3xsh/iswxdigit.html} -Gnulib module: --- +Gnulib module: wctype Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +Solaris 2.5.1. +@item +This function returns 0 for all possible arguments on some platforms: +Linux libc5. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -Solaris 2.5.1. -@item On Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. @end itemize diff --git a/lib/wctype.in.h b/lib/wctype.in.h index 73ce09f450..feb66565d1 100644 --- a/lib/wctype.in.h +++ b/lib/wctype.in.h @@ -1,6 +1,6 @@ /* A substitute for ISO C99 , for platforms that lack it. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2006-2008 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -57,8 +57,9 @@ typedef int __wctype_wint_t; #endif /* FreeBSD 4.4 to 4.11 has but lacks the functions. + Linux libc5 has and the functions but they are broken. Assume all 12 functions are implemented the same way, or not at all. */ -#if ! @HAVE_ISWCNTRL@ +#if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@ /* IRIX 5.3 has macros but no functions, its isw* macros refer to an undefined variable _ctmp_ and to macros like _P, and they @@ -78,6 +79,22 @@ typedef int __wctype_wint_t; # undef iswupper # undef iswxdigit +/* Linux libc5 has and the functions but they are broken. */ +# if @REPLACE_ISWCNTRL@ +# define iswalnum rpl_iswalnum +# define iswalpha rpl_iswalpha +# define iswblank rpl_iswblank +# define iswcntrl rpl_iswcntrl +# define iswdigit rpl_iswdigit +# define iswgraph rpl_iswgraph +# define iswlower rpl_iswlower +# define iswprint rpl_iswprint +# define iswpunct rpl_iswpunct +# define iswspace rpl_iswspace +# define iswupper rpl_iswupper +# define iswxdigit rpl_iswxdigit +# endif + static inline int iswalnum (__wctype_wint_t wc) { diff --git a/m4/wctype.m4 b/m4/wctype.m4 index 7483c4feaf..7c6718c3e1 100644 --- a/m4/wctype.m4 +++ b/m4/wctype.m4 @@ -1,6 +1,6 @@ dnl A placeholder for ISO C99 , for platforms that lack it. -dnl Copyright (C) 2006, 2007 Free Software Foundation, Inc. +dnl Copyright (C) 2006-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, dnl with or without modifications, as long as this notice is preserved. @@ -9,6 +9,7 @@ dnl Written by Paul Eggert. AC_DEFUN([gl_WCTYPE_H], [ + AC_REQUIRE([AC_PROG_CC]) AC_CHECK_FUNCS_ONCE([iswcntrl]) if test $ac_cv_func_iswcntrl = yes; then HAVE_ISWCNTRL=1 @@ -30,7 +31,28 @@ AC_DEFUN([gl_WCTYPE_H], WCTYPE_H=wctype.h if test $ac_cv_header_wctype_h = yes; then if test $ac_cv_func_iswcntrl = yes; then - WCTYPE_H= + dnl Linux libc5 has an iswprint function that returns 0 for all arguments. + dnl The other functions are likely broken in the same way. + AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works], + [ + AC_TRY_RUN([#include + #include + #include + #include + #include + int main () { return iswprint ('x') == 0; }], + [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no]) + ], + [ + AC_TRY_COMPILE([#include + #if __GNU_LIBRARY__ == 1 + Linux libc5 i18n is broken. + #endif], + [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no]) + ]) + if test $gl_cv_func_iswcntrl_works = yes; then + WCTYPE_H= + fi fi dnl Compute NEXT_WCTYPE_H even if WCTYPE_H is empty, dnl for the benefit of builds from non-distclean directories. @@ -41,4 +63,11 @@ AC_DEFUN([gl_WCTYPE_H], fi AC_SUBST([HAVE_WCTYPE_H]) AC_SUBST([WCTYPE_H]) + + if test "$gl_cv_func_iswcntrl_works" = no; then + REPLACE_ISWCNTRL=1 + else + REPLACE_ISWCNTRL=0 + fi + AC_SUBST([REPLACE_ISWCNTRL]) ]) diff --git a/modules/wctype b/modules/wctype index 156235c6ba..b8ee21abb8 100644 --- a/modules/wctype +++ b/modules/wctype @@ -25,6 +25,7 @@ wctype.h: wctype.in.h -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \ -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \ -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \ + -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \ < $(srcdir)/wctype.in.h; \ } > $@-t mv $@-t $@ -- 2.30.2