From d18c3061873d515f8346db69fbb5a72f4f7cf258 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Mon, 15 Feb 2021 20:04:30 -0700 Subject: [PATCH] locale.c: Add two #defines This makes sure that we handle having any variant of nl_langinfo() or localeconv(). --- locale.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/locale.c b/locale.c index ba40bb2f1ad1..6e004edbfcaa 100644 --- a/locale.c +++ b/locale.c @@ -146,6 +146,13 @@ static const char C_thousands_sep[] = ""; && (( *(name) == 'C' && (*(name + 1)) == '\0') \ || strEQ((name), "POSIX"))) +#if defined(HAS_THREAD_SAFE_NL_LANGINFO_L) || defined(HAS_NL_LANGINFO) +# define HAS_SOME_LANGINFO +#endif +#if defined(HAS_LOCALECONV) || defined(HAS_LOCALECONV_L) +# define HAS_SOME_LOCALECONV +#endif + #ifdef USE_LOCALE /* This code keeps a LRU cache of the UTF-8ness of the locales it has so-far @@ -1500,8 +1507,8 @@ S_set_numeric_radix(pTHX_ const bool use_locale) /* If 'use_locale' is FALSE, set to use a dot for the radix character. If * TRUE, use the radix character derived from the current locale */ -# if defined(USE_LOCALE_NUMERIC) && ( defined(HAS_LOCALECONV) \ - || defined(HAS_NL_LANGINFO)) +# if defined(USE_LOCALE_NUMERIC) && ( defined(HAS_SOME_LOCALECONV) \ + || defined(HAS_SOME_LANGINFO)) const char * radix = (use_locale) ? my_nl_langinfo(RADIXCHAR, FALSE) @@ -1982,7 +1989,7 @@ S_new_ctype(pTHX_ const char *newctype) ); } -# ifdef HAS_NL_LANGINFO +# ifdef HAS_SOME_LANGINFO Perl_sv_catpvf(aTHX_ PL_warn_locale, "; codeset=%s", /* parameter FALSE is a don't care here */ @@ -2792,7 +2799,7 @@ L|POSIX/localeconv>, which is thread-friendly. */ const char * -#ifdef HAS_NL_LANGINFO +#ifdef HAS_SOME_LANGINFO Perl_langinfo(const nl_item item) #else Perl_langinfo(const int item) @@ -2802,7 +2809,7 @@ Perl_langinfo(const int item) } STATIC const char * -# ifdef HAS_NL_LANGINFO +# ifdef HAS_SOME_LANGINFO S_my_nl_langinfo(const nl_item item, bool toggle) # else S_my_nl_langinfo(const int item, bool toggle) @@ -2900,7 +2907,7 @@ S_my_nl_langinfo(const int item, bool toggle) { -# ifdef HAS_LOCALECONV +# ifdef HAS_SOME_LOCALECONV const struct lconv* lc; const char * temp; @@ -4944,7 +4951,7 @@ Perl__is_cur_LC_category_utf8(pTHX_ int category) * calculate it */ # if defined(USE_LOCALE_CTYPE) \ - && ( defined(HAS_NL_LANGINFO) \ + && ( defined(HAS_SOME_LANGINFO) \ || (defined(HAS_MBTOWC) || defined(HAS_MBRTOWC))) { @@ -4972,7 +4979,7 @@ Perl__is_cur_LC_category_utf8(pTHX_ int category) } # endif -# if defined(HAS_NL_LANGINFO) +# if defined(HAS_SOME_LANGINFO) { /* The task is easiest if the platform has this POSIX 2001 function. Except on some platforms it can wrongly return "", so have to have