From: Yoshito Umaoka Date: Wed, 7 Sep 2016 07:43:38 +0000 (+0000) Subject: ICU-10232 Updated preprocessro macro again - including xlocale.h except for windows... X-Git-Tag: milestone-59-0-1~250 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ec3948198ec6d15eca60f3ce7747656af3e1e504;p=icu ICU-10232 Updated preprocessro macro again - including xlocale.h except for windows, configure script to set -DU_HAVE_STRTOD_L=1 when strtod_l is available, etc. X-SVN-Rev: 39144 --- diff --git a/icu4c/source/configure b/icu4c/source/configure index 4cd3586d23b..d764fce787a 100755 --- a/icu4c/source/configure +++ b/icu4c/source/configure @@ -7071,6 +7071,7 @@ fi if test x$ac_cv_func_strtod_l = xyes then + CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_STRTOD_L=1" U_HAVE_STRTOD_L=1 else CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_STRTOD_L=0" diff --git a/icu4c/source/configure.ac b/icu4c/source/configure.ac index 76aa00e1976..0ac7b54d1e1 100644 --- a/icu4c/source/configure.ac +++ b/icu4c/source/configure.ac @@ -896,6 +896,7 @@ AC_SUBST(U_TIMEZONE) AC_CHECK_FUNC(strtod_l) if test x$ac_cv_func_strtod_l = xyes then + CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_STRTOD_L=1" U_HAVE_STRTOD_L=1 else CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_STRTOD_L=0" diff --git a/icu4c/source/i18n/digitlst.cpp b/icu4c/source/i18n/digitlst.cpp index 8809b86549d..e157a3f84c5 100644 --- a/icu4c/source/i18n/digitlst.cpp +++ b/icu4c/source/i18n/digitlst.cpp @@ -30,14 +30,6 @@ #if !UCONFIG_NO_FORMATTING -#if !defined(U_HAVE_STRTOD_L) -# if U_PLATFORM_IS_DARWIN_BASED || U_PLATFORM_IS_LINUX_BASED || U_PLATFORM == U_PF_BSD || U_PLATFORM_HAS_WIN32_API -# define U_HAVE_STRTOD_L 1 -# else -# define U_HAVE_STRTOD_L 0 -# endif -#endif - #include "unicode/putil.h" #include "charstr.h" #include "cmemory.h" @@ -54,7 +46,17 @@ #include #include -#if U_HAVE_STRTOD_L && (U_PLATFORM_IS_DARWIN_BASED || U_PLATFORM == U_PF_BSD) +#if !defined(U_USE_STRTOD_L) +# if U_PLATFORM_HAS_WIN32_API +# define U_USE_STRTOD_L 1 +# elif defined(U_HAVE_STRTOD_L) +# define U_USE_STRTOD_L U_HAVE_STRTOD_L +# else +# define U_USE_STRTOD_L 0 +# endif +#endif + +#if U_USE_STRTOD_L && !U_PLATFORM_HAS_WIN32_API #include #endif @@ -477,18 +479,13 @@ DigitList::getDouble() const return tDouble; } -#if U_HAVE_STRTOD_L -# if U_PLATFORM_HAS_WIN32_API -# define locale_t _locale_t -# define newlocale(cat, loc, base) _create_locale(cat, loc) -# define freelocale _free_locale -# define strtod_l _strtod_l -# elif U_PLATFORM_IS_DARWIN_BASED || U_PLATFORM == U_PF_BSD -# define LC_ALL LC_ALL_MASK -# endif +#if U_USE_STRTOD_L && U_PLATFORM_HAS_WIN32_API +# define locale_t _locale_t +# define freelocale _free_locale +# define strtod_l _strtod_l #endif -#if U_HAVE_STRTOD_L +#if U_USE_STRTOD_L static locale_t gCLocale = (locale_t)0; #endif static icu::UInitOnce gCLocaleInitOnce = U_INITONCE_INITIALIZER; @@ -497,7 +494,7 @@ U_CDECL_BEGIN // Cleanup callback func static UBool U_CALLCONV digitList_cleanup(void) { -#if U_HAVE_STRTOD_L +#if U_USE_STRTOD_L if (gCLocale != (locale_t)0) { freelocale(gCLocale); } @@ -507,8 +504,12 @@ static UBool U_CALLCONV digitList_cleanup(void) // C Locale initialization func static void U_CALLCONV initCLocale(void) { ucln_i18n_registerCleanup(UCLN_I18N_DIGITLIST, digitList_cleanup); -#if U_HAVE_STRTOD_L - gCLocale = newlocale(LC_ALL, "C", (locale_t)0); +#if U_USE_STRTOD_L +# if U_PLATFORM_HAS_WIN32_API + gCLocale = _create_locale(LC_ALL, "C"); +# else + gCLocale = newlocale(LC_ALL_MASK, "C", (locale_t)0); +# endif #endif } U_CDECL_END @@ -516,7 +517,7 @@ U_CDECL_END double DigitList::decimalStrToDouble(char *decstr, char **end) { umtx_initOnce(gCLocaleInitOnce, &initCLocale); -#if U_HAVE_STRTOD_L +#if U_USE_STRTOD_L return strtod_l(decstr, end, gCLocale); #else char *decimalPt = strchr(decstr, '.');