--
Best regards,
LIU Hao

From cd191658f4b0c127a46ed219b9953c06df148003 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mo...@126.com>
Date: Sat, 22 Feb 2025 22:35:48 +0800
Subject: [PATCH 1/2] headers/ctype: Add `_CRTIMP` to imported functions

These functions do not seem to be implemented in our code anywhere, so they
must be always imported from Microsoft DLLs.

The changes can be verified with `git show --color-words'.

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

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index 825947677..922dab67a 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -120,24 +120,24 @@ int __cdecl isblank(int _C);
 #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);
+  _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
-  int __cdecl isleadbyte(int _C);
+  _CRTIMP 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);
+  _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). */
@@ -167,7 +167,7 @@ int __cdecl isblank(int _C);
   _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);
+  _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)
@@ -254,10 +254,10 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
 
 #ifndef        NO_OLDNAMES
 #ifndef _CTYPE_DEFINED
-  int __cdecl isascii(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
-  int __cdecl toascii(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
-  int __cdecl iscsymf(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
-  int __cdecl iscsym(int _C) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
+  _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
-- 
2.48.1

From d6e6b74aec7e0771c95d6ab4f13d45cbec78d30c Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mo...@126.com>
Date: Sat, 22 Feb 2025 22:51:58 +0800
Subject: [PATCH 2/2] headers/{ctype,tchar}: Declare `isblank`-family functions

These functions are exported from MSVCR120+ and UCRT DLLs.

When using MSVCR110-, we have custom implementations of `isblank()` and
`iswblank()`. Previously, these were only declared for C99 or C++. To avoid
complication in <tchar.h>, they are now declared unconditionally.

Signed-off-by: LIU Hao <lh_mo...@126.com>
---
 mingw-w64-headers/crt/ctype.h | 23 ++++++++++++++++-------
 mingw-w64-headers/crt/tchar.h | 12 ++++++++++++
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index 922dab67a..2c8499d4d 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -111,10 +111,12 @@ 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);
-#endif
+#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  /* msvcr120 */
 #endif
 
 #ifndef _WCTYPE_DEFINED
@@ -170,9 +172,12 @@ int __cdecl isblank(int _C);
   _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
+#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 _CTYPE_DISABLE_MACROS
@@ -226,6 +231,7 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
 #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,_SPACE) || ((_c)=='\t'))
 #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))
@@ -239,7 +245,10 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
 # 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 __MSVCRT_VERSION__ >= 0xC00
+#define _iswblank_l(_c,_p) (_iswctype_l(_c,_BLANK,_p) || ((_c)=='\t'))
 #endif
+#endif  /* __cplusplus */
 #endif
 
 #define __iscsymf(_c) (isalpha(_c) || ((_c)=='_'))
diff --git a/mingw-w64-headers/crt/tchar.h b/mingw-w64-headers/crt/tchar.h
index aabf37787..42d6b1ae3 100644
--- a/mingw-w64-headers/crt/tchar.h
+++ b/mingw-w64-headers/crt/tchar.h
@@ -472,6 +472,10 @@ extern "C" {
 #define _istupper_l _iswupper_l
 #define _istxdigit iswxdigit
 #define _istxdigit_l _iswxdigit_l
+#define _istblank iswblank
+#if __MSVCRT_VERSION__ >= 0xC00
+#define _istblank_l _iswblank_l
+#endif  /* msvcr120 */
 
 #define _totupper towupper
 #define _totupper_l _towupper_l
@@ -1000,6 +1004,10 @@ extern "C" {
 #define _istspace_l _ismbcspace_l
 #define _istupper _ismbcupper
 #define _istupper_l _ismbcupper_l
+#define _istblank _ismbcblank
+#if __MSVCRT_VERSION__ >= 0xC00
+#define _istblank_l _ismbcblank_l
+#endif  /* msvcr120 */
 
 #define _totupper _mbctoupper
 #define _totupper_l _mbctoupper_l
@@ -1137,6 +1145,10 @@ extern "C" {
 #define _istspace_l _isspace_l
 #define _istupper isupper
 #define _istupper_l _isupper_l
+#define _istblank isblank
+#if __MSVCRT_VERSION__ >= 0xC00
+#define _istblank_l _isblank_l
+#endif  /* msvcr120 */
 
 #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