提交 7f39f576 编写于 作者: B Behdad Esfahbod

Implement strtod_l() on MSVC

Patch from Jean Ghali on mailing list.
上级 e5d70988
...@@ -699,34 +699,43 @@ parse_uint32 (const char **pp, const char *end, uint32_t *pv) ...@@ -699,34 +699,43 @@ parse_uint32 (const char **pp, const char *end, uint32_t *pv)
#if defined (HAVE_NEWLOCALE) && defined (HAVE_STRTOD_L) #if defined (HAVE_NEWLOCALE) && defined (HAVE_STRTOD_L)
#define USE_XLOCALE 1 #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 #endif
#ifdef USE_XLOCALE #ifdef USE_XLOCALE
static locale_t C_locale; static HB_LOCALE_T C_locale;
#ifdef HB_USE_ATEXIT #ifdef HB_USE_ATEXIT
static void static void
free_C_locale (void) free_C_locale (void)
{ {
if (C_locale) if (C_locale)
freelocale (C_locale); HB_FREE_LOCALE (C_locale);
} }
#endif #endif
static locale_t static HB_LOCALE_T
get_C_locale (void) get_C_locale (void)
{ {
retry: 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)) if (unlikely (!C))
{ {
C = newlocale (LC_ALL_MASK, "C", nullptr); C = HB_CREATE_LOCALE ("C");
if (!hb_atomic_ptr_cmpexch (&C_locale, nullptr, C)) if (!hb_atomic_ptr_cmpexch (&C_locale, nullptr, C))
{ {
freelocale (C_locale); HB_FREE_LOCALE (C_locale);
goto retry; goto retry;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册