Replace the isw* functions on Linux libc5.
authorBruno Haible <bruno@clisp.org>
Mon, 21 Apr 2008 23:56:52 +0000 (01:56 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 21 Apr 2008 23:56:52 +0000 (01:56 +0200)
16 files changed:
ChangeLog
doc/posix-functions/iswalnum.texi
doc/posix-functions/iswalpha.texi
doc/posix-functions/iswblank.texi
doc/posix-functions/iswcntrl.texi
doc/posix-functions/iswdigit.texi
doc/posix-functions/iswgraph.texi
doc/posix-functions/iswlower.texi
doc/posix-functions/iswprint.texi
doc/posix-functions/iswpunct.texi
doc/posix-functions/iswspace.texi
doc/posix-functions/iswupper.texi
doc/posix-functions/iswxdigit.texi
lib/wctype.in.h
m4/wctype.m4
modules/wctype

index e8e9525..21b435d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
 2008-04-21  Bruno Haible  <bruno@clisp.org>
 
+       * 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  <bruno@clisp.org>
+
        * m4/vsnprintf.m4 (gl_FUNC_VSNPRINTF): Fix typo in last commit.
        Patch by Alain Guibert.
 
index 4eedee4..ca0ceea 100644 (file)
@@ -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
index 80bba79..6e491f9 100644 (file)
@@ -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
index 9ea0d91..d229808 100644 (file)
@@ -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:
index a9602c7..a60ced6 100644 (file)
@@ -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
index a73f05c..8e747fc 100644 (file)
@@ -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
index 76b8459..42fd60a 100644 (file)
@@ -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
index 9f89a9b..8c8c794 100644 (file)
@@ -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
index d2cef7e..e8ba900 100644 (file)
@@ -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
index c79b9c1..58b7e07 100644 (file)
@@ -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
index 5a43254..671e14f 100644 (file)
@@ -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
index dbe04c2..3d5fae9 100644 (file)
@@ -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
index fe1837b..c7dab23 100644 (file)
@@ -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
index 73ce09f..feb6656 100644 (file)
@@ -1,6 +1,6 @@
 /* A substitute for ISO C99 <wctype.h>, 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 <wctype.h> but lacks the functions.
+   Linux libc5 has <wctype.h> 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 <ctype.h> macros like _P, and they
@@ -78,6 +79,22 @@ typedef int __wctype_wint_t;
 #  undef iswupper
 #  undef iswxdigit
 
+/* Linux libc5 has <wctype.h> 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)
 {
index 7483c4f..7c6718c 100644 (file)
@@ -1,6 +1,6 @@
 dnl A placeholder for ISO C99 <wctype.h>, 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 <stddef.h>
+                      #include <stdio.h>
+                      #include <time.h>
+                      #include <wchar.h>
+                      #include <wctype.h>
+                      int main () { return iswprint ('x') == 0; }],
+            [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no])
+        ],
+        [
+          AC_TRY_COMPILE([#include <stdlib.h>
+                          #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])
 ])
index 156235c..b8ee21a 100644 (file)
@@ -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 $@