[RFC PATCH] kernel32: Use uselocale function to resture C locale for LC_CTYPE category.
Ken Thomases
ken at codeweavers.com
Wed Mar 20 14:43:49 CDT 2019
On Mar 20, 2019, at 2:02 PM, Piotr Caban <piotr at codeweavers.com> wrote:
>
> XIM doesn't work when LC_CTYPE category is set to C using setlocale.
> diff --git a/configure.ac b/configure.ac
> index d5640ed0e9..4a410f8aea 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -2176,6 +2176,7 @@ AC_CHECK_FUNCS(\
> tcdrain \
> thr_kill2 \
> timegm \
> + uselocale \
The other lines use a tab and yours uses spaces.
> diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
> index 9f4a08fdb9..e25cb7848d 100644
> --- a/dlls/ntdll/thread.c
> +++ b/dlls/ntdll/thread.c
> @@ -24,6 +24,7 @@
> #include <assert.h>
> #include <stdarg.h>
> #include <limits.h>
> +#include <locale.h>
> #include <sys/types.h>
> #ifdef HAVE_SYS_MMAN_H
> #include <sys/mman.h>
> @@ -371,6 +372,15 @@ static void start_thread( struct startup_info *info )
> TEB *teb = info->teb;
> struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)&teb->GdiTebBatch;
> struct debug_info debug_info;
> +#ifdef HAVE_USELOCALE
> + locale_t global_loc, c_loc;
> +
> + /* Fixes issues when tr_TR.UTF-8 locale is used */
> + global_loc = duplocale( LC_GLOBAL_LOCALE );
> + c_loc = newlocale( LC_CTYPE_MASK, "C", global_loc );
> + if (!c_loc) freelocale( global_loc );
> + else if (!uselocale( c_loc )) freelocale( c_loc );
> +#endif
It would be better to not duplicate the locale objects for every thread (and leak them). You can use static variables and one-time initialization. And perhaps share them with the ones in kernel32, perhaps via libwine.
-Ken
More information about the wine-devel
mailing list