At the moment, there are three pieces of wctype functions and macros, such as `iswspace`, scattering in ctype.h, wctype.h, and wchar.h. What's worse is that they are not kept quite synchronized; some of them are not declared properly according to `__MSVCRT_VERSION__`.

This series of patches attempt to unify them to wctype.h.


--
Best regards,
LIU Hao

From 0172c9b57561dab8bbd7a084e09c5f72904b3ad0 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mo...@126.com>
Date: Mon, 24 Feb 2025 16:10:28 +0800
Subject: [PATCH 1/9] crt/is{,w}blank: Suppress macros when compiling these
 functions

`__NO_CTYPE_LINES` was not referenced anywhere, so it's removed.

Signed-off-by: LIU Hao <lh_mo...@126.com>
---
 mingw-w64-crt/misc/isblank.c  | 2 +-
 mingw-w64-crt/misc/iswblank.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mingw-w64-crt/misc/isblank.c b/mingw-w64-crt/misc/isblank.c
index ce6247c1c..b49fc6423 100644
--- a/mingw-w64-crt/misc/isblank.c
+++ b/mingw-w64-crt/misc/isblank.c
@@ -1,4 +1,4 @@
-#define __NO_CTYPE_LINES
+#define _CTYPE_DISABLE_MACROS
 #include <ctype.h>
 
 int __cdecl isblank (int _C)
diff --git a/mingw-w64-crt/misc/iswblank.c b/mingw-w64-crt/misc/iswblank.c
index bdf73e564..6a556b189 100644
--- a/mingw-w64-crt/misc/iswblank.c
+++ b/mingw-w64-crt/misc/iswblank.c
@@ -1,5 +1,5 @@
-#define _CRT_WCTYPE_NOINLINE
-#include <ctype.h>
+#define _WCTYPE_INLINE_DEFINED
+#include <wctype.h>
 
 int __cdecl iswblank (wint_t _C)
 {
-- 
2.48.1

From 1104f5bba0860245a887517c219f3a7e3a981ebc Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mo...@126.com>
Date: Mon, 24 Feb 2025 18:14:35 +0800
Subject: [PATCH 2/9] headers/ctype: Declare `isblank()` and `_isblank_l()` for
 MSVCR120 and UCRT

Signed-off-by: LIU Hao <lh_mo...@126.com>
---
 mingw-w64-headers/crt/ctype.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index 922dab67a..161f3bdeb 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -111,9 +111,11 @@ extern "C" {
   _CRTIMP int __cdecl __toascii(int _C);
   _CRTIMP int __cdecl __iscsymf(int _C);
   _CRTIMP int __cdecl __iscsym(int _C);
-
-#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || !defined 
(NO_OLDNAMES) || defined (__cplusplus)
-int __cdecl isblank(int _C);
+#if __MSVCRT_VERSION__ >= 0xC00
+  _CRTIMP int __cdecl isblank(int _C);
+  _CRTIMP int __cdecl _isblank_l(int _C,_locale_t _Locale);
+#else
+  int __cdecl isblank(int _C);
 #endif
 #endif
 
-- 
2.48.1

From 41e503d0a04381e2502394e89ffc2e2c0569ddf6 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mo...@126.com>
Date: Mon, 24 Feb 2025 16:12:51 +0800
Subject: [PATCH 3/9] headers/wctype: Copy declarations from ctype.h

The changes in that commit were done to a wrong header. Technically speaking,
wide functions should not be declared in ctype.h. They will be removed in the
next commit.

`__iswcsym()` and `__iswcsymf()` are not exported from MSVCRT, only MSVCR80+.

Signed-off-by: LIU Hao <lh_mo...@126.com>
---
 mingw-w64-headers/crt/wctype.h | 84 ++++++++++++++++++++++++----------
 1 file changed, 61 insertions(+), 23 deletions(-)

diff --git a/mingw-w64-headers/crt/wctype.h b/mingw-w64-headers/crt/wctype.h
index b45ba26c9..2a1911c54 100644
--- a/mingw-w64-headers/crt/wctype.h
+++ b/mingw-w64-headers/crt/wctype.h
@@ -86,30 +86,61 @@ extern "C" {
 #ifndef _WCTYPE_DEFINED
 #define _WCTYPE_DEFINED
 
-  int __cdecl iswalpha(wint_t);
-  int __cdecl iswupper(wint_t);
-  int __cdecl iswlower(wint_t);
-  int __cdecl iswdigit(wint_t);
-  int __cdecl iswxdigit(wint_t);
-  int __cdecl iswspace(wint_t);
-  int __cdecl iswpunct(wint_t);
-  int __cdecl iswalnum(wint_t);
-  int __cdecl iswprint(wint_t);
-  int __cdecl iswgraph(wint_t);
-  int __cdecl iswcntrl(wint_t);
-  int __cdecl iswascii(wint_t);
-  int __cdecl isleadbyte(int);
-  wint_t __cdecl towupper(wint_t);
-  wint_t __cdecl towlower(wint_t);
-  int __cdecl iswctype(wint_t,wctype_t);
-#if __MSVCRT_VERSION__ >= 0x800
-  _CRTIMP int __cdecl __iswcsymf(wint_t);
-  _CRTIMP int __cdecl __iswcsym(wint_t);
-#endif
-  int __cdecl is_wctype(wint_t,wctype_t);
-#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || !defined 
(NO_OLDNAMES) || defined (__cplusplus)
-int __cdecl iswblank(wint_t _C);
+  _CRTIMP int __cdecl iswalpha(wint_t _C);
+  _CRTIMP int __cdecl iswupper(wint_t _C);
+  _CRTIMP int __cdecl iswlower(wint_t _C);
+  _CRTIMP int __cdecl iswdigit(wint_t _C);
+  _CRTIMP int __cdecl iswxdigit(wint_t _C);
+  _CRTIMP int __cdecl iswspace(wint_t _C);
+  _CRTIMP int __cdecl iswpunct(wint_t _C);
+  _CRTIMP int __cdecl iswalnum(wint_t _C);
+  _CRTIMP int __cdecl iswprint(wint_t _C);
+  _CRTIMP int __cdecl iswgraph(wint_t _C);
+  _CRTIMP int __cdecl iswcntrl(wint_t _C);
+  _CRTIMP int __cdecl iswascii(wint_t _C);
+#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
+  _CRTIMP int __cdecl isleadbyte(int _C);
+#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
+  _CRTIMP wint_t __cdecl towupper(wint_t _C);
+  _CRTIMP wint_t __cdecl towlower(wint_t _C);
+  _CRTIMP int __cdecl iswctype(wint_t _C,wctype_t _Type);
+#if __MSVCRT_VERSION__ >= 0x800 || (__MSVCRT_VERSION__ == 0x600 && 
_WIN32_WINNT >= 0x0600)
+  /* These are available since msvcr80.dll (__MSVCRT_VERSION__ >= 0x800), and 
in
+   * msvcrt.dll (__MSVCRT_VERSION__ == 0x600) since Vista (_WIN32_WINNT >= 
0x0600). */
+  _CRTIMP int __cdecl _iswalpha_l(wint_t _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _iswupper_l(wint_t _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _iswlower_l(wint_t _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _iswdigit_l(wint_t _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _iswxdigit_l(wint_t _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _iswspace_l(wint_t _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _iswpunct_l(wint_t _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _iswalnum_l(wint_t _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _iswprint_l(wint_t _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _iswgraph_l(wint_t _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _iswcntrl_l(wint_t _C,_locale_t _Locale);
+# ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
+  _CRTIMP int __cdecl _isleadbyte_l(int _C,_locale_t _Locale);
+# endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
+  _CRTIMP wint_t __cdecl _towupper_l(wint_t _C,_locale_t _Locale);
+  _CRTIMP wint_t __cdecl _towlower_l(wint_t _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _iswctype_l(wint_t _C,wctype_t _Type,_locale_t _Locale);
 #endif
+#if __MSVCRT_VERSION__ >= 0x800
+  /* These are only available since msvcr80.dll, never in msvcrt.dll. */
+  _CRTIMP int __cdecl __iswcsymf(wint_t _C);
+  _CRTIMP int __cdecl __iswcsym(wint_t _C);
+  _CRTIMP int __cdecl _iswcsymf_l(wint_t _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _iswcsym_l(wint_t _C,_locale_t _Locale);
+#endif
+#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
+  int __cdecl is_wctype(wint_t _C,wctype_t _Type);
+#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
+#if __MSVCRT_VERSION__ >= 0xC00
+  _CRTIMP int __cdecl iswblank(wint_t _C);
+  _CRTIMP int __cdecl _iswblank_l(wint_t _C,_locale_t _Locale);
+#else
+  int __cdecl iswblank(wint_t _C);
+#endif  /* msvcr120 */
 #endif
 
 #ifndef _WCTYPE_INLINE_DEFINED
@@ -127,6 +158,7 @@ int __cdecl iswblank(wint_t _C);
 #define iswgraph(_c) (iswctype(_c,_PUNCT|_ALPHA|_DIGIT))
 #define iswcntrl(_c) (iswctype(_c,_CONTROL))
 #define iswascii(_c) ((unsigned)(_c) < 0x80)
+#define iswblank(_c) (iswctype(_c,_BLANK) || ((_c)=='\t'))
 #define isleadbyte(c) (__pctype_func()[(unsigned char)(c)] & _LEADBYTE)
 #else
 #ifndef __CRT__NO_INLINE
@@ -142,11 +174,17 @@ int __cdecl iswblank(wint_t _C);
   __CRT_INLINE int __cdecl iswgraph(wint_t _C) {return 
(iswctype(_C,_PUNCT|_ALPHA|_DIGIT)); }
   __CRT_INLINE int __cdecl iswcntrl(wint_t _C) {return 
(iswctype(_C,_CONTROL)); }
   __CRT_INLINE int __cdecl iswascii(wint_t _C) {return ((unsigned)(_C) < 
0x80); }
+  __CRT_INLINE int __cdecl iswblank(wint_t _C) {return (iswctype(_C,_BLANK) || 
((_C)=='\t')); }
   __CRT_INLINE int __cdecl isleadbyte(int _C) {return 
(__pctype_func()[(unsigned char)(_C)] & _LEADBYTE); }
 #endif /* !__CRT__NO_INLINE */
 #endif /* __cplusplus */
 #endif
 
+#define __iswcsymf(_c) (iswalpha(_c) || ((_c)=='_'))
+#define __iswcsym(_c) (iswalnum(_c) || ((_c)=='_'))
+#define _iswcsymf_l(_c,_p) (_iswalpha_l(_c,_p) || ((_c)=='_'))
+#define _iswcsym_l(_c,_p) (_iswalnum_l(_c,_p) || ((_c)=='_'))
+
   typedef wchar_t wctrans_t;
   wint_t __cdecl towctrans(wint_t,wctrans_t);
   wctrans_t __cdecl wctrans(const char *);
-- 
2.48.1

From bf7d31ad853a9d830712d4173a9499950225aa55 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mo...@126.com>
Date: Mon, 24 Feb 2025 16:20:02 +0800
Subject: [PATCH 4/9] headers/wchar: Deduplicate wctype declarations by
 including <wctype.h>

Signed-off-by: LIU Hao <lh_mo...@126.com>
---
 mingw-w64-headers/crt/wchar.h | 139 +---------------------------------
 1 file changed, 1 insertion(+), 138 deletions(-)

diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h
index ca2c1fc70..04818083c 100644
--- a/mingw-w64-headers/crt/wchar.h
+++ b/mingw-w64-headers/crt/wchar.h
@@ -9,6 +9,7 @@
 #include <corecrt.h>
 #include <corecrt_stdio_config.h>
 #include <corecrt_wstdlib.h>
+#include <wctype.h>
 
 #if __USE_MINGW_ANSI_STDIO && !defined (__USE_MINGW_STRTOX) && 
!defined(_CRTBLD)
 #define __USE_MINGW_STRTOX 1
@@ -148,109 +149,6 @@ _CRTIMP FILE *__cdecl __acrt_iob_func(unsigned index);
 
 #define _WConst_return _CONST_RETURN
 
-#ifndef _CRT_CTYPEDATA_DEFINED
-#define _CRT_CTYPEDATA_DEFINED
-#ifndef _CTYPE_DISABLE_MACROS
-
-#ifndef __PCTYPE_FUNC
-#define __PCTYPE_FUNC __pctype_func()
-  _CRTIMP const unsigned short* __pctype_func(void);
-#endif
-
-#ifndef _pctype
-#define _pctype (__pctype_func())
-#endif
-#endif
-#endif
-
-#ifndef _CRT_WCTYPEDATA_DEFINED
-#define _CRT_WCTYPEDATA_DEFINED
-#ifndef _CTYPE_DISABLE_MACROS
-#if !defined(_wctype) && defined(_CRT_USE_WINAPI_FAMILY_DESKTOP_APP)
-  extern const unsigned short ** __MINGW_IMP_SYMBOL(_wctype);
-#define _wctype (* __MINGW_IMP_SYMBOL(_wctype))
-#endif
-
-  _CRTIMP const wctype_t * __cdecl __pwctype_func(void);
-#ifndef _pwctype
-#define _pwctype (__pwctype_func())
-#endif
-
-#endif
-#endif
-
-#define _UPPER 0x1
-#define _LOWER 0x2
-#define _DIGIT 0x4
-#define _SPACE 0x8
-
-#define _PUNCT 0x10
-#define _CONTROL 0x20
-#define _BLANK 0x40
-#define _HEX 0x80
-
-#define _LEADBYTE 0x8000
-#define _ALPHA (0x0100|_UPPER|_LOWER)
-
-#ifndef _WCTYPE_DEFINED
-#define _WCTYPE_DEFINED
-
-  int __cdecl iswalpha(wint_t _C);
-  int __cdecl iswupper(wint_t _C);
-  int __cdecl iswlower(wint_t _C);
-  int __cdecl iswdigit(wint_t _C);
-  int __cdecl iswxdigit(wint_t _C);
-  int __cdecl iswspace(wint_t _C);
-  int __cdecl iswpunct(wint_t _C);
-  int __cdecl iswalnum(wint_t _C);
-  int __cdecl iswprint(wint_t _C);
-  int __cdecl iswgraph(wint_t _C);
-  int __cdecl iswcntrl(wint_t _C);
-  int __cdecl iswascii(wint_t _C);
-#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
-  int __cdecl isleadbyte(int _C);
-#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
-  wint_t __cdecl towupper(wint_t _C);
-  wint_t __cdecl towlower(wint_t _C);
-  int __cdecl iswctype(wint_t _C,wctype_t _Type);
-#if __MSVCRT_VERSION__ >= 0x800 || (__MSVCRT_VERSION__ == 0x600 && 
_WIN32_WINNT >= 0x0600)
-  /* These are available since msvcr80.dll (__MSVCRT_VERSION__ >= 0x800), and 
in
-   * msvcrt.dll (__MSVCRT_VERSION__ == 0x600) since Vista (_WIN32_WINNT >= 
0x0600). */
-  _CRTIMP int __cdecl _iswalpha_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswupper_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswlower_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswdigit_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswxdigit_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswspace_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswpunct_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswalnum_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswprint_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswgraph_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswcntrl_l(wint_t _C,_locale_t _Locale);
-# ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
-  _CRTIMP int __cdecl _isleadbyte_l(int _C,_locale_t _Locale);
-# endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
-  _CRTIMP wint_t __cdecl _towupper_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP wint_t __cdecl _towlower_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswctype_l(wint_t _C,wctype_t _Type,_locale_t _Locale);
-  _CRTIMP int __cdecl __iswcsymf(wint_t _C);
-  _CRTIMP int __cdecl __iswcsym(wint_t _C);
-#endif
-#if __MSVCRT_VERSION__ >= 0x800
-  /* These are only available since msvcr80.dll, never in msvcrt.dll. */
-  _CRTIMP int __cdecl _iswcsymf_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswcsym_l(wint_t _C,_locale_t _Locale);
-#endif
-#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
-  int __cdecl is_wctype(wint_t _C,wctype_t _Type);
-#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
-
-#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || !defined 
(NO_OLDNAMES) || defined (__cplusplus)
-  int __cdecl iswblank(wint_t _C);
-#endif
-
-#endif
-
 #ifndef _WDIRECT_DEFINED
 #define _WDIRECT_DEFINED
 
@@ -335,41 +233,6 @@ _CRTIMP FILE *__cdecl __acrt_iob_func(unsigned index);
 #endif
 #endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
 
-#ifndef _WCTYPE_INLINE_DEFINED
-#undef _CRT_WCTYPE_NOINLINE
-#if !defined(__cplusplus) || defined(_CRT_WCTYPE_NOINLINE)
-#define iswalpha(_c) (iswctype(_c,_ALPHA))
-#define iswupper(_c) (iswctype(_c,_UPPER))
-#define iswlower(_c) (iswctype(_c,_LOWER))
-#define iswdigit(_c) (iswctype(_c,_DIGIT))
-#define iswxdigit(_c) (iswctype(_c,_HEX))
-#define iswspace(_c) (iswctype(_c,_SPACE))
-#define iswpunct(_c) (iswctype(_c,_PUNCT))
-#define iswalnum(_c) (iswctype(_c,_ALPHA|_DIGIT))
-#define iswprint(_c) (iswctype(_c,_BLANK|_PUNCT|_ALPHA|_DIGIT))
-#define iswgraph(_c) (iswctype(_c,_PUNCT|_ALPHA|_DIGIT))
-#define iswcntrl(_c) (iswctype(_c,_CONTROL))
-#define iswascii(_c) ((unsigned)(_c) < 0x80)
-#if __MSVCRT_VERSION__ >= 0x800 || (__MSVCRT_VERSION__ == 0x600 && 
_WIN32_WINNT >= 0x0600)
-# define _iswalpha_l(_c,_p) (_iswctype_l(_c,_ALPHA,_p))
-# define _iswupper_l(_c,_p) (_iswctype_l(_c,_UPPER,_p))
-# define _iswlower_l(_c,_p) (_iswctype_l(_c,_LOWER,_p))
-# define _iswdigit_l(_c,_p) (_iswctype_l(_c,_DIGIT,_p))
-# define _iswxdigit_l(_c,_p) (_iswctype_l(_c,_HEX,_p))
-# define _iswspace_l(_c,_p) (_iswctype_l(_c,_SPACE,_p))
-# define _iswpunct_l(_c,_p) (_iswctype_l(_c,_PUNCT,_p))
-# define _iswalnum_l(_c,_p) (_iswctype_l(_c,_ALPHA|_DIGIT,_p))
-# define _iswprint_l(_c,_p) (_iswctype_l(_c,_BLANK|_PUNCT|_ALPHA|_DIGIT,_p))
-# define _iswgraph_l(_c,_p) (_iswctype_l(_c,_PUNCT|_ALPHA|_DIGIT,_p))
-# define _iswcntrl_l(_c,_p) (_iswctype_l(_c,_CONTROL,_p))
-#endif  /* __MSVCRT_VERSION__ >= 0x800 */
-#if !defined(_CTYPE_DISABLE_MACROS) && 
defined(_CRT_USE_WINAPI_FAMILY_DESKTOP_APP)
-#define isleadbyte(_c) (__PCTYPE_FUNC[(unsigned char)(_c)] & _LEADBYTE)
-#endif
-#endif
-#define _WCTYPE_INLINE_DEFINED
-#endif
-
 #if !defined(_POSIX_) || defined(__GNUC__)
 #ifndef _INO_T_DEFINED
 #define _INO_T_DEFINED
-- 
2.48.1

From 4a1880c3f2e91dfbd2d43d9089623a4af9086fd2 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mo...@126.com>
Date: Mon, 24 Feb 2025 17:59:01 +0800
Subject: [PATCH 5/9] headers/ctype: Remove wctype declarations

They belong in wctype.h, and users should include that instead.

Signed-off-by: LIU Hao <lh_mo...@126.com>
---
 mingw-w64-headers/crt/ctype.h | 114 +---------------------------------
 1 file changed, 2 insertions(+), 112 deletions(-)

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index 161f3bdeb..0f9ec3a8e 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -29,21 +29,6 @@ extern "C" {
 #define _pctype (__pctype_func())
 #endif
 
-#endif
-#endif
-
-#ifndef _CRT_WCTYPEDATA_DEFINED
-#define _CRT_WCTYPEDATA_DEFINED
-#ifndef _CTYPE_DISABLE_MACROS
-#if !defined(_wctype) && defined(_CRT_USE_WINAPI_FAMILY_DESKTOP_APP)
-  extern const unsigned short ** __MINGW_IMP_SYMBOL(_wctype);
-#define _wctype (* __MINGW_IMP_SYMBOL(_wctype))
-#endif
-
-  _CRTIMP const wctype_t * __cdecl __pwctype_func(void);
-#ifndef _pwctype
-#define _pwctype (__pwctype_func())
-#endif
 #endif
 #endif
 
@@ -116,65 +101,7 @@ extern "C" {
   _CRTIMP int __cdecl _isblank_l(int _C,_locale_t _Locale);
 #else
   int __cdecl isblank(int _C);
-#endif
-#endif
-
-#ifndef _WCTYPE_DEFINED
-#define _WCTYPE_DEFINED
-
-  _CRTIMP int __cdecl iswalpha(wint_t _C);
-  _CRTIMP int __cdecl iswupper(wint_t _C);
-  _CRTIMP int __cdecl iswlower(wint_t _C);
-  _CRTIMP int __cdecl iswdigit(wint_t _C);
-  _CRTIMP int __cdecl iswxdigit(wint_t _C);
-  _CRTIMP int __cdecl iswspace(wint_t _C);
-  _CRTIMP int __cdecl iswpunct(wint_t _C);
-  _CRTIMP int __cdecl iswalnum(wint_t _C);
-  _CRTIMP int __cdecl iswprint(wint_t _C);
-  _CRTIMP int __cdecl iswgraph(wint_t _C);
-  _CRTIMP int __cdecl iswcntrl(wint_t _C);
-  _CRTIMP int __cdecl iswascii(wint_t _C);
-#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
-  _CRTIMP int __cdecl isleadbyte(int _C);
-#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
-  _CRTIMP wint_t __cdecl towupper(wint_t _C);
-  _CRTIMP wint_t __cdecl towlower(wint_t _C);
-  _CRTIMP int __cdecl iswctype(wint_t _C,wctype_t _Type);
-#if __MSVCRT_VERSION__ >= 0x800 || (__MSVCRT_VERSION__ == 0x600 && 
_WIN32_WINNT >= 0x0600)
-  /* These are available since msvcr80.dll (__MSVCRT_VERSION__ >= 0x800), and 
in
-   * msvcrt.dll (__MSVCRT_VERSION__ == 0x600) since Vista (_WIN32_WINNT >= 
0x0600). */
-  _CRTIMP int __cdecl _iswalpha_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswupper_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswlower_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswdigit_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswxdigit_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswspace_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswpunct_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswalnum_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswprint_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswgraph_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswcntrl_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP wint_t __cdecl _towupper_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP wint_t __cdecl _towlower_l(wint_t _C,_locale_t _Locale);
-# ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
-  _CRTIMP int __cdecl _isleadbyte_l(int _C,_locale_t _Locale);
-# endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
-  _CRTIMP int __cdecl _iswctype_l(wint_t _C,wctype_t _Type,_locale_t _Locale);
-  _CRTIMP int __cdecl __iswcsymf(wint_t _C);
-  _CRTIMP int __cdecl __iswcsym(wint_t _C);
-#endif
-#if __MSVCRT_VERSION__ >= 0x800
-  /* These are only available since msvcr80.dll, never in msvcrt.dll. */
-  _CRTIMP int __cdecl _iswcsymf_l(wint_t _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _iswcsym_l(wint_t _C,_locale_t _Locale);
-#endif
-#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
-  _CRTIMP int __cdecl is_wctype(wint_t _C,wctype_t _Type);
-#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
-
-#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || !defined 
(NO_OLDNAMES) || defined (__cplusplus)
-int __cdecl iswblank(wint_t _C);
-#endif
+#endif  /* msvcr120 */
 #endif
 
 #ifndef _CTYPE_DISABLE_MACROS
@@ -211,48 +138,11 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
 #define __isascii(_Char) ((unsigned)(_Char) < 0x80)
 #define __toascii(_Char) ((_Char) & 0x7f)
 
-#ifndef _WCTYPE_INLINE_DEFINED
-#define _WCTYPE_INLINE_DEFINED
-
-#undef _CRT_WCTYPE_NOINLINE
-#ifndef __cplusplus
-#define iswalpha(_c) (iswctype(_c,_ALPHA))
-#define iswupper(_c) (iswctype(_c,_UPPER))
-#define iswlower(_c) (iswctype(_c,_LOWER))
-#define iswdigit(_c) (iswctype(_c,_DIGIT))
-#define iswxdigit(_c) (iswctype(_c,_HEX))
-#define iswspace(_c) (iswctype(_c,_SPACE))
-#define iswpunct(_c) (iswctype(_c,_PUNCT))
-#define iswalnum(_c) (iswctype(_c,_ALPHA|_DIGIT))
-#define iswprint(_c) (iswctype(_c,_BLANK|_PUNCT|_ALPHA|_DIGIT))
-#define iswgraph(_c) (iswctype(_c,_PUNCT|_ALPHA|_DIGIT))
-#define iswcntrl(_c) (iswctype(_c,_CONTROL))
-#define iswascii(_c) ((unsigned)(_c) < 0x80)
-#if __MSVCRT_VERSION__ >= 0x800 || (__MSVCRT_VERSION__ == 0x600 && 
_WIN32_WINNT >= 0x0600)
-# define _iswalpha_l(_c,_p) (_iswctype_l(_c,_ALPHA,_p))
-# define _iswupper_l(_c,_p) (_iswctype_l(_c,_UPPER,_p))
-# define _iswlower_l(_c,_p) (_iswctype_l(_c,_LOWER,_p))
-# define _iswdigit_l(_c,_p) (_iswctype_l(_c,_DIGIT,_p))
-# define _iswxdigit_l(_c,_p) (_iswctype_l(_c,_HEX,_p))
-# define _iswspace_l(_c,_p) (_iswctype_l(_c,_SPACE,_p))
-# define _iswpunct_l(_c,_p) (_iswctype_l(_c,_PUNCT,_p))
-# define _iswalnum_l(_c,_p) (_iswctype_l(_c,_ALPHA|_DIGIT,_p))
-# define _iswprint_l(_c,_p) (_iswctype_l(_c,_BLANK|_PUNCT|_ALPHA|_DIGIT,_p))
-# define _iswgraph_l(_c,_p) (_iswctype_l(_c,_PUNCT|_ALPHA|_DIGIT,_p))
-# define _iswcntrl_l(_c,_p) (_iswctype_l(_c,_CONTROL,_p))
-#endif  /* __MSVCRT_VERSION__ >= 0x800 */
-#endif
-#endif
-
 #define __iscsymf(_c) (isalpha(_c) || ((_c)=='_'))
 #define __iscsym(_c) (isalnum(_c) || ((_c)=='_'))
-#define __iswcsymf(_c) (iswalpha(_c) || ((_c)=='_'))
-#define __iswcsym(_c) (iswalnum(_c) || ((_c)=='_'))
 #define _iscsymf_l(_c,_p) (_isalpha_l(_c,_p) || ((_c)=='_'))
 #define _iscsym_l(_c,_p) (_isalnum_l(_c,_p) || ((_c)=='_'))
-#define _iswcsymf_l(_c,_p) (_iswalpha_l(_c,_p) || ((_c)=='_'))
-#define _iswcsym_l(_c,_p) (_iswalnum_l(_c,_p) || ((_c)=='_'))
-#endif
+#endif  /* _CTYPE_DISABLE_MACROS */
 
 #ifndef        NO_OLDNAMES
 #ifndef _CTYPE_DEFINED
-- 
2.48.1

From 16b01b93af38b1763f21caae3b9b9fb85a1d09b0 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mo...@126.com>
Date: Mon, 24 Feb 2025 17:34:58 +0800
Subject: [PATCH 6/9] headers/ctype: Organize functions and macros like
 wctype.h

Signed-off-by: LIU Hao <lh_mo...@126.com>
---
 mingw-w64-headers/crt/ctype.h | 114 ++++++++++++++++++++++++----------
 1 file changed, 80 insertions(+), 34 deletions(-)

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index 0f9ec3a8e..51f3562cd 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -62,40 +62,58 @@ extern "C" {
 #ifndef _CTYPE_DEFINED
 #define _CTYPE_DEFINED
 
-  _CRTIMP int __cdecl _isctype(int _C,int _Type);
-  _CRTIMP int __cdecl _isctype_l(int _C,int _Type,_locale_t _Locale);
   _CRTIMP int __cdecl isalpha(int _C);
-  _CRTIMP int __cdecl _isalpha_l(int _C,_locale_t _Locale);
   _CRTIMP int __cdecl isupper(int _C);
-  _CRTIMP int __cdecl _isupper_l(int _C,_locale_t _Locale);
   _CRTIMP int __cdecl islower(int _C);
-  _CRTIMP int __cdecl _islower_l(int _C,_locale_t _Locale);
   _CRTIMP int __cdecl isdigit(int _C);
-  _CRTIMP int __cdecl _isdigit_l(int _C,_locale_t _Locale);
   _CRTIMP int __cdecl isxdigit(int _C);
-  _CRTIMP int __cdecl _isxdigit_l(int _C,_locale_t _Locale);
   _CRTIMP int __cdecl isspace(int _C);
-  _CRTIMP int __cdecl _isspace_l(int _C,_locale_t _Locale);
   _CRTIMP int __cdecl ispunct(int _C);
-  _CRTIMP int __cdecl _ispunct_l(int _C,_locale_t _Locale);
   _CRTIMP int __cdecl isalnum(int _C);
-  _CRTIMP int __cdecl _isalnum_l(int _C,_locale_t _Locale);
   _CRTIMP int __cdecl isprint(int _C);
-  _CRTIMP int __cdecl _isprint_l(int _C,_locale_t _Locale);
   _CRTIMP int __cdecl isgraph(int _C);
-  _CRTIMP int __cdecl _isgraph_l(int _C,_locale_t _Locale);
   _CRTIMP int __cdecl iscntrl(int _C);
-  _CRTIMP int __cdecl _iscntrl_l(int _C,_locale_t _Locale);
+  _CRTIMP int __cdecl __isascii(int _C);
+  _CRTIMP int __cdecl __toascii(int _C);
+#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
+  _CRTIMP int __cdecl isleadbyte(int _C);
+#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
   _CRTIMP int __cdecl toupper(int _C);
+  _CRTIMP int __cdecl _toupper(int _C);
   _CRTIMP int __cdecl tolower(int _C);
   _CRTIMP int __cdecl _tolower(int _C);
-  _CRTIMP int __cdecl _tolower_l(int _C,_locale_t _Locale);
-  _CRTIMP int __cdecl _toupper(int _C);
+  _CRTIMP int __cdecl _isctype(int _C,int _Type);
+#if __MSVCRT_VERSION__ >= 0x800 || (__MSVCRT_VERSION__ == 0x600 && 
_WIN32_WINNT >= 0x0600)
+  /* These are available since msvcr80.dll (__MSVCRT_VERSION__ >= 0x800), and 
in
+   * msvcrt.dll (__MSVCRT_VERSION__ == 0x600) since Vista (_WIN32_WINNT >= 
0x0600). */
+  _CRTIMP int __cdecl _isalpha_l(int _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _isupper_l(int _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _islower_l(int _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _isdigit_l(int _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _isxdigit_l(int _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _isspace_l(int _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _ispunct_l(int _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _isalnum_l(int _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _isprint_l(int _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _isgraph_l(int _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _iscntrl_l(int _C,_locale_t _Locale);
+# ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
+  _CRTIMP int __cdecl _isleadbyte_l(int _C,_locale_t _Locale);
+# endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
   _CRTIMP int __cdecl _toupper_l(int _C,_locale_t _Locale);
-  _CRTIMP int __cdecl __isascii(int _C);
-  _CRTIMP int __cdecl __toascii(int _C);
+  _CRTIMP int __cdecl _tolower_l(int _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _isctype_l(int _C,int _Type,_locale_t _Locale);
   _CRTIMP int __cdecl __iscsymf(int _C);
   _CRTIMP int __cdecl __iscsym(int _C);
+#endif
+#if __MSVCRT_VERSION__ >= 0x800
+  /* These are only available since msvcr80.dll, never in msvcrt.dll. */
+  _CRTIMP int __cdecl _iscsymf_l(int _C,_locale_t _Locale);
+  _CRTIMP int __cdecl _iscsym_l(int _C,_locale_t _Locale);
+#endif
+#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
+  int __cdecl is_ctype(int _C,int _Type);
+#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
 #if __MSVCRT_VERSION__ >= 0xC00
   _CRTIMP int __cdecl isblank(int _C);
   _CRTIMP int __cdecl _isblank_l(int _C,_locale_t _Locale);
@@ -104,8 +122,51 @@ extern "C" {
 #endif  /* msvcr120 */
 #endif
 
-#ifndef _CTYPE_DISABLE_MACROS
+#ifndef _CTYPE_INLINE_DEFINED
+#define _CTYPE_INLINE_DEFINED
+#ifndef __cplusplus
+#define isalpha(_c) (_isctype(_c,_ALPHA))
+#define isupper(_c) (_isctype(_c,_UPPER))
+#define islower(_c) (_isctype(_c,_LOWER))
+#define isdigit(_c) (_isctype(_c,_DIGIT))
+#define isxdigit(_c) (_isctype(_c,_HEX))
+#define isspace(_c) (_isctype(_c,_SPACE))
+#define ispunct(_c) (_isctype(_c,_PUNCT))
+#define isalnum(_c) (_isctype(_c,_ALPHA|_DIGIT))
+#define isprint(_c) (_isctype(_c,_BLANK|_PUNCT|_ALPHA|_DIGIT))
+#define isgraph(_c) (_isctype(_c,_PUNCT|_ALPHA|_DIGIT))
+#define iscntrl(_c) (_isctype(_c,_CONTROL))
+#define __isascii(_c) ((unsigned)(_c) < 0x80)
+#define __toascii(_c) ((_c) & 0x7F)
+#define isblank(_c) (_isctype(_c,_BLANK) || ((_c)=='\t'))
+#define isleadbyte(c) (__pctype_func()[(unsigned char)(c)] & _LEADBYTE)
+#else
+#ifndef __CRT__NO_INLINE
+  __CRT_INLINE int __cdecl isalpha(int _C) {return (_isctype(_C,_ALPHA)); }
+  __CRT_INLINE int __cdecl isupper(int _C) {return (_isctype(_C,_UPPER)); }
+  __CRT_INLINE int __cdecl islower(int _C) {return (_isctype(_C,_LOWER)); }
+  __CRT_INLINE int __cdecl isdigit(int _C) {return (_isctype(_C,_DIGIT)); }
+  __CRT_INLINE int __cdecl isxdigit(int _C) {return (_isctype(_C,_HEX)); }
+  __CRT_INLINE int __cdecl isspace(int _C) {return (_isctype(_C,_SPACE)); }
+  __CRT_INLINE int __cdecl ispunct(int _C) {return (_isctype(_C,_PUNCT)); }
+  __CRT_INLINE int __cdecl isalnum(int _C) {return 
(_isctype(_C,_ALPHA|_DIGIT)); }
+  __CRT_INLINE int __cdecl isprint(int _C) {return 
(_isctype(_C,_BLANK|_PUNCT|_ALPHA|_DIGIT)); }
+  __CRT_INLINE int __cdecl isgraph(int _C) {return 
(_isctype(_C,_PUNCT|_ALPHA|_DIGIT)); }
+  __CRT_INLINE int __cdecl iscntrl(int _C) {return (_isctype(_C,_CONTROL)); }
+  __CRT_INLINE int __cdecl __isascii(int _C) {return ((unsigned)(_C) < 0x80); }
+  __CRT_INLINE int __cdecl __toascii(int _C) {return ((_C) & 0x7F); }
+  __CRT_INLINE int __cdecl isblank(int _C) {return (_isctype(_C,_BLANK) || 
((_C)=='\t')); }
+  __CRT_INLINE int __cdecl isleadbyte(int _C) {return 
(__pctype_func()[(unsigned char)(_C)] & _LEADBYTE); }
+#endif /* !__CRT__NO_INLINE */
+#endif /* __cplusplus */
+#endif
 
+#define __iscsymf(_c) (isalpha(_c) || ((_c)=='_'))
+#define __iscsym(_c) (isalnum(_c) || ((_c)=='_'))
+#define _iscsymf_l(_c,_p) (_isalpha_l(_c,_p) || ((_c)=='_'))
+#define _iscsym_l(_c,_p) (_isalnum_l(_c,_p) || ((_c)=='_'))
+
+#ifndef _CTYPE_DISABLE_MACROS
 #ifndef MB_CUR_MAX
 #define MB_CUR_MAX ___mb_cur_max_func()
 #ifndef __mb_cur_max
@@ -113,6 +174,7 @@ extern "C" {
 #endif
 _CRTIMP int __cdecl ___mb_cur_max_func(void);
 #endif
+#endif /* _CTYPE_DISABLE_MACROS */
 
 #define __chvalidchk(a,b) (__PCTYPE_FUNC[(unsigned char)(a)] & (b))
 #ifdef _UCRT
@@ -122,27 +184,11 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
 #define _chvalidchk_l(_Char,_Flag,_Locale) (!_Locale ? 
__chvalidchk(_Char,_Flag) : ((_locale_t)_Locale)->locinfo->pctype[(unsigned 
char)(_Char)] & (_Flag))
 #define _ischartype_l(_Char,_Flag,_Locale) (((_Locale)!=NULL && 
(((_locale_t)(_Locale))->locinfo->mb_cur_max) > 1) ? 
_isctype_l(_Char,(_Flag),_Locale) : _chvalidchk_l(_Char,_Flag,_Locale))
 #endif
-#define _isalpha_l(_Char,_Locale) _ischartype_l(_Char,_ALPHA,_Locale)
-#define _isupper_l(_Char,_Locale) _ischartype_l(_Char,_UPPER,_Locale)
-#define _islower_l(_Char,_Locale) _ischartype_l(_Char,_LOWER,_Locale)
-#define _isdigit_l(_Char,_Locale) _ischartype_l(_Char,_DIGIT,_Locale)
-#define _isxdigit_l(_Char,_Locale) _ischartype_l(_Char,_HEX,_Locale)
-#define _isspace_l(_Char,_Locale) _ischartype_l(_Char,_SPACE,_Locale)
-#define _ispunct_l(_Char,_Locale) _ischartype_l(_Char,_PUNCT,_Locale)
-#define _isalnum_l(_Char,_Locale) _ischartype_l(_Char,_ALPHA|_DIGIT,_Locale)
-#define _isprint_l(_Char,_Locale) 
_ischartype_l(_Char,_BLANK|_PUNCT|_ALPHA|_DIGIT,_Locale)
-#define _isgraph_l(_Char,_Locale) 
_ischartype_l(_Char,_PUNCT|_ALPHA|_DIGIT,_Locale)
-#define _iscntrl_l(_Char,_Locale) _ischartype_l(_Char,_CONTROL,_Locale)
-#define _tolower(_Char) ((_Char)-'A'+'a')
-#define _toupper(_Char) ((_Char)-'a'+'A')
-#define __isascii(_Char) ((unsigned)(_Char) < 0x80)
-#define __toascii(_Char) ((_Char) & 0x7f)
 
 #define __iscsymf(_c) (isalpha(_c) || ((_c)=='_'))
 #define __iscsym(_c) (isalnum(_c) || ((_c)=='_'))
 #define _iscsymf_l(_c,_p) (_isalpha_l(_c,_p) || ((_c)=='_'))
 #define _iscsym_l(_c,_p) (_isalnum_l(_c,_p) || ((_c)=='_'))
-#endif  /* _CTYPE_DISABLE_MACROS */
 
 #ifndef        NO_OLDNAMES
 #ifndef _CTYPE_DEFINED
-- 
2.48.1

From 1341183c8d7259b3256fa220190238eb5d74728f Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mo...@126.com>
Date: Mon, 24 Feb 2025 17:37:32 +0800
Subject: [PATCH 7/9] headers/wctype: Remove `isleadbyte()` etc.

They are already declared in ctype.h

Reference: 
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/isleadbyte-isleadbyte-l?view=msvc-170
Signed-off-by: LIU Hao <lh_mo...@126.com>
---
 mingw-w64-headers/crt/wctype.h | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/mingw-w64-headers/crt/wctype.h b/mingw-w64-headers/crt/wctype.h
index 2a1911c54..b20d08ed2 100644
--- a/mingw-w64-headers/crt/wctype.h
+++ b/mingw-w64-headers/crt/wctype.h
@@ -98,9 +98,6 @@ extern "C" {
   _CRTIMP int __cdecl iswgraph(wint_t _C);
   _CRTIMP int __cdecl iswcntrl(wint_t _C);
   _CRTIMP int __cdecl iswascii(wint_t _C);
-#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
-  _CRTIMP int __cdecl isleadbyte(int _C);
-#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
   _CRTIMP wint_t __cdecl towupper(wint_t _C);
   _CRTIMP wint_t __cdecl towlower(wint_t _C);
   _CRTIMP int __cdecl iswctype(wint_t _C,wctype_t _Type);
@@ -118,9 +115,6 @@ extern "C" {
   _CRTIMP int __cdecl _iswprint_l(wint_t _C,_locale_t _Locale);
   _CRTIMP int __cdecl _iswgraph_l(wint_t _C,_locale_t _Locale);
   _CRTIMP int __cdecl _iswcntrl_l(wint_t _C,_locale_t _Locale);
-# ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
-  _CRTIMP int __cdecl _isleadbyte_l(int _C,_locale_t _Locale);
-# endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
   _CRTIMP wint_t __cdecl _towupper_l(wint_t _C,_locale_t _Locale);
   _CRTIMP wint_t __cdecl _towlower_l(wint_t _C,_locale_t _Locale);
   _CRTIMP int __cdecl _iswctype_l(wint_t _C,wctype_t _Type,_locale_t _Locale);
@@ -159,7 +153,6 @@ extern "C" {
 #define iswcntrl(_c) (iswctype(_c,_CONTROL))
 #define iswascii(_c) ((unsigned)(_c) < 0x80)
 #define iswblank(_c) (iswctype(_c,_BLANK) || ((_c)=='\t'))
-#define isleadbyte(c) (__pctype_func()[(unsigned char)(c)] & _LEADBYTE)
 #else
 #ifndef __CRT__NO_INLINE
   __CRT_INLINE int __cdecl iswalpha(wint_t _C) {return (iswctype(_C,_ALPHA)); }
@@ -175,7 +168,6 @@ extern "C" {
   __CRT_INLINE int __cdecl iswcntrl(wint_t _C) {return 
(iswctype(_C,_CONTROL)); }
   __CRT_INLINE int __cdecl iswascii(wint_t _C) {return ((unsigned)(_C) < 
0x80); }
   __CRT_INLINE int __cdecl iswblank(wint_t _C) {return (iswctype(_C,_BLANK) || 
((_C)=='\t')); }
-  __CRT_INLINE int __cdecl isleadbyte(int _C) {return 
(__pctype_func()[(unsigned char)(_C)] & _LEADBYTE); }
 #endif /* !__CRT__NO_INLINE */
 #endif /* __cplusplus */
 #endif
-- 
2.48.1

From e7a9a8ad8bc1b96dc3a577a13bce4170ee506b28 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mo...@126.com>
Date: Mon, 24 Feb 2025 17:38:46 +0800
Subject: [PATCH 8/9] crt/isblank: Use `_CTYPE_INLINE_DEFINED` like iswblank.c

Signed-off-by: LIU Hao <lh_mo...@126.com>
---
 mingw-w64-crt/misc/isblank.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mingw-w64-crt/misc/isblank.c b/mingw-w64-crt/misc/isblank.c
index b49fc6423..221495f4b 100644
--- a/mingw-w64-crt/misc/isblank.c
+++ b/mingw-w64-crt/misc/isblank.c
@@ -1,4 +1,4 @@
-#define _CTYPE_DISABLE_MACROS
+#define _CTYPE_INLINE_DEFINED
 #include <ctype.h>
 
 int __cdecl isblank (int _C)
-- 
2.48.1

From bae41dc28edfe3f8a984482ea227a86ee1332d3c Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mo...@126.com>
Date: Mon, 24 Feb 2025 17:57:41 +0800
Subject: [PATCH 9/9] headers/tchar: Add `_istblank` and `_istblank_l`

Signed-off-by: LIU Hao <lh_mo...@126.com>
---
 mingw-w64-headers/crt/tchar.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mingw-w64-headers/crt/tchar.h b/mingw-w64-headers/crt/tchar.h
index aabf37787..356d8ee52 100644
--- a/mingw-w64-headers/crt/tchar.h
+++ b/mingw-w64-headers/crt/tchar.h
@@ -472,6 +472,8 @@ extern "C" {
 #define _istupper_l _iswupper_l
 #define _istxdigit iswxdigit
 #define _istxdigit_l _iswxdigit_l
+#define _istblank iswblank
+#define _istblank_l _iswblank_l
 
 #define _totupper towupper
 #define _totupper_l _towupper_l
@@ -1000,6 +1002,8 @@ extern "C" {
 #define _istspace_l _ismbcspace_l
 #define _istupper _ismbcupper
 #define _istupper_l _ismbcupper_l
+#define _istblank _ismbcblank
+#define _istblank_l _ismbcblank_l
 
 #define _totupper _mbctoupper
 #define _totupper_l _mbctoupper_l
@@ -1137,6 +1141,8 @@ extern "C" {
 #define _istspace_l _isspace_l
 #define _istupper isupper
 #define _istupper_l _isupper_l
+#define _istblank isblank
+#define _istblank_l _isblank_l
 
 #define _totupper toupper
 #define _totupper_l _toupper_l
-- 
2.48.1

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to