From 44fe1c8ff19048d11785ff154993d6637b447fdd Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Wed, 25 Mar 2020 16:36:48 +0430 Subject: [PATCH] Remove xlocale use now that isn't available in most distros Our CI bots don't detect it in Alpine, ArchLinux, Ubuntu and Fedora so let's get rid of it use the fallback we are using anyway for a long time. --- CMakeLists.txt | 6 +--- configure.ac | 4 +-- meson.build | 3 -- src/hb-number.cc | 71 +--------------------------------------------- src/test-number.cc | 9 ------ 5 files changed, 4 insertions(+), 89 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cdfd4b3b..71830b6f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,7 +88,7 @@ endmacro () if (UNIX) list(APPEND CMAKE_REQUIRED_LIBRARIES m) endif () -check_funcs(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l roundf) +check_funcs(atexit mprotect sysconf getpagesize mmap isatty roundf) check_include_file(unistd.h HAVE_UNISTD_H) if (${HAVE_UNISTD_H}) add_definitions(-DHAVE_UNISTD_H) @@ -97,10 +97,6 @@ check_include_file(sys/mman.h HAVE_SYS_MMAN_H) if (${HAVE_SYS_MMAN_H}) add_definitions(-DHAVE_SYS_MMAN_H) endif () -check_include_file(xlocale.h HAVE_XLOCALE_H) -if (${HAVE_XLOCALE_H}) - add_definitions(-DHAVE_XLOCALE_H) -endif () check_include_file(stdbool.h HAVE_STDBOOL_H) if (${HAVE_STDBOOL_H}) add_definitions(-DHAVE_STDBOOL_H) diff --git a/configure.ac b/configure.ac index 7fd9538c2..df5929744 100644 --- a/configure.ac +++ b/configure.ac @@ -77,8 +77,8 @@ GTK_DOC_CHECK([1.15],[--flavour no-tmpl]) ]) # Functions and headers -AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l roundf) -AC_CHECK_HEADERS(unistd.h sys/mman.h xlocale.h stdbool.h) +AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize mmap isatty roundf) +AC_CHECK_HEADERS(unistd.h sys/mman.h stdbool.h) # Compiler flags AC_CANONICAL_HOST diff --git a/meson.build b/meson.build index 016ef89cc..12dc4858f 100644 --- a/meson.build +++ b/meson.build @@ -59,7 +59,6 @@ python3 = import('python').find_installation('python3') check_headers = [ ['unistd.h'], ['sys/mman.h'], - ['xlocale.h'], ['stdbool.h'], ] @@ -70,8 +69,6 @@ check_funcs = [ ['getpagesize'], ['mmap'], ['isatty'], - ['newlocale'], - ['strtod_l'], ['roundf'], ] diff --git a/src/hb-number.cc b/src/hb-number.cc index 424c2a3ff..e68b10d9b 100644 --- a/src/hb-number.cc +++ b/src/hb-number.cc @@ -28,11 +28,6 @@ #include "hb-number.hh" #include "hb-number-parser.hh" -#include -#ifdef HAVE_XLOCALE_H -#include -#endif - template static bool _parse_number (const char **pp, const char *end, T *pv, @@ -74,75 +69,11 @@ hb_parse_uint (const char **pp, const char *end, unsigned int *pv, { return strtoul (p, end, base); }); } - -#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 - -#if HB_USE_ATEXIT -static void free_static_C_locale (); -#endif - -static struct hb_C_locale_lazy_loader_t : hb_lazy_loader_t, - hb_C_locale_lazy_loader_t> -{ - static HB_LOCALE_T create () - { - HB_LOCALE_T C_locale = HB_CREATE_LOCALE ("C"); - -#if HB_USE_ATEXIT - atexit (free_static_C_locale); -#endif - - return C_locale; - } - static void destroy (HB_LOCALE_T p) - { - HB_FREE_LOCALE (p); - } - static HB_LOCALE_T get_null () - { - return nullptr; - } -} static_C_locale; - -#if HB_USE_ATEXIT -static -void free_static_C_locale () -{ - static_C_locale.free_instance (); -} -#endif - -static HB_LOCALE_T -get_C_locale () -{ - return static_C_locale.get_unconst (); -} -#endif /* USE_XLOCALE */ - bool hb_parse_double (const char **pp, const char *end, double *pv, bool whole_buffer) { return _parse_number (pp, end, pv, whole_buffer, [] (const char *p, char **end) - { -#ifdef USE_XLOCALE - return strtod_l (p, end, get_C_locale ()); -#else - return strtod_rl (p, end); -#endif - }); + { return strtod_rl (p, end); }); } diff --git a/src/test-number.cc b/src/test-number.cc index 3591b13f2..468de6f42 100644 --- a/src/test-number.cc +++ b/src/test-number.cc @@ -146,11 +146,6 @@ main (int argc, char **argv) assert ((int) roundf (pv * 1000.) == 123); assert (pp - str == 4); assert (end - pp == 1); - - /* Test strtod_rl even if libc's strtod_l is used */ - char *pend; - assert ((int) roundf (strtod_rl (str, &pend) * 1000.) == 123); - assert (pend - str == 4); } { @@ -163,10 +158,6 @@ main (int argc, char **argv) assert ((int) roundf (pv * 1000.) == 123); assert (pp - str == 5); assert (end - pp == 0); - - char *pend; - assert ((int) roundf (strtod_rl (str, &pend) * 1000.) == 123); - assert (pend - str == 5); } {