Implement strtod_l() on MSVC

Patch from Jean Ghali on mailing list.
This commit is contained in:
Behdad Esfahbod 2017-11-13 15:04:13 -08:00
parent e5d7098892
commit 7f39f57614
1 changed files with 15 additions and 6 deletions

View File

@ -699,34 +699,43 @@ parse_uint32 (const char **pp, const char *end, uint32_t *pv)
#if defined (HAVE_NEWLOCALE) && defined (HAVE_STRTOD_L)
#define USE_XLOCALE 1
#define HB_LOCALE_T locale_t
#define HB_CREATE_LOCALE(locName) newlocale (LC_ALL_MASK, locName, nullptr)
#define HB_FREE_LOCALE(loc) freelocale (loc)
#elif defined(_MSC_VER)
#define USE_XLOCALE 1
#define HB_LOCALE_T _locale_t
#define HB_CREATE_LOCALE(locName) _create_locale (LC_ALL, locName)
#define HB_FREE_LOCALE(loc) _free_locale (loc)
#define strtod_l(a, b, c) _strtod_l ((a), (b), (c))
#endif
#ifdef USE_XLOCALE
static locale_t C_locale;
static HB_LOCALE_T C_locale;
#ifdef HB_USE_ATEXIT
static void
free_C_locale (void)
{
if (C_locale)
freelocale (C_locale);
HB_FREE_LOCALE (C_locale);
}
#endif
static locale_t
static HB_LOCALE_T
get_C_locale (void)
{
retry:
locale_t C = (locale_t) hb_atomic_ptr_get (&C_locale);
HB_LOCALE_T C = (HB_LOCALE_T) hb_atomic_ptr_get (&C_locale);
if (unlikely (!C))
{
C = newlocale (LC_ALL_MASK, "C", nullptr);
C = HB_CREATE_LOCALE ("C");
if (!hb_atomic_ptr_cmpexch (&C_locale, nullptr, C))
{
freelocale (C_locale);
HB_FREE_LOCALE (C_locale);
goto retry;
}