From: Bruno Haible Date: Wed, 26 Jul 2023 13:12:47 +0000 (+0200) Subject: wctype: Work around wctype+iswctype bug on MSVC. X-Git-Tag: v1.0~1028 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=d8fc9af5ec2ebb1fd68ae3d366fbc76fee852e08;p=gnulib.git wctype: Work around wctype+iswctype bug on MSVC. * m4/wctype.m4 (gl_FUNC_WCTYPE): In the test program, test also for the MSVC bug. Update cross-compilation guess. * doc/posix-functions/wctype.texi: Mention the MSVC bug. --- diff --git a/ChangeLog b/ChangeLog index f1e00c8b70..180d60cbb5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2023-07-26 Bruno Haible + + wctype: Work around wctype+iswctype bug on MSVC. + * m4/wctype.m4 (gl_FUNC_WCTYPE): In the test program, test also for the + MSVC bug. Update cross-compilation guess. + * doc/posix-functions/wctype.texi: Mention the MSVC bug. + 2023-07-26 Bruno Haible wctype: Work around wctype bug on mingw. diff --git a/doc/posix-functions/wctype.texi b/doc/posix-functions/wctype.texi index e4a2b58056..af35ed1f35 100644 --- a/doc/posix-functions/wctype.texi +++ b/doc/posix-functions/wctype.texi @@ -19,6 +19,11 @@ HP-UX 11.00. This function does not support the @code{"blank"} character class on some platforms: mingw. +@item +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. @end itemize Portability problems not fixed by Gnulib: diff --git a/m4/wctype.m4 b/m4/wctype.m4 index c006873d1b..321bd696fb 100644 --- a/m4/wctype.m4 +++ b/m4/wctype.m4 @@ -1,4 +1,4 @@ -# wctype.m4 serial 3 +# wctype.m4 serial 4 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, @@ -17,19 +17,21 @@ AC_DEFUN_ONCE([gl_FUNC_WCTYPE], [AC_LANG_SOURCE([[ #include #include - int main () { return wctype ("blank") == (wctype_t)0; } + int main () + { + /* This test fails on mingw. */ + if (wctype ("blank") == (wctype_t)0) + return 1; + /* This test fails on MSVC 14. */ + if ((! iswctype ('\t', wctype ("blank"))) != (! iswblank ('\t'))) + return 2; + return 0; + } ]])], [gl_cv_func_wctype_works=yes], [gl_cv_func_wctype_works=no], [case "$host_os" in - # Guess no on mingw. - mingw*) AC_EGREP_CPP([Problem], [ -#ifdef __MINGW32__ - Problem -#endif - ], - [gl_cv_func_wctype_works="guessing no"], - [gl_cv_func_wctype_works="guessing yes"]) - ;; + # Guess no on native Windows. + mingw*) gl_cv_func_wctype_works="guessing no" ;; # Guess yes otherwise. *) gl_cv_func_wctype_works="guessing yes" ;; esac