wctype: Provide iswblank function.
authorBruno Haible <bruno@clisp.org>
Fri, 19 Mar 2010 21:46:56 +0000 (22:46 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 19 Mar 2010 21:46:56 +0000 (22:46 +0100)
ChangeLog
doc/posix-functions/iswblank.texi
lib/wctype.in.h
m4/wctype_h.m4
modules/wctype
tests/test-wctype.c

index 3b8e0cd..0e54678 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2010-03-19  Bruno Haible  <bruno@clisp.org>
 
+       wctype: Provide iswblank function.
+       * lib/wctype.in.h (iswblank): Provide a replacement also when iswcntrl
+       exists and is fine.
+       * m4/wctype_h.m4 (gl_WCTYPE_H): Also check whether iswcntrl exists.
+       * modules/wctype (Makefile.am): Substitute HAVE_ISWBLANK.
+       * tests/test-wctype.c (main): Re-enable the iswblank tests.
+       * doc/posix-functions/iswblank.texi: Update.
+
+2010-03-19  Bruno Haible  <bruno@clisp.org>
+
        Tests of module 'pty' in C++ mode.
        * modules/pty-tests: New file.
        * tests/test-pty-c++.cc: New file.
index e8ea1be..7aa4bd5 100644 (file)
@@ -9,6 +9,9 @@ Gnulib module: wctype
 Portability problems fixed by Gnulib:
 @itemize
 @item
+This function is missing on some platforms:
+AIX 4.3.2, IRIX 6.5, OSF/1 5.1, Solaris 9, mingw.
+@item
 This function returns 0 for all possible arguments on some platforms:
 Linux libc5.
 @end itemize
@@ -16,9 +19,6 @@ Linux libc5.
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-AIX 4.3.2, IRIX 6.5, OSF/1 5.1, Solaris 9, mingw.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
index 0693014..8016203 100644 (file)
@@ -69,7 +69,8 @@
 
 /* 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.  */
+   Assume all 11 functions (all isw* except iswblank) are implemented the
+   same way, or not at all.  */
 #if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
 
 /* IRIX 5.3 has macros but no functions, its isw* macros refer to an
@@ -271,7 +272,16 @@ towupper
   return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
 }
 
-#endif /* ! HAVE_ISWCNTRL || REPLACE_ISWCNTRL */
+#elif ! @HAVE_ISWBLANK@
+/* Only the iswblank function is missing.  */
+
+static inline int
+iswblank (wint_t wc)
+{
+  return wc == ' ' || wc == '\t';
+}
+
+#endif
 
 #if defined __MINGW32__
 
index 83daffc..3292451 100644 (file)
@@ -1,4 +1,4 @@
-# wctype_h.m4 serial 5
+# wctype_h.m4 serial 6
 
 dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
 
@@ -20,6 +20,13 @@ AC_DEFUN([gl_WCTYPE_H],
     HAVE_ISWCNTRL=0
   fi
   AC_SUBST([HAVE_ISWCNTRL])
+  AC_CHECK_FUNCS_ONCE([iswblank])
+  if test $ac_cv_func_iswblank = yes; then
+    HAVE_ISWBLANK=1
+  else
+    HAVE_ISWBLANK=0
+  fi
+  AC_SUBST([HAVE_ISWBLANK])
   AC_CHECK_HEADERS_ONCE([wctype.h])
   AC_REQUIRE([AC_C_INLINE])
 
index 4666b3c..b212e35 100644 (file)
@@ -26,6 +26,7 @@ wctype.h: wctype.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
              -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
              -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \
+             -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \
              -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \
              -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
              -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
index 49d7cfa..5db215e 100644 (file)
@@ -33,9 +33,7 @@ main (void)
   /* Check that the isw* functions exist as functions or as macros.  */
   (void) iswalnum (0);
   (void) iswalpha (0);
-#if 0 /* not portable: missing on mingw */
   (void) iswblank (0);
-#endif
   (void) iswcntrl (0);
   (void) iswdigit (0);
   (void) iswgraph (0);
@@ -49,9 +47,7 @@ main (void)
   /* Check that the isw* functions map WEOF to 0.  */
   ASSERT (!iswalnum (e));
   ASSERT (!iswalpha (e));
-#if 0 /* not portable: missing on mingw */
   ASSERT (!iswblank (e));
-#endif
   ASSERT (!iswcntrl (e));
   ASSERT (!iswdigit (e));
   ASSERT (!iswgraph (e));