]> Savannah Git Hosting - gnulib.git/commitdiff
wctype-h: Work around iswprint bug on mingw.
authorBruno Haible <bruno@clisp.org>
Wed, 26 Jul 2023 12:13:48 +0000 (14:13 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 26 Jul 2023 12:13:48 +0000 (14:13 +0200)
* lib/wctype.in.h (rpl_iswprint): On mingw, don't use the system's
iswprint function.
* tests/test-wctype-h.c (main): Verify that this character class
contains the ASCII space but not tab and newline.
* tests/test-c32isprint.c (main): For tab, \v, \f, expect the same value
on native Windows as on other platforms.
* doc/posix-functions/iswprint.texi: Mention the mingw bug.

ChangeLog
doc/posix-functions/iswprint.texi
lib/wctype.in.h
tests/test-c32isprint.c
tests/test-wctype-h.c

index 3d602638deffbb6f7c1fad258aa146768fdf74e6..930191fd98f0d889c78e70a72d7321b259a4c687 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-07-26  Bruno Haible  <bruno@clisp.org>
+
+       wctype-h: Work around iswprint bug on mingw.
+       * lib/wctype.in.h (rpl_iswprint): On mingw, don't use the system's
+       iswprint function.
+       * tests/test-wctype-h.c (main): Verify that this character class
+       contains the ASCII space but not tab and newline.
+       * tests/test-c32isprint.c (main): For tab, \v, \f, expect the same value
+       on native Windows as on other platforms.
+       * doc/posix-functions/iswprint.texi: Mention the mingw bug.
+
 2023-07-26  Bruno Haible  <bruno@clisp.org>
 
        iswblank tests: Add more tests.
index 90ce3057e032a5bb17f6f44d8992c45a4f46cb6d..728baa0b7bb9b0db1a45793bc44a29a14b1a4430 100644 (file)
@@ -15,6 +15,10 @@ Minix 3.1.8.
 This function cannot be called from plain inline or extern inline functions
 on some platforms:
 OS X 10.8.
+@item
+This function returns true for the tab (@code{'\t'}) character
+on some platforms:
+mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 926a78d62186175f744679f1bd22202b67f817fe..a8649b83a155242fa5d31c6a880436a6ce8ecbea 100644 (file)
@@ -132,7 +132,8 @@ typedef unsigned int rpl_wint_t;
 /* 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.
    mingw and MSVC have <wctype.h> and the functions but they take a wchar_t
-   as argument, not an rpl_wint_t.
+   as argument, not an rpl_wint_t.  Additionally, the mingw iswprint function
+   is broken.
    Assume all 11 functions (all isw* except iswblank) are implemented the
    same way, or not at all.  */
 # if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
@@ -184,7 +185,11 @@ rpl_iswlower (wint_t wc)
 _GL_WCTYPE_INLINE int
 rpl_iswprint (wint_t wc)
 {
+#   ifdef __MINGW32__
+  return ((wchar_t) wc == wc ? wc == ' ' || iswgraph ((wchar_t) wc) : 0);
+#   else
   return ((wchar_t) wc == wc ? iswprint ((wchar_t) wc) : 0);
+#   endif
 }
 
 _GL_WCTYPE_INLINE int
index b7617ee105e056dba9ba0005e250dad1ad72ad2d..18ccf556777f2ad9d8f1f814eec0dc1971df0b35 100644 (file)
@@ -68,9 +68,7 @@ main (int argc, char *argv[])
     for (c = 0; c < 0x100; c++)
       switch (c)
         {
-        #if !(defined _WIN32 && !defined __CYGWIN__)
         case '\t': case '\v': case '\f':
-        #endif
         case ' ': case '!': case '"': case '#': case '%':
         case '&': case '\'': case '(': case ')': case '*':
         case '+': case ',': case '-': case '.': case '/':
index ceee02bc7f69cf3d64bdb379d623337f6d6ef268..af02fe7eb6f315f66ed1bbdac092a408d2b5a42a 100644 (file)
@@ -62,6 +62,11 @@ main (void)
   ASSERT (!iswupper (e));
   ASSERT (!iswxdigit (e));
 
+  /* Sanity check for the iswprint function.  */
+  ASSERT (iswprint (L' '));
+  ASSERT (!iswprint (L'\t'));
+  ASSERT (!iswprint (L'\n'));
+
   /* Check that the tow* functions exist as functions or as macros.  */
   (void) towlower (0);
   (void) towupper (0);