# HG changeset patch # User Bruno Haible # Date 1269035216 -3600 # Node ID 15a1a8b07c3221adcc0878c5af7c11008e06acc9 # Parent e0ce493c0059386cedd4e1a31bfdc37e864e1a23 wctype: Provide iswblank function. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-03-19 Bruno Haible + + 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 Tests of module 'pty' in C++ mode. diff --git a/doc/posix-functions/iswblank.texi b/doc/posix-functions/iswblank.texi --- a/doc/posix-functions/iswblank.texi +++ b/doc/posix-functions/iswblank.texi @@ -9,6 +9,9 @@ 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 @@ 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 diff --git a/lib/wctype.in.h b/lib/wctype.in.h --- a/lib/wctype.in.h +++ b/lib/wctype.in.h @@ -69,7 +69,8 @@ /* 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. */ + 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 @@ 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__ diff --git a/m4/wctype_h.m4 b/m4/wctype_h.m4 --- a/m4/wctype_h.m4 +++ b/m4/wctype_h.m4 @@ -1,4 +1,4 @@ -# wctype_h.m4 serial 5 +# wctype_h.m4 serial 6 dnl A placeholder for ISO C99 , for platforms that lack it. @@ -20,6 +20,13 @@ 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]) diff --git a/modules/wctype b/modules/wctype --- a/modules/wctype +++ b/modules/wctype @@ -26,6 +26,7 @@ -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' \ diff --git a/tests/test-wctype.c b/tests/test-wctype.c --- a/tests/test-wctype.c +++ b/tests/test-wctype.c @@ -33,9 +33,7 @@ /* 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 @@ /* 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));