From b97e4f7084e3f2c3eea64163188da97734bbedef Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 15 Jan 2022 17:47:51 -0700 Subject: [PATCH] Further adjust setlocale Fixes https://github.com/harfbuzz/harfbuzz/issues/3375#issuecomment-1013783496 --- src/hb-common.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/hb-common.cc b/src/hb-common.cc index 2241a347f..7963bafaa 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -41,17 +41,18 @@ #endif #ifdef WIN32 -using hb_locale_t = _locale_t; +#define hb_locale_t _locale_t; #else -using hb_locale_t = locale_t; +#define hb_locale_t locale_t; #endif +#define hb_setlocale setlocale +#define hb_uselocale uselocale #else -using hb_locale_t = void *; #define hb_locale_t void * -#define setlocale(Category, Locale) "C" -#define uselocale(Locale) ((hb_locale_t) 0) +#define hb_setlocale(Category, Locale) "C" +#define hb_uselocale(Locale) ((hb_locale_t) 0) #endif @@ -433,7 +434,7 @@ hb_language_get_default () hb_language_t language = default_language; if (unlikely (language == HB_LANGUAGE_INVALID)) { - language = hb_language_from_string (setlocale (LC_CTYPE, nullptr), -1); + language = hb_language_from_string (hb_setlocale (LC_CTYPE, nullptr), -1); (void) default_language.cmpexch (HB_LANGUAGE_INVALID, language); } @@ -1127,9 +1128,9 @@ hb_variation_to_string (hb_variation_t *variation, s[len++] = '='; hb_locale_t oldlocale HB_UNUSED; - oldlocale = uselocale (get_C_locale ()); + oldlocale = hb_uselocale (get_C_locale ()); len += hb_max (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%g", (double) variation->value)); - (void) uselocale (oldlocale); + (void) hb_uselocale (oldlocale); assert (len < ARRAY_LENGTH (s)); len = hb_min (len, size - 1);