Mercurial > hg > octave-kai > gnulib-hg
changeset 13009:15a1a8b07c32
wctype: Provide iswblank function.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 19 Mar 2010 22:46:56 +0100 |
parents | e0ce493c0059 |
children | 23b6d428ea53 |
files | ChangeLog doc/posix-functions/iswblank.texi lib/wctype.in.h m4/wctype_h.m4 modules/wctype tests/test-wctype.c |
diffstat | 6 files changed, 34 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +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.
--- 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
--- a/lib/wctype.in.h +++ b/lib/wctype.in.h @@ -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 @@ 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__
--- 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 <wctype.h>, 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])
--- 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' \
--- 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));