From 7f39f576148643b4790fd70361e328b4b4da3149 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 13 Nov 2017 15:04:13 -0800 Subject: [PATCH] Implement strtod_l() on MSVC Patch from Jean Ghali on mailing list. --- src/hb-common.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/hb-common.cc b/src/hb-common.cc index 5c4a2c76f..92720d9e7 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -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; }