From a07c0e4b0c5659d04b77a3f6b636c1ade7358fbb Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 30 Aug 2023 02:19:01 +0200 Subject: [PATCH] wctype: Rely on module iswpunct. * m4/wctype.m4 (gl_FUNC_WCTYPE): Also test whether the "punct" class works. * modules/wctype (Depends-on): Add iswpunct. * tests/test-iswctype.c (main): Add more tests of the "punct" class. * doc/posix-functions/wctype.texi: Mention the Android problem. --- ChangeLog | 7 +++++++ doc/posix-functions/wctype.texi | 4 ++++ m4/wctype.m4 | 10 ++++++++-- modules/wctype | 1 + tests/test-iswctype.c | 28 ++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ae888b304a..a839600839 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2023-08-29 Bruno Haible + wctype: Rely on module iswpunct. + * m4/wctype.m4 (gl_FUNC_WCTYPE): Also test whether the "punct" class + works. + * modules/wctype (Depends-on): Add iswpunct. + * tests/test-iswctype.c (main): Add more tests of the "punct" class. + * doc/posix-functions/wctype.texi: Mention the Android problem. + c32ispunct: Rely on module iswpunct. * modules/c32ispunct (Depends-on): Add iswpunct. * tests/test-c32ispunct.c (main): Add a few more tests in the "C" diff --git a/doc/posix-functions/wctype.texi b/doc/posix-functions/wctype.texi index 957403ccee..6346703b60 100644 --- a/doc/posix-functions/wctype.texi +++ b/doc/posix-functions/wctype.texi @@ -24,6 +24,10 @@ The object returned by this function for the @code{"blank"} character class is inconsistent with the @code{iswblank} and @code{isblank} functions on some platforms: MSVC 14. +@item +The object returned by this function for the @code{"punct"} character class +is inconsistent with the @code{ispunct} function on some platforms: +Android 11. @end itemize Portability problems not fixed by Gnulib: diff --git a/m4/wctype.m4 b/m4/wctype.m4 index ad78c8b166..4f3a836dc5 100644 --- a/m4/wctype.m4 +++ b/m4/wctype.m4 @@ -1,4 +1,4 @@ -# wctype.m4 serial 5 +# wctype.m4 serial 6 dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,10 +11,11 @@ AC_DEFUN_ONCE([gl_FUNC_WCTYPE], AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles HAVE_WCTYPE=$HAVE_WCTYPE_T if test $HAVE_WCTYPE = 1; then - AC_CACHE_CHECK([whether wctype supports the "blank" character class], + AC_CACHE_CHECK([whether wctype supports the "blank" and "punct" character classes], [gl_cv_func_wctype_works], [AC_RUN_IFELSE( [AC_LANG_SOURCE([[ + #include #include #include int main () @@ -25,6 +26,9 @@ AC_DEFUN_ONCE([gl_FUNC_WCTYPE], /* This test fails on MSVC 14. */ if ((! iswctype ('\t', wctype ("blank"))) != (! iswblank ('\t'))) return 2; + /* This test fails on Android 11. */ + if ((! iswctype ('\`', wctype ("punct"))) != (! ispunct ('\`'))) + return 4; return 0; } ]])], @@ -32,6 +36,8 @@ AC_DEFUN_ONCE([gl_FUNC_WCTYPE], [case "$host_os" in # Guess no on native Windows. mingw* | windows*) gl_cv_func_wctype_works="guessing no" ;; + # Guess no on Android. + android*) gl_cv_func_wctype_works="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_wctype_works="guessing yes" ;; esac diff --git a/modules/wctype b/modules/wctype index f3e449938b..69f2deb608 100644 --- a/modules/wctype +++ b/modules/wctype @@ -10,6 +10,7 @@ Depends-on: wctype-h iswblank [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1] iswdigit [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1] +iswpunct [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1] iswxdigit [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1] # When we override wctype_t, we also need to override iswctype(). iswctype [test $REPLACE_WCTYPE = 1] diff --git a/tests/test-iswctype.c b/tests/test-iswctype.c index a500f53fa2..fabd1b6a31 100644 --- a/tests/test-iswctype.c +++ b/tests/test-iswctype.c @@ -53,10 +53,38 @@ main (int argc, char *argv[]) desc = wctype ("punct"); ASSERT (desc != (wctype_t) 0); + ASSERT (iswctype (L'!', desc)); + ASSERT (iswctype (L'"', desc)); + ASSERT (iswctype (L'#', desc)); ASSERT (iswctype (L'$', desc)); + ASSERT (iswctype (L'%', desc)); + ASSERT (iswctype (L'&', desc)); + ASSERT (iswctype (L'\'', desc)); + ASSERT (iswctype (L'(', desc)); + ASSERT (iswctype (L')', desc)); + ASSERT (iswctype (L'*', desc)); + ASSERT (iswctype (L'+', desc)); + ASSERT (iswctype (L',', desc)); + ASSERT (iswctype (L'-', desc)); ASSERT (iswctype (L'.', desc)); + ASSERT (iswctype (L'/', desc)); + ASSERT (iswctype (L':', desc)); + ASSERT (iswctype (L';', desc)); ASSERT (iswctype (L'<', desc)); + ASSERT (iswctype (L'=', desc)); ASSERT (iswctype (L'>', desc)); + ASSERT (iswctype (L'?', desc)); + ASSERT (iswctype (L'@', desc)); + ASSERT (iswctype (L'[', desc)); + ASSERT (iswctype (L'\\', desc)); + ASSERT (iswctype (L']', desc)); + ASSERT (iswctype (L'^', desc)); + ASSERT (iswctype (L'_', desc)); + ASSERT (iswctype (L'`', desc)); + ASSERT (iswctype (L'{', desc)); + ASSERT (iswctype (L'|', desc)); + ASSERT (iswctype (L'}', desc)); + ASSERT (iswctype (L'~', desc)); ASSERT (! iswctype (L' ', desc)); ASSERT (! iswctype (L'a', desc)); ASSERT (! iswctype (L'1', desc)); -- 2.39.5