This is patch series for ctype.h/wctype.h similar to one for conio.h, except no 
de-duplication was needed.

Few thing I want to point out:

First, apparently _iscsym_l and _iscsymf_l are available only as macros. With 
these changes, they are no longer exposed for C++ compilations. Should we 
provide them as externals even if MSVC does not do this? I'd like to keep 
things consistent and don't go out of the way exposing just these two for C++.

Second, I'm not sure about the last patch. I think using _CRTIMP should do the 
right thing, which is IMO more readable than __MINGW_IMP_SYMBOL.

After we're done with this patch series, I'll start working on issues with 
_BLANK I've mentioned. I can also add _iscsym_l  and _iscsymf_l as externals 
while I'm on it.

Results of CI run for this patch series: 
https://github.com/maiddaisuki/mingw-w64/actions/runs/21092638569

- Kirill Makurin
From 793098823058ab98e016b874a0e2b547b938f93c Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 17:48:48 +0900
Subject: [PATCH 01/19] headers: remove static CRT leftovers from ctype.h and
 mbctype.h

The only symbols that is used by mingw-w64 is __globallocalestatus.
It is defined in mingw-w64-crt/crt/xthdloc.c and referenced in
mingw-w64-crt/crt/crtexe.c.

This symbols in not well-documented by Microsoft,
so remove it from public headers as well.

Declare __globallocalestatus as an external variable in
mingw-w64-crt/crt/crtexe.c to avoid compilation error.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-crt/crt/crtexe.c      |  1 +
 mingw-w64-headers/crt/ctype.h   | 14 --------------
 mingw-w64-headers/crt/mbctype.h |  6 ------
 3 files changed, 1 insertion(+), 20 deletions(-)

diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c
index 8768993b5..037c36caa 100644
--- a/mingw-w64-crt/crt/crtexe.c
+++ b/mingw-w64-crt/crt/crtexe.c
@@ -30,6 +30,7 @@ extern int _fmode;
 #undef _commode
 extern int _commode;
 extern int _dowildcard;
+extern int __globallocalestatus;
 
 static int __cdecl check_managed_app (void);
 
diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index 05986d997..de9f38115 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -16,20 +16,6 @@ extern "C" {
 #define WEOF (wint_t)(0xFFFF)
 #endif
 
-  /* CRT stuff */
-#if 1
-  extern const unsigned char __newclmap[];
-  extern const unsigned char __newcumap[];
-  extern pthreadlocinfo __ptlocinfo;
-  extern pthreadmbcinfo __ptmbcinfo;
-  extern int __globallocalestatus;
-  extern int __locale_changed;
-  extern struct threadlocaleinfostruct __initiallocinfo;
-  extern _locale_tstruct __initiallocalestructinfo;
-  pthreadlocinfo __cdecl __updatetlocinfo(void);
-  pthreadmbcinfo __cdecl __updatetmbcinfo(void);
-#endif
-
 #ifndef _CTYPE_DEFINED
 #define _CTYPE_DEFINED
 
diff --git a/mingw-w64-headers/crt/mbctype.h b/mingw-w64-headers/crt/mbctype.h
index e39d2a102..d1c48f2b3 100644
--- a/mingw-w64-headers/crt/mbctype.h
+++ b/mingw-w64-headers/crt/mbctype.h
@@ -23,12 +23,6 @@ extern "C" {
 #define _mbcasemap (__p__mbcasemap())
 #endif
 
-  extern pthreadmbcinfo __ptmbcinfo;
-  extern int __globallocalestatus;
-  extern int __locale_changed;
-  extern struct threadmbcinfostruct __initialmbcinfo;
-  pthreadmbcinfo __cdecl __updatetmbcinfo(void);
-
 #define _MS 0x01
 #define _MP 0x02
 #define _M1 0x04
-- 
2.51.0.windows.1

From 1eeaa1fc6515667cac0d488a9a9a069ecd01cd56 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 17:51:07 +0900
Subject: [PATCH 02/19] headers: corecrt_wctype.h: remove unnecessary guards

All corecrt_wctype.h symbols are now declared only in corecrt_wctype.h,
which makes such guards unnecessary.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/corecrt_wctype.h | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/mingw-w64-headers/crt/corecrt_wctype.h 
b/mingw-w64-headers/crt/corecrt_wctype.h
index d2a58d81d..6a6250893 100644
--- a/mingw-w64-headers/crt/corecrt_wctype.h
+++ b/mingw-w64-headers/crt/corecrt_wctype.h
@@ -22,8 +22,6 @@ extern "C" {
 #define WEOF (wint_t)(0xFFFF)
 #endif
 
-#ifndef _CRT_CTYPEDATA_DEFINED
-#define _CRT_CTYPEDATA_DEFINED
 #ifndef _CTYPE_DISABLE_MACROS
 
 #ifndef __PCTYPE_FUNC
@@ -35,11 +33,8 @@ 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);
@@ -51,7 +46,6 @@ extern "C" {
 #define _pwctype (__pwctype_func())
 #endif
 #endif
-#endif
 
 #define _UPPER 0x1
 #define _LOWER 0x2
@@ -66,9 +60,6 @@ extern "C" {
 #define _LEADBYTE 0x8000
 #define _ALPHA (0x0100|_UPPER|_LOWER)
 
-#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);
@@ -120,7 +111,6 @@ extern "C" {
 #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 */
-#endif
 
 #ifndef _WCTYPE_INLINE_DEFINED
 #define _WCTYPE_INLINE_DEFINED
-- 
2.51.0.windows.1

From 13039fcc57c2836e43cc39e8d715a85a884ef6b2 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 17:53:18 +0900
Subject: [PATCH 03/19] headers: corecrt_wctype.h: unite code blocks guarded
 with _CTYPE_DISABLE_MACROS

There are two blocks of code in the row which are guarded with
_CTYPE_DISABLE_MACROS. Unite these blocks.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/corecrt_wctype.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/mingw-w64-headers/crt/corecrt_wctype.h 
b/mingw-w64-headers/crt/corecrt_wctype.h
index 6a6250893..8e841da2a 100644
--- a/mingw-w64-headers/crt/corecrt_wctype.h
+++ b/mingw-w64-headers/crt/corecrt_wctype.h
@@ -33,9 +33,6 @@ extern "C" {
 #define _pctype (__pctype_func())
 #endif
 
-#endif
-
-#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))
@@ -45,7 +42,7 @@ extern "C" {
 #ifndef _pwctype
 #define _pwctype (__pwctype_func())
 #endif
-#endif
+#endif /* !_CTYPE_DISABLE_MACROS */
 
 #define _UPPER 0x1
 #define _LOWER 0x2
-- 
2.51.0.windows.1

From 401364fa815e7843698cae4a1cbea9aaea39bd1c Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 17:54:44 +0900
Subject: [PATCH 04/19] headers: corecrt_wctype.h: guard macro versions with
 _CTYPE_DISABLE_MACROS

MSVC headers use _CTYPE_DISABLE_MACROS to guard macro versions
defined in both ctype.h and corecrt_wctype.h.

mingw-w64 headers used _CTYPE_DISABLE_MACROS only in ctype.h;
corecrt_wctype.h used _WCTYPE_INLINE_DEFINED instead.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-crt/misc/_iswblank_l.c       | 2 +-
 mingw-w64-crt/misc/iswblank.c          | 2 +-
 mingw-w64-headers/crt/corecrt_wctype.h | 9 ++-------
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/mingw-w64-crt/misc/_iswblank_l.c b/mingw-w64-crt/misc/_iswblank_l.c
index 3abfdfd9c..d492b3b1c 100644
--- a/mingw-w64-crt/misc/_iswblank_l.c
+++ b/mingw-w64-crt/misc/_iswblank_l.c
@@ -1,4 +1,4 @@
-#define _WCTYPE_INLINE_DEFINED
+#define _CTYPE_DISABLE_MACROS
 #include <wctype.h>
 
 int __cdecl _iswblank_l(wint_t _C, _locale_t _Locale)
diff --git a/mingw-w64-crt/misc/iswblank.c b/mingw-w64-crt/misc/iswblank.c
index 0d05e1c11..dc48c297f 100644
--- a/mingw-w64-crt/misc/iswblank.c
+++ b/mingw-w64-crt/misc/iswblank.c
@@ -1,4 +1,4 @@
-#define _WCTYPE_INLINE_DEFINED
+#define _CTYPE_DISABLE_MACROS
 #include <wctype.h>
 
 int __cdecl iswblank (wint_t _C)
diff --git a/mingw-w64-headers/crt/corecrt_wctype.h 
b/mingw-w64-headers/crt/corecrt_wctype.h
index 8e841da2a..d70228b10 100644
--- a/mingw-w64-headers/crt/corecrt_wctype.h
+++ b/mingw-w64-headers/crt/corecrt_wctype.h
@@ -109,11 +109,7 @@ extern "C" {
   _CRTIMP int __cdecl is_wctype(wint_t _C,wctype_t _Type);
 #endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
 
-#ifndef _WCTYPE_INLINE_DEFINED
-#define _WCTYPE_INLINE_DEFINED
-
-#undef _CRT_WCTYPE_NOINLINE
-#ifndef __cplusplus
+#if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
 #define iswalpha(_c) (iswctype(_c,_ALPHA))
 #define iswupper(_c) (iswctype(_c,_UPPER))
 #define iswlower(_c) (iswctype(_c,_LOWER))
@@ -141,8 +137,7 @@ extern "C" {
 # define _iswcntrl_l(_c,_p) (_iswctype_l(_c,_CONTROL,_p))
 # define _iswblank_l(_c,_p) (((_c) == '\t') || _iswctype_l(_c,_BLANK,_p))
 #endif  /* __MSVCRT_VERSION__ >= 0x800 */
-#endif
-#endif
+#endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
 
 #ifdef __cplusplus
 }
-- 
2.51.0.windows.1

From fb5ab5b879b10ef7bc57aac9079f8dd77552e8f9 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 18:24:05 +0900
Subject: [PATCH 05/19] headers: corecrt_wctype.h: group and reorder
 declarations [1/4]

Group declarations of standard C function together.
Definitions of macro versions follow immediately.

Declarations and macro definitions are sorted in alphabetical order.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/corecrt_wctype.h | 64 +++++++++++++++-----------
 1 file changed, 37 insertions(+), 27 deletions(-)

diff --git a/mingw-w64-headers/crt/corecrt_wctype.h 
b/mingw-w64-headers/crt/corecrt_wctype.h
index d70228b10..62435eec9 100644
--- a/mingw-w64-headers/crt/corecrt_wctype.h
+++ b/mingw-w64-headers/crt/corecrt_wctype.h
@@ -57,27 +57,49 @@ extern "C" {
 #define _LEADBYTE 0x8000
 #define _ALPHA (0x0100|_UPPER|_LOWER)
 
-  _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);
+/**
+ * Standard C functions.
+ */
+
+_CRTIMP int __cdecl iswctype(wint_t _C,wctype_t _Type);
+
+_CRTIMP int __cdecl iswalnum(wint_t _C);
+_CRTIMP int __cdecl iswalpha(wint_t _C);
+_CRTIMP int __cdecl iswblank(wint_t _C);
+_CRTIMP int __cdecl iswcntrl(wint_t _C);
+_CRTIMP int __cdecl iswdigit(wint_t _C);
+_CRTIMP int __cdecl iswgraph(wint_t _C);
+_CRTIMP int __cdecl iswlower(wint_t _C);
+_CRTIMP int __cdecl iswprint(wint_t _C);
+_CRTIMP int __cdecl iswpunct(wint_t _C);
+_CRTIMP int __cdecl iswspace(wint_t _C);
+_CRTIMP int __cdecl iswupper(wint_t _C);
+_CRTIMP int __cdecl iswxdigit(wint_t _C);
+
+_CRTIMP wint_t __cdecl towlower(wint_t _C);
+_CRTIMP wint_t __cdecl towupper(wint_t _C);
+
+#if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
+#define iswalnum(_c)  (iswctype(_c,_ALPHA|_DIGIT))
+#define iswalpha(_c)  (iswctype(_c,_ALPHA))
+#define iswblank(_c)  (((_c) == '\t') || iswctype(_c,_BLANK))
+#define iswcntrl(_c)  (iswctype(_c,_CONTROL))
+#define iswdigit(_c)  (iswctype(_c,_DIGIT))
+#define iswgraph(_c)  (iswctype(_c,_PUNCT|_ALPHA|_DIGIT))
+#define iswlower(_c)  (iswctype(_c,_LOWER))
+#define iswprint(_c)  (iswctype(_c,_BLANK|_PUNCT|_ALPHA|_DIGIT))
+#define iswpunct(_c)  (iswctype(_c,_PUNCT))
+#define iswspace(_c)  (iswctype(_c,_SPACE))
+#define iswupper(_c)  (iswctype(_c,_UPPER))
+#define iswxdigit(_c) (iswctype(_c,_HEX))
+#endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
+
   _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);
   _CRTIMP int __cdecl __iswcsymf(wint_t _C);
   _CRTIMP int __cdecl __iswcsym(wint_t _C);
-  _CRTIMP int __cdecl iswblank(wint_t _C);
 #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). */
@@ -110,19 +132,7 @@ extern "C" {
 #endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
 
 #if !defined(_CTYPE_DISABLE_MACROS) && !defined(__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)
-#define iswblank(_c) (((_c) == '\t') || iswctype(_c,_BLANK))
 #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))
-- 
2.51.0.windows.1

From c409ab99acfe5fb1072c0ba1058c67cedab40986 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 18:28:24 +0900
Subject: [PATCH 06/19] headers: corecrt_wctype.h: group and reorder
 declarations [2/4]

Group declarations of locale-specific versions of standard C
functions together. Definitions of macro versions follow immediately.

Declarations and macro definitions are sorted in alphabetical order.

These locale-specific versions are available since msvcr80.dll;
they are also available in msvcrt.dll since Windows Vista.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/corecrt_wctype.h | 71 +++++++++++++++-----------
 1 file changed, 42 insertions(+), 29 deletions(-)

diff --git a/mingw-w64-headers/crt/corecrt_wctype.h 
b/mingw-w64-headers/crt/corecrt_wctype.h
index 62435eec9..12f1a660a 100644
--- a/mingw-w64-headers/crt/corecrt_wctype.h
+++ b/mingw-w64-headers/crt/corecrt_wctype.h
@@ -94,6 +94,48 @@ _CRTIMP wint_t __cdecl towupper(wint_t _C);
 #define iswxdigit(_c) (iswctype(_c,_HEX))
 #endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */

+/**
+ * Locale-specific versions of Standard C functions.
+ *
+ * They are available since msvcr80.dll.
+ */
+
+/* These are also available in msvcrt.dll since Windows Vista. */
+#if __MSVCRT_VERSION__ >= 0x0800 || (__MSVCRT_VERSION__ == 0x0600 && 
_WIN32_WINNT >= 0x0600)
+_CRTIMP int __cdecl _iswctype_l(wint_t _C,wctype_t _Type,_locale_t _Locale);
+
+_CRTIMP int __cdecl _iswalnum_l(wint_t _C,_locale_t _Locale);
+_CRTIMP int __cdecl _iswalpha_l(wint_t _C,_locale_t _Locale);
+_CRTIMP int __cdecl _iswblank_l(wint_t _C,_locale_t _Locale);
+_CRTIMP int __cdecl _iswcntrl_l(wint_t _C,_locale_t _Locale);
+_CRTIMP int __cdecl _iswdigit_l(wint_t _C,_locale_t _Locale);
+_CRTIMP int __cdecl _iswgraph_l(wint_t _C,_locale_t _Locale);
+_CRTIMP int __cdecl _iswlower_l(wint_t _C,_locale_t _Locale);
+_CRTIMP int __cdecl _iswprint_l(wint_t _C,_locale_t _Locale);
+_CRTIMP int __cdecl _iswpunct_l(wint_t _C,_locale_t _Locale);
+_CRTIMP int __cdecl _iswspace_l(wint_t _C,_locale_t _Locale);
+_CRTIMP int __cdecl _iswupper_l(wint_t _C,_locale_t _Locale);
+_CRTIMP int __cdecl _iswxdigit_l(wint_t _C,_locale_t _Locale);
+
+_CRTIMP wint_t __cdecl _towlower_l(wint_t _C,_locale_t _Locale);
+_CRTIMP wint_t __cdecl _towupper_l(wint_t _C,_locale_t _Locale);
+
+#if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
+#define _iswalnum_l(_c,_p)  (_iswctype_l(_c,_ALPHA|_DIGIT,_p))
+#define _iswalpha_l(_c,_p)  (_iswctype_l(_c,_ALPHA,_p))
+#define _iswblank_l(_c,_p)  (((_c) == '\t') || _iswctype_l(_c,_BLANK,_p))
+#define _iswcntrl_l(_c,_p)  (_iswctype_l(_c,_CONTROL,_p))
+#define _iswdigit_l(_c,_p)  (_iswctype_l(_c,_DIGIT,_p))
+#define _iswgraph_l(_c,_p)  (_iswctype_l(_c,_PUNCT|_ALPHA|_DIGIT,_p))
+#define _iswlower_l(_c,_p)  (_iswctype_l(_c,_LOWER,_p))
+#define _iswprint_l(_c,_p)  (_iswctype_l(_c,_BLANK|_PUNCT|_ALPHA|_DIGIT,_p))
+#define _iswpunct_l(_c,_p)  (_iswctype_l(_c,_PUNCT,_p))
+#define _iswspace_l(_c,_p)  (_iswctype_l(_c,_SPACE,_p))
+#define _iswupper_l(_c,_p)  (_iswctype_l(_c,_UPPER,_p))
+#define _iswxdigit_l(_c,_p) (_iswctype_l(_c,_HEX,_p))
+#endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
+#endif
+
   _CRTIMP int __cdecl iswascii(wint_t _C);
 #ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
   _CRTIMP int __cdecl isleadbyte(int _C);
@@ -103,24 +145,9 @@ _CRTIMP wint_t __cdecl towupper(wint_t _C);
 #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 _iswblank_l(wint_t _C,_locale_t _Locale);
 #endif
 #if __MSVCRT_VERSION__ >= 0x800
   /* These are only available since msvcr80.dll, never in msvcrt.dll. */
@@ -133,20 +160,6 @@ _CRTIMP wint_t __cdecl towupper(wint_t _C);

 #if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
 #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))
-# define _iswblank_l(_c,_p) (((_c) == '\t') || _iswctype_l(_c,_BLANK,_p))
-#endif  /* __MSVCRT_VERSION__ >= 0x800 */
 #endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */

 #ifdef __cplusplus
--
2.51.0.windows.1
From 6448497a31aefda87ab9d7f16e55c56ed944a635 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 18:30:16 +0900
Subject: [PATCH 07/19] headers: corecrt_wctype.h: group and reorder
 declarations [3/4]

Group declarations of Microsoft-specific functions together.
Definitions of macro versions follow immediately.

Declarations and macro definitions are sorted in alphabetical order.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/corecrt_wctype.h | 27 +++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/mingw-w64-headers/crt/corecrt_wctype.h 
b/mingw-w64-headers/crt/corecrt_wctype.h
index 12f1a660a..6ddf13a4b 100644
--- a/mingw-w64-headers/crt/corecrt_wctype.h
+++ b/mingw-w64-headers/crt/corecrt_wctype.h
@@ -136,12 +136,24 @@ _CRTIMP wint_t __cdecl _towupper_l(wint_t _C,_locale_t 
_Locale);
 #endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
 #endif
 
-  _CRTIMP int __cdecl iswascii(wint_t _C);
+/**
+ * Microsoft-specific functions.
+ */
+
+_CRTIMP int __cdecl __iswcsym(wint_t _C);
+_CRTIMP int __cdecl __iswcsymf(wint_t _C);
+_CRTIMP int __cdecl iswascii(wint_t _C);
+
+/* These are only available for Desktop applications. */
 #ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
-  _CRTIMP int __cdecl isleadbyte(int _C);
+_CRTIMP int __cdecl is_wctype(wint_t _C,wctype_t _Type);
+_CRTIMP int __cdecl isleadbyte(int _C);
 #endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
-  _CRTIMP int __cdecl __iswcsymf(wint_t _C);
-  _CRTIMP int __cdecl __iswcsym(wint_t _C);
+
+#if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
+#define iswascii(_c) ((unsigned)(_c) < 0x80)
+#endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
+
 #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). */
@@ -154,13 +166,6 @@ _CRTIMP wint_t __cdecl _towupper_l(wint_t _C,_locale_t 
_Locale);
   _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(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
-#define iswascii(_c) ((unsigned)(_c) < 0x80)
-#endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
 
 #ifdef __cplusplus
 }
-- 
2.51.0.windows.1

From a9bb5a4a48d5a1dbe0befccd0ee821e5e0fef4e8 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 18:32:56 +0900
Subject: [PATCH 08/19] headers: corecrt_wctype.h: group and reorder
 declarations [4/4]

Group declarations of locale-specific versions of
Microsoft-specific functions together.

Declarations are sorted in alphabetical order.

These locale-specific versions are available since msvcr80.dll;
some of them are also available in msvcrt.dll since Windows Vista.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/corecrt_wctype.h | 27 ++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/mingw-w64-headers/crt/corecrt_wctype.h 
b/mingw-w64-headers/crt/corecrt_wctype.h
index 6ddf13a4b..494a62d34 100644
--- a/mingw-w64-headers/crt/corecrt_wctype.h
+++ b/mingw-w64-headers/crt/corecrt_wctype.h
@@ -154,17 +154,24 @@ _CRTIMP int __cdecl isleadbyte(int _C);
 #define iswascii(_c) ((unsigned)(_c) < 0x80)
 #endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
 
-#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). */
-# ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
-  _CRTIMP int __cdecl _isleadbyte_l(int _C,_locale_t _Locale);
-# endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
+/**
+ * Locale-specific versions of Microsoft functions.
+ *
+ * They are available since msvcr80.dll.
+ */
+
+/* These are only available since msvcr80.dll, never in msvcrt.dll. */
+#if __MSVCRT_VERSION__ >= 0x0800
+_CRTIMP int __cdecl _iswcsym_l(wint_t _C,_locale_t _Locale);
+_CRTIMP int __cdecl _iswcsymf_l(wint_t _C,_locale_t _Locale);
 #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);
+
+/* These are also available in msvcrt.dll since Windows Vista. */
+#if __MSVCRT_VERSION__ >= 0x0800 || (__MSVCRT_VERSION__ == 0x0600 && 
_WIN32_WINNT >= 0x0600)
+/* These are only available for Desktop applications. */
+#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
+_CRTIMP int __cdecl _isleadbyte_l(int _C,_locale_t _Locale);
+#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
 #endif
 
 #ifdef __cplusplus
-- 
2.51.0.windows.1

From 697a1e6914e73f669cbf29f2b7992b77d8596714 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 18:34:06 +0900
Subject: [PATCH 09/19] headers: ctype.h: remove definition of WEOF

WEOF is already defined in included corecrt_wctype.h.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/ctype.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index de9f38115..b98933613 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -12,10 +12,6 @@
 extern "C" {
 #endif
 
-#ifndef WEOF
-#define WEOF (wint_t)(0xFFFF)
-#endif
-
 #ifndef _CTYPE_DEFINED
 #define _CTYPE_DEFINED
 
-- 
2.51.0.windows.1

From 1ce37d6b4d9faacf443da55d41e7a5d894c4c699 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 18:37:52 +0900
Subject: [PATCH 10/19] headers: ctype.h: remove unnecessary guards

All ctype.h symbols are now declared only in ctype.h,
which makes such guards unnecessary.

Declarations of isascii, toascii, _tolower and _toupper were guarded with
_CTYPE_DEFINED, which makes no sense: _CTYPE_DEFINED is always defined when
ctype.h is included.

Instead, guard them with _CTYPE_DISABLE_MACROS: this way they are defined
as macros only when _CTYPE_DISABLE_MACROS is undefined, which is default.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/ctype.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index b98933613..ffbf1592c 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -12,9 +12,6 @@
 extern "C" {
 #endif
 
-#ifndef _CTYPE_DEFINED
-#define _CTYPE_DEFINED
-
   _CRTIMP int __cdecl isalpha(int _C);
   _CRTIMP int __cdecl isupper(int _C);
   _CRTIMP int __cdecl islower(int _C);
@@ -51,7 +48,6 @@ extern "C" {
   _CRTIMP int __cdecl __toascii(int _C);
   _CRTIMP int __cdecl __iscsymf(int _C);
   _CRTIMP int __cdecl __iscsym(int _C);
-#endif
 
 #ifndef _CTYPE_DISABLE_MACROS
 
@@ -99,7 +95,7 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
 #endif
 
 #ifndef        NO_OLDNAMES
-#ifndef _CTYPE_DEFINED
+#ifdef _CTYPE_DISABLE_MACROS
   _CRTIMP int __cdecl isascii(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
   _CRTIMP int __cdecl toascii(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
   _CRTIMP int __cdecl iscsymf(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
-- 
2.51.0.windows.1

From d3f5afb969f0064b506a0b18eab01c8fad7a183e Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 18:38:47 +0900
Subject: [PATCH 11/19] headers: ctype.h: move definition of MB_CUR_MAX to the
 top

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/ctype.h | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index ffbf1592c..1446a60e4 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -12,6 +12,18 @@
 extern "C" {
 #endif
 
+#ifndef _CTYPE_DISABLE_MACROS
+
+#ifndef MB_CUR_MAX
+#define MB_CUR_MAX ___mb_cur_max_func()
+#ifndef __mb_cur_max
+#define __mb_cur_max   (___mb_cur_max_func())
+#endif
+_CRTIMP int __cdecl ___mb_cur_max_func(void);
+#endif
+
+#endif /* !_CTYPE_DISABLE_MACROS */
+
   _CRTIMP int __cdecl isalpha(int _C);
   _CRTIMP int __cdecl isupper(int _C);
   _CRTIMP int __cdecl islower(int _C);
@@ -50,15 +62,6 @@ extern "C" {
   _CRTIMP int __cdecl __iscsym(int _C);
 
 #ifndef _CTYPE_DISABLE_MACROS
-
-#ifndef MB_CUR_MAX
-#define MB_CUR_MAX ___mb_cur_max_func()
-#ifndef __mb_cur_max
-#define __mb_cur_max   (___mb_cur_max_func())
-#endif
-_CRTIMP int __cdecl ___mb_cur_max_func(void);
-#endif
-
 #define __chvalidchk(a,b) (__PCTYPE_FUNC[(unsigned char)(a)] & (b))
 #ifdef _UCRT
 #define _chvalidchk_l(_Char,_Flag,_Locale) (!_Locale ? 
__chvalidchk(_Char,_Flag) : 
((_locale_t)_Locale)->locinfo->_locale_pctype[(unsigned char)(_Char)] & (_Flag))
-- 
2.51.0.windows.1

From b616e277778e4da4b7edc548f66cfa02e537f900 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 18:44:44 +0900
Subject: [PATCH 12/19] headers: ctype.h: group and reorder declarations [1/5]

Group declarations of standard C functions together.
Declarations are sorted in alphabetical order.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/ctype.h | 39 +++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index 1446a60e4..8880bc6a8 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -24,24 +24,34 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
 
 #endif /* !_CTYPE_DISABLE_MACROS */
 
-  _CRTIMP int __cdecl isalpha(int _C);
-  _CRTIMP int __cdecl isupper(int _C);
-  _CRTIMP int __cdecl islower(int _C);
-  _CRTIMP int __cdecl isdigit(int _C);
-  _CRTIMP int __cdecl isxdigit(int _C);
-  _CRTIMP int __cdecl isspace(int _C);
-  _CRTIMP int __cdecl ispunct(int _C);
-  _CRTIMP int __cdecl isalnum(int _C);
-  _CRTIMP int __cdecl isprint(int _C);
-  _CRTIMP int __cdecl isgraph(int _C);
-  _CRTIMP int __cdecl iscntrl(int _C);
-  _CRTIMP int __cdecl toupper(int _C);
+/**
+ * Standard C functions.
+ */
+
+_CRTIMP int __cdecl isalnum(int _C);
+_CRTIMP int __cdecl isalpha(int _C);
+_CRTIMP int __cdecl isblank(int _C);
+_CRTIMP int __cdecl iscntrl(int _C);
+_CRTIMP int __cdecl isdigit(int _C);
+_CRTIMP int __cdecl isgraph(int _C);
+_CRTIMP int __cdecl islower(int _C);
+_CRTIMP int __cdecl isprint(int _C);
+_CRTIMP int __cdecl ispunct(int _C);
+_CRTIMP int __cdecl isspace(int _C);
+_CRTIMP int __cdecl isupper(int _C);
+_CRTIMP int __cdecl isxdigit(int _C);
+
+_CRTIMP int __cdecl tolower(int _C);
+_CRTIMP int __cdecl toupper(int _C);
+
+#if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
+#define __chvalidchk(a,b) (__PCTYPE_FUNC[(unsigned char)(a)] & (b))
+#endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
+
   _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 _isctype(int _C,int _Type);
-  _CRTIMP int __cdecl isblank(int _C);
   _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);
@@ -62,7 +72,6 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
   _CRTIMP int __cdecl __iscsym(int _C);
 
 #ifndef _CTYPE_DISABLE_MACROS
-#define __chvalidchk(a,b) (__PCTYPE_FUNC[(unsigned char)(a)] & (b))
 #ifdef _UCRT
 #define _chvalidchk_l(_Char,_Flag,_Locale) (!_Locale ? 
__chvalidchk(_Char,_Flag) : 
((_locale_t)_Locale)->locinfo->_locale_pctype[(unsigned char)(_Char)] & (_Flag))
 #define _ischartype_l(_Char,_Flag,_Locale) (((_Locale)!=NULL && 
(((_locale_t)(_Locale))->locinfo->_locale_mb_cur_max) > 1) ? 
_isctype_l(_Char,(_Flag),_Locale) : _chvalidchk_l(_Char,_Flag,_Locale))
-- 
2.51.0.windows.1

From 45c48f6e96a5e57249a7e6afc0d2a8a5d3f03e79 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 18:46:52 +0900
Subject: [PATCH 13/19] headers: ctype.h: group and reorder declarations [2/5]

Group declarations of locale-specific versions of standard C
functions together. Definitions of macro versions follow immediately.

Declarations and macro definitions are sorted in alphabetical order.

These locale-specific version are available since msvcr80.dll;
they are also available in msvcrt.dll since Windows Vista.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/ctype.h | 81 +++++++++++++++++++++--------------
 1 file changed, 48 insertions(+), 33 deletions(-)

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index 8880bc6a8..45b0dc520 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -48,49 +48,64 @@ _CRTIMP int __cdecl toupper(int _C);
 #define __chvalidchk(a,b) (__PCTYPE_FUNC[(unsigned char)(a)] & (b))
 #endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
 
+/**
+ * Locale-specific versions of Standard C functions.
+ *
+ * They are available since msvcr80.dll.
+ */
+
+/* These are also available in msvcrt.dll since Windows Vista. */
+#if __MSVCRT_VERSION__ >= 0x0800 || (__MSVCRT_VERSION__ == 0x0600 && 
_WIN32_WINNT >= 0x0600)
+_CRTIMP int __cdecl _isalnum_l(int _C,_locale_t _Locale);
+_CRTIMP int __cdecl _isalpha_l(int _C,_locale_t _Locale);
+_CRTIMP int __cdecl _isblank_l(int _C,_locale_t _Locale);
+_CRTIMP int __cdecl _iscntrl_l(int _C,_locale_t _Locale);
+_CRTIMP int __cdecl _isdigit_l(int _C,_locale_t _Locale);
+_CRTIMP int __cdecl _isgraph_l(int _C,_locale_t _Locale);
+_CRTIMP int __cdecl _islower_l(int _C,_locale_t _Locale);
+_CRTIMP int __cdecl _isprint_l(int _C,_locale_t _Locale);
+_CRTIMP int __cdecl _ispunct_l(int _C,_locale_t _Locale);
+_CRTIMP int __cdecl _isspace_l(int _C,_locale_t _Locale);
+_CRTIMP int __cdecl _isupper_l(int _C,_locale_t _Locale);
+_CRTIMP int __cdecl _isxdigit_l(int _C,_locale_t _Locale);
+
+_CRTIMP int __cdecl _tolower_l(int _C,_locale_t _Locale);
+_CRTIMP int __cdecl _toupper_l(int _C,_locale_t _Locale);
+
+#if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
+#ifdef _UCRT
+#define _chvalidchk_l(_Char,_Flag,_Locale) (!_Locale ? 
__chvalidchk(_Char,_Flag) : 
((_locale_t)_Locale)->locinfo->_locale_pctype[(unsigned char)(_Char)] & (_Flag))
+#define _ischartype_l(_Char,_Flag,_Locale) (((_Locale)!=NULL && 
(((_locale_t)(_Locale))->locinfo->_locale_mb_cur_max) > 1) ? 
_isctype_l(_Char,(_Flag),_Locale) : _chvalidchk_l(_Char,_Flag,_Locale))
+#else
+#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 _isalnum_l(_Char,_Locale)  _ischartype_l(_Char,_ALPHA|_DIGIT,_Locale)
+#define _isalpha_l(_Char,_Locale)  _ischartype_l(_Char,_ALPHA,_Locale)
+#define _isblank_l(_Char,_Locale)  (((_Char) == '\t') || 
_ischartype_l(_Char,_BLANK,_Locale))
+#define _iscntrl_l(_Char,_Locale)  _ischartype_l(_Char,_CONTROL,_Locale)
+#define _isdigit_l(_Char,_Locale)  _ischartype_l(_Char,_DIGIT,_Locale)
+#define _isgraph_l(_Char,_Locale)  
_ischartype_l(_Char,_PUNCT|_ALPHA|_DIGIT,_Locale)
+#define _islower_l(_Char,_Locale)  _ischartype_l(_Char,_LOWER,_Locale)
+#define _isprint_l(_Char,_Locale)  
_ischartype_l(_Char,_BLANK|_PUNCT|_ALPHA|_DIGIT,_Locale)
+#define _ispunct_l(_Char,_Locale)  _ischartype_l(_Char,_PUNCT,_Locale)
+#define _isspace_l(_Char,_Locale)  _ischartype_l(_Char,_SPACE,_Locale)
+#define _isupper_l(_Char,_Locale)  _ischartype_l(_Char,_UPPER,_Locale)
+#define _isxdigit_l(_Char,_Locale) _ischartype_l(_Char,_HEX,_Locale)
+#endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
+#endif
+
   _CRTIMP int __cdecl _toupper(int _C);
   _CRTIMP int __cdecl _tolower(int _C);
-  _CRTIMP int __cdecl _tolower_l(int _C,_locale_t _Locale);
   _CRTIMP int __cdecl _isctype(int _C,int _Type);
-  _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);
-  _CRTIMP int __cdecl _toupper_l(int _C,_locale_t _Locale);
   _CRTIMP int __cdecl _isctype_l(int _C,int _Type,_locale_t _Locale);
-  _CRTIMP int __cdecl _isblank_l(int _C,_locale_t _Locale);
   _CRTIMP int __cdecl __isascii(int _C);
   _CRTIMP int __cdecl __toascii(int _C);
   _CRTIMP int __cdecl __iscsymf(int _C);
   _CRTIMP int __cdecl __iscsym(int _C);
 
 #ifndef _CTYPE_DISABLE_MACROS
-#ifdef _UCRT
-#define _chvalidchk_l(_Char,_Flag,_Locale) (!_Locale ? 
__chvalidchk(_Char,_Flag) : 
((_locale_t)_Locale)->locinfo->_locale_pctype[(unsigned char)(_Char)] & (_Flag))
-#define _ischartype_l(_Char,_Flag,_Locale) (((_Locale)!=NULL && 
(((_locale_t)(_Locale))->locinfo->_locale_mb_cur_max) > 1) ? 
_isctype_l(_Char,(_Flag),_Locale) : _chvalidchk_l(_Char,_Flag,_Locale))
-#else
-#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 _isblank_l(_Char,_Locale) (((_Char) == '\t') || 
_ischartype_l(_Char,_BLANK,_Locale))
 #define _tolower(_Char) ((_Char)-'A'+'a')
 #define _toupper(_Char) ((_Char)-'a'+'A')
 #define __isascii(_Char) ((unsigned)(_Char) < 0x80)
-- 
2.51.0.windows.1

From 993ef197ad4af9110eff736838fca7e71ee394d2 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 18:51:42 +0900
Subject: [PATCH 14/19] headers: ctype.h: group and reorder declarations [3/5]

Group declarations of POSIX functions together.
Definitions of macro versions follow immediately.

Declarations and macro definitions guarded by NO_OLDNAMES
are also moved closer to original declarations.

Declarations and macro definitions are sorted in alphabetical order.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/ctype.h | 39 +++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index 45b0dc520..b07456dd4 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -96,21 +96,38 @@ _CRTIMP int __cdecl _toupper_l(int _C,_locale_t _Locale);
 #endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
 #endif
 
-  _CRTIMP int __cdecl _toupper(int _C);
-  _CRTIMP int __cdecl _tolower(int _C);
+/**
+ * POSIX functions.
+ */
+
+_CRTIMP int __cdecl __isascii(int _C);
+_CRTIMP int __cdecl __toascii(int _C);
+_CRTIMP int __cdecl _tolower(int _C);
+_CRTIMP int __cdecl _toupper(int _C);
+
+#if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
+#define __isascii(_Char) ((unsigned)(_Char) < 0x80)
+#define __toascii(_Char) ((_Char) & 0x7f)
+#define _tolower(_Char)  ((_Char)-'A'+'a')
+#define _toupper(_Char)  ((_Char)-'a'+'A')
+#endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
+
+#ifndef        NO_OLDNAMES
+#if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
+#define isascii __isascii
+#define toascii __toascii
+#else
+_CRTIMP int __cdecl isascii(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
+_CRTIMP int __cdecl toascii(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
+#endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
+#endif /* !NO_OLDNAMES */
+
   _CRTIMP int __cdecl _isctype(int _C,int _Type);
   _CRTIMP int __cdecl _isctype_l(int _C,int _Type,_locale_t _Locale);
-  _CRTIMP int __cdecl __isascii(int _C);
-  _CRTIMP int __cdecl __toascii(int _C);
   _CRTIMP int __cdecl __iscsymf(int _C);
   _CRTIMP int __cdecl __iscsym(int _C);
 
 #ifndef _CTYPE_DISABLE_MACROS
-#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 __iswcsymf(_c) (iswalpha(_c) || ((_c)=='_'))
@@ -123,13 +140,9 @@ _CRTIMP int __cdecl _toupper_l(int _C,_locale_t _Locale);
 
 #ifndef        NO_OLDNAMES
 #ifdef _CTYPE_DISABLE_MACROS
-  _CRTIMP int __cdecl isascii(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
-  _CRTIMP int __cdecl toascii(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
   _CRTIMP int __cdecl iscsymf(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
   _CRTIMP int __cdecl iscsym(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
 #else
-#define isascii __isascii
-#define toascii __toascii
 #define iscsymf __iscsymf
 #define iscsym __iscsym
 #endif
-- 
2.51.0.windows.1

From 1defe3bda82d852ad60ba93396667fb69d814819 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 18:53:41 +0900
Subject: [PATCH 15/19] headers: ctype.h: group and reorder declarations [4/5]

Group declarations of Microsoft-specific functions together.
Definitions of macro versions follow immediately.

Declarations and macro definitions guarded by NO_OLDNAMES
are also moved closer to original declarations.

Declarations and macro definitions are sorted in alphabetical order.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/ctype.h | 43 +++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 17 deletions(-)

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index b07456dd4..3c0aed172 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -122,32 +122,41 @@ _CRTIMP int __cdecl toascii(int _C) 
__MINGW_ATTRIB_DEPRECATED_MSVC2005;
 #endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
 #endif /* !NO_OLDNAMES */
 
-  _CRTIMP int __cdecl _isctype(int _C,int _Type);
+/**
+ * Microsoft-specific functions.
+ */
+
+_CRTIMP int __cdecl _isctype(int _C,int _Type);
+
+_CRTIMP int __cdecl __iscsym(int _C);
+_CRTIMP int __cdecl __iscsymf(int _C);
+
+#if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
+#define __iscsym(_c)   (isalnum(_c) || ((_c)=='_'))
+#define __iscsymf(_c)  (isalpha(_c) || ((_c)=='_'))
+#define __iswcsym(_c)  (iswalnum(_c) || ((_c)=='_'))
+#define __iswcsymf(_c) (iswalpha(_c) || ((_c)=='_'))
+#endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
+
+#ifndef        NO_OLDNAMES
+#if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
+#define iscsym __iscsym
+#define iscsymf __iscsymf
+#else
+_CRTIMP int __cdecl iscsym(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
+_CRTIMP int __cdecl iscsymf(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
+#endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
+#endif /* !NO_OLDNAMES */
+
   _CRTIMP int __cdecl _isctype_l(int _C,int _Type,_locale_t _Locale);
-  _CRTIMP int __cdecl __iscsymf(int _C);
-  _CRTIMP int __cdecl __iscsym(int _C);
 
 #ifndef _CTYPE_DISABLE_MACROS
-#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
 
-#ifndef        NO_OLDNAMES
-#ifdef _CTYPE_DISABLE_MACROS
-  _CRTIMP int __cdecl iscsymf(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
-  _CRTIMP int __cdecl iscsym(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
-#else
-#define iscsymf __iscsymf
-#define iscsym __iscsym
-#endif
-#endif
-
 #ifdef __cplusplus
 }
 #endif
-- 
2.51.0.windows.1

From 8a5d79bb188207ac1d9440c3c0b684d24d8e5535 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 18:55:21 +0900
Subject: [PATCH 16/19] headers: ctype.h: group and reorder declarations [5/5]

Group declarations of locale-specific versions of Microsoft-specific
functions together. Definitions of macro versions follow immediately.

Declarations and macro definitions are sorted in alphabetical order.

These locale-specific versions are available since msvcr80.dll;
some of them are also available in msvcrt.dll since Windows Vista.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/ctype.h | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index 3c0aed172..53a0e3b72 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -148,13 +148,22 @@ _CRTIMP int __cdecl iscsymf(int _C) 
__MINGW_ATTRIB_DEPRECATED_MSVC2005;
 #endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
 #endif /* !NO_OLDNAMES */
 
-  _CRTIMP int __cdecl _isctype_l(int _C,int _Type,_locale_t _Locale);
+/**
+ * Locale-specific versions of Microsoft functions.
+ *
+ * They are available since msvcr80.dll.
+ */
 
-#ifndef _CTYPE_DISABLE_MACROS
-#define _iscsymf_l(_c,_p) (_isalpha_l(_c,_p) || ((_c)=='_'))
-#define _iscsym_l(_c,_p) (_isalnum_l(_c,_p) || ((_c)=='_'))
+/* These are also available in msvcrt.dll since Windows Vista. */
+#if __MSVCRT_VERSION__ >= 0x0800 || (__MSVCRT_VERSION__ == 0x0600 && 
_WIN32_WINNT >= 0x0600)
+_CRTIMP int __cdecl _isctype_l(int _C,int _Type,_locale_t _Locale);
+
+#if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
+#define _iscsym_l(_c,_p)   (_isalnum_l(_c,_p) || ((_c)=='_'))
+#define _iscsymf_l(_c,_p)  (_isalpha_l(_c,_p) || ((_c)=='_'))
+#define _iswcsym_l(_c,_p)  (_iswalnum_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 /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
 #endif
 
 #ifdef __cplusplus
-- 
2.51.0.windows.1

From d76b3e988eeb42af9f8e658f0775031af3c05b2f Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 18:56:56 +0900
Subject: [PATCH 17/19] headers: corecrt_wctype.h: move declarations of
 _iswcsym[f][_l] to ctype.h

Microsoft documentation[1] says that they are declaraed only in ctype.h.

[1] 
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/iscsym-functions

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/corecrt_wctype.h |  8 --------
 mingw-w64-headers/crt/ctype.h          | 15 +++++++++++++--
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/mingw-w64-headers/crt/corecrt_wctype.h 
b/mingw-w64-headers/crt/corecrt_wctype.h
index 494a62d34..e31fa3b22 100644
--- a/mingw-w64-headers/crt/corecrt_wctype.h
+++ b/mingw-w64-headers/crt/corecrt_wctype.h
@@ -140,8 +140,6 @@ _CRTIMP wint_t __cdecl _towupper_l(wint_t _C,_locale_t 
_Locale);
  * Microsoft-specific functions.
  */
 
-_CRTIMP int __cdecl __iswcsym(wint_t _C);
-_CRTIMP int __cdecl __iswcsymf(wint_t _C);
 _CRTIMP int __cdecl iswascii(wint_t _C);
 
 /* These are only available for Desktop applications. */
@@ -160,12 +158,6 @@ _CRTIMP int __cdecl isleadbyte(int _C);
  * They are available since msvcr80.dll.
  */
 
-/* These are only available since msvcr80.dll, never in msvcrt.dll. */
-#if __MSVCRT_VERSION__ >= 0x0800
-_CRTIMP int __cdecl _iswcsym_l(wint_t _C,_locale_t _Locale);
-_CRTIMP int __cdecl _iswcsymf_l(wint_t _C,_locale_t _Locale);
-#endif
-
 /* These are also available in msvcrt.dll since Windows Vista. */
 #if __MSVCRT_VERSION__ >= 0x0800 || (__MSVCRT_VERSION__ == 0x0600 && 
_WIN32_WINNT >= 0x0600)
 /* These are only available for Desktop applications. */
diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index 53a0e3b72..206eb8b69 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -130,6 +130,8 @@ _CRTIMP int __cdecl _isctype(int _C,int _Type);
 
 _CRTIMP int __cdecl __iscsym(int _C);
 _CRTIMP int __cdecl __iscsymf(int _C);
+_CRTIMP int __cdecl __iswcsym(wint_t _C);
+_CRTIMP int __cdecl __iswcsymf(wint_t _C);
 
 #if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
 #define __iscsym(_c)   (isalnum(_c) || ((_c)=='_'))
@@ -154,6 +156,17 @@ _CRTIMP int __cdecl iscsymf(int _C) 
__MINGW_ATTRIB_DEPRECATED_MSVC2005;
  * They are available since msvcr80.dll.
  */
 
+/* These are only available since msvcr80.dll, never in msvcrt.dll. */
+#if __MSVCRT_VERSION__ >= 0x0800
+_CRTIMP int __cdecl _iswcsym_l(wint_t _C,_locale_t _Locale);
+_CRTIMP int __cdecl _iswcsymf_l(wint_t _C,_locale_t _Locale);
+
+#if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
+#define _iswcsym_l(_c,_p)  (_iswalnum_l(_c,_p) || ((_c)=='_'))
+#define _iswcsymf_l(_c,_p) (_iswalpha_l(_c,_p) || ((_c)=='_'))
+#endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
+#endif
+
 /* These are also available in msvcrt.dll since Windows Vista. */
 #if __MSVCRT_VERSION__ >= 0x0800 || (__MSVCRT_VERSION__ == 0x0600 && 
_WIN32_WINNT >= 0x0600)
 _CRTIMP int __cdecl _isctype_l(int _C,int _Type,_locale_t _Locale);
@@ -161,8 +174,6 @@ _CRTIMP int __cdecl _isctype_l(int _C,int _Type,_locale_t 
_Locale);
 #if !defined(_CTYPE_DISABLE_MACROS) && !defined(__cplusplus)
 #define _iscsym_l(_c,_p)   (_isalnum_l(_c,_p) || ((_c)=='_'))
 #define _iscsymf_l(_c,_p)  (_isalpha_l(_c,_p) || ((_c)=='_'))
-#define _iswcsym_l(_c,_p)  (_iswalnum_l(_c,_p) || ((_c)=='_'))
-#define _iswcsymf_l(_c,_p) (_iswalpha_l(_c,_p) || ((_c)=='_'))
 #endif /* !_CTYPE_DISABLE_MACROS && !__cplusplus */
 #endif
 
-- 
2.51.0.windows.1

From 54579aad7de2a87362b5b2c54f59ca76ab39f4c0 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 19:03:58 +0900
Subject: [PATCH 18/19] headers: corecrt_wctype.h: declare __p[w]ctype_func
 functions unconditionally

This ensures that they are declared even if __PCTYPE_FUNC, _pctype
or _pwctype macro is defined prior to including corecrt_wctype.h.

Declaration of __pctype_func is missing __cdecl; fix it.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/corecrt_wctype.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-headers/crt/corecrt_wctype.h 
b/mingw-w64-headers/crt/corecrt_wctype.h
index e31fa3b22..77c242339 100644
--- a/mingw-w64-headers/crt/corecrt_wctype.h
+++ b/mingw-w64-headers/crt/corecrt_wctype.h
@@ -23,10 +23,11 @@ extern "C" {
 #endif

 #ifndef _CTYPE_DISABLE_MACROS
+_CRTIMP const unsigned short* __cdecl __pctype_func(void);
+_CRTIMP const wctype_t * __cdecl __pwctype_func(void);

 #ifndef __PCTYPE_FUNC
 #define __PCTYPE_FUNC __pctype_func()
-  _CRTIMP const unsigned short* __pctype_func(void);
 #endif

 #ifndef _pctype
@@ -38,7 +39,6 @@ extern "C" {
 #define _wctype (* __MINGW_IMP_SYMBOL(_wctype))
 #endif

-  _CRTIMP const wctype_t * __cdecl __pwctype_func(void);
 #ifndef _pwctype
 #define _pwctype (__pwctype_func())
 #endif
--
2.51.0.windows.1
From 7b010926280e3143959adc1dbfbfe5f0dfe7b67d Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Sat, 17 Jan 2026 19:09:44 +0900
Subject: [PATCH 19/19] headers: corecrt_wctype.h: declare _wctype using
 _CRTIMP

This variable is available since msvcrt.dll; add a guard.

Signed-off-by: Kirill Makurin <[email protected]>
---
 mingw-w64-headers/crt/corecrt_wctype.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/mingw-w64-headers/crt/corecrt_wctype.h 
b/mingw-w64-headers/crt/corecrt_wctype.h
index 77c242339..5ae4459e6 100644
--- a/mingw-w64-headers/crt/corecrt_wctype.h
+++ b/mingw-w64-headers/crt/corecrt_wctype.h
@@ -34,16 +34,17 @@ _CRTIMP const wctype_t * __cdecl __pwctype_func(void);
 #define _pctype (__pctype_func())
 #endif
 
-#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
-
 #ifndef _pwctype
 #define _pwctype (__pwctype_func())
 #endif
 #endif /* !_CTYPE_DISABLE_MACROS */
 
+#if __MSVCRT_VERSION__ >= 0x0600
+#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
+extern _CRTIMP const unsigned short *_wctype;
+#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
+#endif
+
 #define _UPPER 0x1
 #define _LOWER 0x2
 #define _DIGIT 0x4
-- 
2.51.0.windows.1

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to