_mbcasemap[] global array is available since Microsoft Visual C++ 5.0 SP1
version of msvcrt.dll for all architectures, and then also in new msvcr*
DLL libraries, and also in UCRT.

__p__mbcasemap() function is available in msvcrt.dll only for i386
architecture since Microsoft Visual C++ 5.0 SP1. For new msvcr* DLL
libraries, it is available also for non-i386 architecture.

So provide fallback implementation of __p__mbcasemap() function in non-i386
msvcrt.dll import libraries. And define _mbcasemap in header file via
__p__mbcasemap() function.
---
 mingw-w64-crt/Makefile.am           |  3 +++
 mingw-w64-crt/misc/__p__mbcasemap.c | 16 ++++++++++++++++
 mingw-w64-headers/crt/mbctype.h     |  8 ++------
 3 files changed, 21 insertions(+), 6 deletions(-)
 create mode 100644 mingw-w64-crt/misc/__p__mbcasemap.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 0fc43f8e9ad4..b83490a34d58 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -458,6 +458,7 @@ src_msvcrt64=\
   misc/__p__acmdln.c \
   misc/__p__commode.c \
   misc/__p__fmode.c \
+  misc/__p__mbcasemap.c \
   misc/__p__mbctype.c \
   misc/__p__wcmdln.c \
   misc/_create_locale.c \
@@ -472,6 +473,7 @@ src_msvcrtarm32=\
   misc/__p__acmdln.c \
   misc/__p__commode.c \
   misc/__p__fmode.c \
+  misc/__p__mbcasemap.c \
   misc/__p__mbctype.c \
   misc/__p__wcmdln.c \
   misc/_getpid.c \
@@ -571,6 +573,7 @@ src_msvcrtarm64=\
   misc/__p__acmdln.c \
   misc/__p__commode.c \
   misc/__p__fmode.c \
+  misc/__p__mbcasemap.c \
   misc/__p__mbctype.c \
   misc/__p__wcmdln.c \
   misc/_getpid.c \
diff --git a/mingw-w64-crt/misc/__p__mbcasemap.c 
b/mingw-w64-crt/misc/__p__mbcasemap.c
new file mode 100644
index 000000000000..4a4432af3862
--- /dev/null
+++ b/mingw-w64-crt/misc/__p__mbcasemap.c
@@ -0,0 +1,16 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <_mingw.h>
+
+extern unsigned char** __MINGW_IMP_SYMBOL(_mbcasemap);
+
+unsigned char* __cdecl __p__mbcasemap(void);
+unsigned char* __cdecl __p__mbcasemap(void)
+{
+    return *__MINGW_IMP_SYMBOL(_mbcasemap);
+}
+unsigned char* (__cdecl *__MINGW_IMP_SYMBOL(__p__mbcasemap))(void) = 
__p__mbcasemap;
diff --git a/mingw-w64-headers/crt/mbctype.h b/mingw-w64-headers/crt/mbctype.h
index bc14b82529ea..b85720c97eb0 100644
--- a/mingw-w64-headers/crt/mbctype.h
+++ b/mingw-w64-headers/crt/mbctype.h
@@ -19,12 +19,8 @@ extern "C" {
 #endif
 
 #ifndef _mbcasemap
-#ifdef _MSVCRT_
-  extern unsigned char *_mbcasemap;
-#else
-  extern unsigned char ** __MINGW_IMP_SYMBOL(_mbcasemap);
-#define _mbcasemap (* __MINGW_IMP_SYMBOL(_mbcasemap))
-#endif
+  _CRTIMP unsigned char * __cdecl __p__mbcasemap(void);
+#define _mbcasemap (__p__mbcasemap())
 #endif
 
   extern pthreadmbcinfo __ptmbcinfo;
-- 
2.20.1



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

Reply via email to