> Rationale is in commit message.

I forgot to attach the patch...

- Kirill Makurin

From 1a00e6266699387a49d228c6585639599b3fc105 Mon Sep 17 00:00:00 2001
From: Kirill Makurin <[email protected]>
Date: Mon, 11 May 2026 22:34:35 +0900
Subject: [PATCH] crt: ctype.h: remove macro versions of locale-specific
 functions

Those macros access internal structure of `_locale_t`, layout of which
is CRT-specific. In case of msvcrt.dll, layout may differ from one OS
version of msvcrt.dll to another, making it practically impossible to
have correct declaration of `_locale_t` for all CRTs.

All those macros have external library versions, so simply remove them.

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

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index 86f7f86d7..827f6e41a 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -44,10 +44,6 @@ _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 */
-
 /**
  * Locale-specific versions of Standard C functions.
  *
@@ -71,29 +67,6 @@ _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
 
 /**
-- 
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