• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * This file has no copyright assigned and is placed in the Public Domain.
3  * This file is part of the mingw-w64 runtime package.
4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5  */
6 
7 #include <windows.h>
8 #include <locale.h>
9 #include <msvcrt.h>
10 
11 static _locale_t __cdecl init_func(int category, const char *locale);
12 _locale_t (__cdecl *__MINGW_IMP_SYMBOL(_create_locale))(int, const char *) = init_func;
13 
null_func(int category,const char * locale)14 static _locale_t __cdecl null_func(int category, const char *locale)
15 {
16   (void)category;
17   (void)locale;
18   return NULL;
19 }
20 
init_func(int category,const char * locale)21 static _locale_t __cdecl init_func(int category, const char *locale)
22 {
23     HMODULE msvcrt = __mingw_get_msvcrt_handle();
24     _locale_t (__cdecl *func)(int, const char *) = NULL;
25 
26     if (msvcrt)
27         func = (void*)GetProcAddress(msvcrt, "_create_locale");
28 
29     if (!func)
30         func = null_func;
31 
32     return (__MINGW_IMP_SYMBOL(_create_locale) = func)(category, locale);
33 }
34