Re: [Mingw-w64-public] [PATCH] headers: Update the threadlocinfo struct for ucrt
On Fri, 2 Nov 2018, Mateusz wrote: W dniu 18.10.2018 o 19:51, Martin Storsjö pisze: Signed-off-by: Martin Storsjö --- This fixes a testcase like this: #include #include #include int main(int argc, char const *argv[]) { _locale_t loc = _create_locale(LC_ALL, "C"); int ret = _isdigit_l('3', loc); printf ("%d\n", ret); return 0; } --- mingw-w64-headers/crt/crtdefs.h | 6 ++ mingw-w64-headers/crt/ctype.h | 5 + 2 files changed, 11 insertions(+) diff --git a/mingw-w64-headers/crt/crtdefs.h b/mingw-w64-headers/crt/crtdefs.h index 20ba574..84c0455 100644 --- a/mingw-w64-headers/crt/crtdefs.h +++ b/mingw-w64-headers/crt/crtdefs.h @@ -442,6 +442,11 @@ typedef struct tagLC_ID { #ifndef _THREADLOCALEINFO #define _THREADLOCALEINFO typedef struct threadlocaleinfostruct { +#ifdef __MSVCRT_VERSION__ >= 0x1400 This gives warning. Maybe we should use #if __MSVCRT_VERSION__ >= 0x1400 instead? Oh, indeed, oops. I pushed a fix. // Martin ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] [PATCH] headers: Update the threadlocinfo struct for ucrt
W dniu 18.10.2018 o 19:51, Martin Storsjö pisze: > Signed-off-by: Martin Storsjö > --- > This fixes a testcase like this: > > #include > #include > #include > > int main(int argc, char const *argv[]) > { > _locale_t loc = _create_locale(LC_ALL, "C"); > int ret = _isdigit_l('3', loc); > printf ("%d\n", ret); > return 0; > } > --- > mingw-w64-headers/crt/crtdefs.h | 6 ++ > mingw-w64-headers/crt/ctype.h | 5 + > 2 files changed, 11 insertions(+) > > diff --git a/mingw-w64-headers/crt/crtdefs.h b/mingw-w64-headers/crt/crtdefs.h > index 20ba574..84c0455 100644 > --- a/mingw-w64-headers/crt/crtdefs.h > +++ b/mingw-w64-headers/crt/crtdefs.h > @@ -442,6 +442,11 @@ typedef struct tagLC_ID { > #ifndef _THREADLOCALEINFO > #define _THREADLOCALEINFO > typedef struct threadlocaleinfostruct { > +#ifdef __MSVCRT_VERSION__ >= 0x1400 This gives warning. Maybe we should use #if __MSVCRT_VERSION__ >= 0x1400 instead? > + const unsigned short *_locale_pctype; > + int _locale_mb_cur_max; > + unsigned int _locale_lc_codepage; > +#else >int refcount; >unsigned int lc_codepage; >unsigned int lc_collate_cp; > @@ -465,6 +470,7 @@ typedef struct threadlocaleinfostruct { >const unsigned char *pclmap; >const unsigned char *pcumap; >struct __lc_time_data *lc_time_curr; > +#endif > } threadlocinfo; > #endif /* _THREADLOCALEINFO */ > > diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h > index a85ad96..e6449b3 100644 > --- a/mingw-w64-headers/crt/ctype.h > +++ b/mingw-w64-headers/crt/ctype.h > @@ -209,8 +209,13 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void); > #endif > > #define __chvalidchk(a,b) (__PCTYPE_FUNC[(unsigned char)(a)] & (b)) > +#ifdef __MSVCRT_VERSION__ >= 0x1400 And here also. Regards, Mateusz ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] [PATCH] headers: Update the threadlocinfo struct for ucrt
On 10/18/2018 07:51 PM, Martin Storsjö wrote: > Signed-off-by: Martin Storsjö > --- > This fixes a testcase like this: > > #include > #include > #include > > int main(int argc, char const *argv[]) > { > _locale_t loc = _create_locale(LC_ALL, "C"); > int ret = _isdigit_l('3', loc); > printf ("%d\n", ret); > return 0; > } > --- > mingw-w64-headers/crt/crtdefs.h | 6 ++ > mingw-w64-headers/crt/ctype.h | 5 + > 2 files changed, 11 insertions(+) The patch looks good to me. Thanks, Jacek ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] [PATCH] headers: Update the threadlocinfo struct for ucrt
Signed-off-by: Martin Storsjö --- This fixes a testcase like this: #include #include #include int main(int argc, char const *argv[]) { _locale_t loc = _create_locale(LC_ALL, "C"); int ret = _isdigit_l('3', loc); printf ("%d\n", ret); return 0; } --- mingw-w64-headers/crt/crtdefs.h | 6 ++ mingw-w64-headers/crt/ctype.h | 5 + 2 files changed, 11 insertions(+) diff --git a/mingw-w64-headers/crt/crtdefs.h b/mingw-w64-headers/crt/crtdefs.h index 20ba574..84c0455 100644 --- a/mingw-w64-headers/crt/crtdefs.h +++ b/mingw-w64-headers/crt/crtdefs.h @@ -442,6 +442,11 @@ typedef struct tagLC_ID { #ifndef _THREADLOCALEINFO #define _THREADLOCALEINFO typedef struct threadlocaleinfostruct { +#ifdef __MSVCRT_VERSION__ >= 0x1400 + const unsigned short *_locale_pctype; + int _locale_mb_cur_max; + unsigned int _locale_lc_codepage; +#else int refcount; unsigned int lc_codepage; unsigned int lc_collate_cp; @@ -465,6 +470,7 @@ typedef struct threadlocaleinfostruct { const unsigned char *pclmap; const unsigned char *pcumap; struct __lc_time_data *lc_time_curr; +#endif } threadlocinfo; #endif /* _THREADLOCALEINFO */ diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h index a85ad96..e6449b3 100644 --- a/mingw-w64-headers/crt/ctype.h +++ b/mingw-w64-headers/crt/ctype.h @@ -209,8 +209,13 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void); #endif #define __chvalidchk(a,b) (__PCTYPE_FUNC[(unsigned char)(a)] & (b)) +#ifdef __MSVCRT_VERSION__ >= 0x1400 +#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) -- 2.7.4 ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] [PATCH] headers: Update the threadlocinfo struct for ucrt
Hi Martin, On 10/18/2018 09:58 AM, Martin Storsjö wrote: > This keeps the old names for the few struct fields that are left, > to avoid having to change code in ctype.h which references it. > > Alternatively, we could switch consistently to the new names in ctype.h, > and add "#define _locale_mb_cur_max mb_cur_max" for the non-ucrt case? > That's a much larger and more intrusive change though. As far as I can see, those are accessed in just two places in ctype.h. Having two #ifdefs there doesn't seem too bad. Thanks, Jacek ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] [PATCH] headers: Update the threadlocinfo struct for ucrt
This keeps the old names for the few struct fields that are left, to avoid having to change code in ctype.h which references it. Alternatively, we could switch consistently to the new names in ctype.h, and add "#define _locale_mb_cur_max mb_cur_max" for the non-ucrt case? That's a much larger and more intrusive change though. Signed-off-by: Martin Storsjö --- This fixes a testcase like this: #include #include #include int main(int argc, char const *argv[]) { _locale_t loc = _create_locale(LC_ALL, "C"); int ret = _isdigit_l('3', loc); printf ("%d\n", ret); return 0; } I guess Wine would need a similar change for ucrt as well, as code which does this correctly for ucrt right now fails in Wine. --- mingw-w64-headers/crt/crtdefs.h | 8 1 file changed, 8 insertions(+) diff --git a/mingw-w64-headers/crt/crtdefs.h b/mingw-w64-headers/crt/crtdefs.h index 20ba574..2321733 100644 --- a/mingw-w64-headers/crt/crtdefs.h +++ b/mingw-w64-headers/crt/crtdefs.h @@ -442,6 +442,13 @@ typedef struct tagLC_ID { #ifndef _THREADLOCALEINFO #define _THREADLOCALEINFO typedef struct threadlocaleinfostruct { +#ifdef __MSVCRT_VERSION__ >= 0x1400 + // In UCRT, these fields actually have different names, but we keep the old + // names since e.g. macros in ctype.h reference them. + const unsigned short *pctype; // _locale_pctype + int mb_cur_max; // _locale_mb_cur_max + unsigned int lc_codepage; // _locale_lc_codepage +#else int refcount; unsigned int lc_codepage; unsigned int lc_collate_cp; @@ -465,6 +472,7 @@ typedef struct threadlocaleinfostruct { const unsigned char *pclmap; const unsigned char *pcumap; struct __lc_time_data *lc_time_curr; +#endif } threadlocinfo; #endif /* _THREADLOCALEINFO */ -- 2.7.4 ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public