Global variable _pwctype is not available in UCRT. Instead UCRT has only __pwctype_func() function which returns value of _pwctype variable.
Function __pwctype_func() is available also in msvcrt since VC70. For previous i386 msvcrt versions there is a __p__pwctype() function which returns pointer to the _pwctype variable. Like for _pctype changes, add fallback versions of __pwctype_func() and __p__pwctype() functions suitable for older CRT versions. And change definition of _pwctype in header file from the global variable to macro which calls __pwctype_func() function. This change allows to use _pwctype with all CRT libraries, including UCRT. Fix also type of _pwctype. In msvc its type is wctype_t and not unsigned short. Note that wctype_t is just typedef for unsigned short, so this should be just a cosmetic change to align with msvc. --- mingw-w64-crt/Makefile.am | 7 +++++++ mingw-w64-crt/lib-common/msvcrt.def.in | 2 +- mingw-w64-crt/misc/__p__pwctype.c | 17 +++++++++++++++++ mingw-w64-crt/misc/__pwctype_func.c | 17 +++++++++++++++++ mingw-w64-headers/crt/ctype.h | 13 +++---------- mingw-w64-headers/crt/wchar.h | 14 ++------------ mingw-w64-headers/crt/wctype.h | 9 ++------- 7 files changed, 49 insertions(+), 30 deletions(-) create mode 100644 mingw-w64-crt/misc/__p__pwctype.c create mode 100644 mingw-w64-crt/misc/__pwctype_func.c diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index f56e57cb8fda..16cc3d3a5889 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -437,6 +437,7 @@ src_msvcrt32=\ math/x86/_copysignf.c \ misc/___mb_cur_max_func.c \ misc/__pctype_func.c \ + misc/__pwctype_func.c \ misc/_create_locale.c \ misc/_free_locale.c \ misc/_get_current_locale.c \ @@ -586,7 +587,9 @@ src_crtdll=\ misc/__p__commode.c \ misc/__p__fmode.c \ misc/__p__pctype.c \ + misc/__p__pwctype.c \ misc/__pctype_func.c \ + misc/__pwctype_func.c \ misc/__set_app_type.c \ misc/dummy__setusermatherr.c \ misc/imaxabs.c \ @@ -614,7 +617,9 @@ src_msvcrt10=\ misc/__p__commode.c \ misc/__p__fmode.c \ misc/__p__pctype.c \ + misc/__p__pwctype.c \ misc/__pctype_func.c \ + misc/__pwctype_func.c \ misc/__set_app_type.c \ misc/dummy__setusermatherr.c \ misc/imaxabs.c \ @@ -636,6 +641,7 @@ src_msvcrt20=\ crt/msvcrt20_wgetmainargs.c \ misc/___mb_cur_max_func.c \ misc/__pctype_func.c \ + misc/__pwctype_func.c \ misc/__set_app_type.c \ misc/dummy__setusermatherr.c \ misc/imaxabs.c \ @@ -654,6 +660,7 @@ src_msvcrt20=\ src_msvcrt40=\ misc/___mb_cur_max_func.c \ misc/__pctype_func.c \ + misc/__pwctype_func.c \ misc/imaxabs.c \ misc/imaxdiv.c \ misc/invalid_parameter_handler.c \ diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in b/mingw-w64-crt/lib-common/msvcrt.def.in index 6f4881906776..29fda75203bc 100644 --- a/mingw-w64-crt/lib-common/msvcrt.def.in +++ b/mingw-w64-crt/lib-common/msvcrt.def.in @@ -1145,7 +1145,7 @@ _wtof F_I386(__CxxCallUnwindVecDtor) F_X86_ANY(__CxxFrameHandler2) ___lc_collate_cp_func -__pwctype_func +F_NON_I386(__pwctype_func) ; i386 __pwctype_func replaced by emu F_NON_I386(_abs64) ; i386 _abs64 replaced by emu _mkgmtime _mkgmtime64 diff --git a/mingw-w64-crt/misc/__p__pwctype.c b/mingw-w64-crt/misc/__p__pwctype.c new file mode 100644 index 000000000000..651b08cf1428 --- /dev/null +++ b/mingw-w64-crt/misc/__p__pwctype.c @@ -0,0 +1,17 @@ +/** + * 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> +#include <corecrt.h> + +extern const wctype_t** __MINGW_IMP_SYMBOL(_pwctype); + +const wctype_t** __cdecl __p__pwctype(void); +const wctype_t** __cdecl __p__pwctype(void) +{ + return __MINGW_IMP_SYMBOL(_pwctype); +} +const wctype_t** (__cdecl *__MINGW_IMP_SYMBOL(__p__pwctype))(void) = __p__pwctype; diff --git a/mingw-w64-crt/misc/__pwctype_func.c b/mingw-w64-crt/misc/__pwctype_func.c new file mode 100644 index 000000000000..309f02241979 --- /dev/null +++ b/mingw-w64-crt/misc/__pwctype_func.c @@ -0,0 +1,17 @@ +/** + * 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> +#include <corecrt.h> + +_CRTIMP const wctype_t** __cdecl __p__pwctype(void); + +const wctype_t* __cdecl __pwctype_func(void); +const wctype_t* __cdecl __pwctype_func(void) +{ + return *__p__pwctype(); +} +const wctype_t* (__cdecl *__MINGW_IMP_SYMBOL(__pwctype_func))(void) = __pwctype_func; diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h index e0d23c06535e..1fb3fbba20d4 100644 --- a/mingw-w64-headers/crt/ctype.h +++ b/mingw-w64-headers/crt/ctype.h @@ -43,17 +43,10 @@ extern "C" { #define _wctype (* __MINGW_IMP_SYMBOL(_wctype)) #endif #endif -#ifdef _MSVCRT_ -#define __pwctype_func() (_pwctype) -#ifndef _pwctype - extern const unsigned short *_pwctype; -#endif -#else -#define __pwctype_func() (* __MINGW_IMP_SYMBOL(_pwctype)) + + _CRTIMP const wctype_t * __cdecl __pwctype_func(void); #ifndef _pwctype - extern const unsigned short ** __MINGW_IMP_SYMBOL(_pwctype); -#define _pwctype (* __MINGW_IMP_SYMBOL(_pwctype)) -#endif +#define _pwctype (__pwctype_func()) #endif #endif #endif diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h index 9ac5f5a9cc77..c219e1fee9a8 100644 --- a/mingw-w64-headers/crt/wchar.h +++ b/mingw-w64-headers/crt/wchar.h @@ -175,19 +175,9 @@ _CRTIMP FILE *__cdecl __acrt_iob_func(unsigned index); #endif #endif -#ifdef _MSVCRT_ -#define __pwctype_func() (_pwctype) -#else -#define __pwctype_func() (* __MINGW_IMP_SYMBOL(_pwctype)) -#endif - + _CRTIMP const wctype_t * __cdecl __pwctype_func(void); #ifndef _pwctype -#ifdef _MSVCRT_ - extern const unsigned short *_pwctype; -#else - extern const unsigned short ** __MINGW_IMP_SYMBOL(_pwctype); -#define _pwctype (* __MINGW_IMP_SYMBOL(_pwctype)) -#endif +#define _pwctype (__pwctype_func()) #endif #endif diff --git a/mingw-w64-headers/crt/wctype.h b/mingw-w64-headers/crt/wctype.h index b04a6cadc908..a9c8afeebc70 100644 --- a/mingw-w64-headers/crt/wctype.h +++ b/mingw-w64-headers/crt/wctype.h @@ -67,14 +67,9 @@ extern "C" { #endif #endif + _CRTIMP const wctype_t * __cdecl __pwctype_func(void); #ifndef _pwctype -#ifdef _MSVCRT_ - extern const unsigned short *_pwctype; -#else - extern const unsigned short ** __MINGW_IMP_SYMBOL(_pwctype); -#define _pwctype (* __MINGW_IMP_SYMBOL(_pwctype)) -#define __pwctype_func() (* __MINGW_IMP_SYMBOL(_pwctype)) -#endif +#define _pwctype (__pwctype_func()) #endif #endif #endif -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public