From a6e1954fb51583783853a94119c94f5b3de8a9a6 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 11 Apr 2021 09:12:07 -0600 Subject: [PATCH] locale.c: Rmv S_set_numeric_radix() Previous commits have made this function much smaller, and its branches can be easily absorbed into the callers, with clearer code, and in fact removal of a redundant calculation of the locale's radix character, promised in a previous commit's message --- embed.fnc | 1 - embed.h | 1 - locale.c | 44 ++++++++++---------------------------------- 3 files changed, 10 insertions(+), 36 deletions(-) diff --git a/embed.fnc b/embed.fnc index b02b60359c7e..316929e7d622 100644 --- a/embed.fnc +++ b/embed.fnc @@ -3287,7 +3287,6 @@ Sr |void |setlocale_failure_panic_i|const unsigned int cat_index \ |NN const char * failed \ |const line_t caller_0_line \ |const line_t caller_1_line -S |void |set_numeric_radix|const bool use_locale S |void |new_numeric |NN const char* newnum S |void |new_LC_ALL |NULLOK const char* unused S |const char *|toggle_locale_i|const unsigned switch_cat_index \ diff --git a/embed.h b/embed.h index d78c0258d17d..89e2c18c75c5 100644 --- a/embed.h +++ b/embed.h @@ -1734,7 +1734,6 @@ #define new_numeric(a) S_new_numeric(aTHX_ a) #define restore_toggled_locale_i(a,b) S_restore_toggled_locale_i(aTHX_ a,b) #define save_to_buffer S_save_to_buffer -#define set_numeric_radix(a) S_set_numeric_radix(aTHX_ a) #define setlocale_failure_panic_i(a,b,c,d,e) S_setlocale_failure_panic_i(aTHX_ a,b,c,d,e) #define stdize_locale(a,b,c,d) S_stdize_locale(aTHX_ a,b,c,d) #define toggle_locale_i(a,b) S_toggle_locale_i(aTHX_ a,b) diff --git a/locale.c b/locale.c index b6a1768c89ff..42cbee3170b2 100644 --- a/locale.c +++ b/locale.c @@ -1512,33 +1512,6 @@ S_setlocale_failure_panic_i(pTHX_ NOT_REACHED; /* NOTREACHED */ } -STATIC void -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 */ - -# ifndef USE_LOCALE_NUMERIC - - PERL_UNUSED_ARG(use_locale); - -# else - - if (! use_locale) { - sv_setpv(PL_numeric_radix_sv, C_decimal_point); - } - else { - sv_setsv_nomg(PL_numeric_radix_sv, PL_underlying_radix_sv); - } - - DEBUG_L(PerlIO_printf(Perl_debug_log, "Locale radix is '%s', ?UTF-8=%d\n", - SvPVX(PL_numeric_radix_sv), - cBOOL(SvUTF8(PL_numeric_radix_sv)))); - -# endif /* USE_LOCALE_NUMERIC */ - -} - STATIC void S_new_numeric(pTHX_ const char *newnum) { @@ -1645,6 +1618,10 @@ S_new_numeric(pTHX_ const char *newnum) SvUTF8_on(PL_underlying_radix_sv); } + DEBUG_L(PerlIO_printf(Perl_debug_log, + "Locale radix is '%s', ?UTF-8=%d\n", + SvPVX(PL_underlying_radix_sv), + cBOOL(SvUTF8(PL_underlying_radix_sv)))); /* This locale is indistinguishable from C (for numeric purposes) if both * the radix character and the thousands separator are the same as C's. @@ -1689,10 +1666,7 @@ S_new_numeric(pTHX_ const char *newnum) * separator. This is for XS modules, so they don't have to worry about * the radix being a non-dot. (Core operations that need the underlying * locale change to it temporarily). */ - if (PL_numeric_standard) { - set_numeric_radix(0); - } - else { + if (! PL_numeric_standard) { set_numeric_standard(); } @@ -1719,8 +1693,9 @@ Perl_set_numeric_standard(pTHX) void_setlocale_c(LC_NUMERIC, "C"); PL_numeric_standard = TRUE; + sv_setpv(PL_numeric_radix_sv, C_decimal_point); + PL_numeric_underlying = PL_numeric_underlying_is_standard; - set_numeric_radix(0); # endif /* USE_LOCALE_NUMERIC */ @@ -1744,9 +1719,10 @@ Perl_set_numeric_underlying(pTHX) PL_numeric_name)); void_setlocale_c(LC_NUMERIC, PL_numeric_name); - PL_numeric_standard = PL_numeric_underlying_is_standard; PL_numeric_underlying = TRUE; - set_numeric_radix(! PL_numeric_standard); + sv_setsv_nomg(PL_numeric_radix_sv, PL_underlying_radix_sv); + + PL_numeric_standard = PL_numeric_underlying_is_standard; # endif /* USE_LOCALE_NUMERIC */