From 6d431010aa3c79352d9944eb747be7b501f58c78 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sat, 13 Feb 2021 07:34:58 -0700 Subject: [PATCH] locale.c: Change internal variable name The new name better reflects its purpose, so is less confusing --- embed.fnc | 2 +- locale.c | 42 +++++++++++++++++++++--------------------- proto.h | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/embed.fnc b/embed.fnc index 52bbfc206438..f6da2fd32c74 100644 --- a/embed.fnc +++ b/embed.fnc @@ -3252,7 +3252,7 @@ S |void |new_numeric |NULLOK const char* newnum S |void |new_LC_ALL |NULLOK const char* unused # ifdef USE_POSIX_2008_LOCALE S |const char*|emulate_setlocale_i|const unsigned int index \ - |NULLOK const char* locale + |NULLOK const char* new_locale S |const char*|my_querylocale_i|const unsigned int index S |const char *|setlocale_from_aggregate_LC_ALL \ |NN const char * locale diff --git a/locale.c b/locale.c index 6e370c8ee3cd..f2a2ab204cf3 100644 --- a/locale.c +++ b/locale.c @@ -784,7 +784,7 @@ S_setlocale_from_aggregate_LC_ALL(pTHX_ const char * locale) # endif /* No querylocale() */ STATIC const char * -S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale) +S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * new_locale) { /* This function effectively performs a setlocale() on just the current * thread; thus it is thread-safe. It does this by using the POSIX 2008 @@ -798,7 +798,7 @@ S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale) * exceptions are mostly those that return a pointer to static memory. * * This function takes our internal index of the 'category' setlocale is - * called with, and the 'locale' to set the category to. It uses the + * called with, and the 'new_locale' to set the category to. It uses the * index to find the category mask that the POSIX 2008 functions use. */ int mask; @@ -813,16 +813,16 @@ S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale) DEBUG_Lv(PerlIO_printf(Perl_debug_log, "%s:%d: emulate_setlocale_i input=%d (%s), mask=0x%x, \"%s\", cat=%d\n", __FILE__, __LINE__, index, category_names[index], mask, - locale, categories[index])); + new_locale, categories[index])); /* If just querying what the existing locale is ... */ - if (locale == NULL) { + if (new_locale == NULL) { return my_querylocale_i(index); } # ifndef USE_QUERYLOCALE - if (strEQ(locale, "")) { + if (strEQ(new_locale, "")) { /* For non-querylocale() systems, we do the setting of "" ourselves to * be sure that we really know what's going on. We follow the Linux @@ -844,7 +844,7 @@ S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale) /* Use any "LC_ALL" environment variable, as it overrides everything * else. */ if (lc_all && strNE(lc_all, "")) { - locale = lc_all; + new_locale = lc_all; } else { @@ -865,11 +865,11 @@ S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale) /* Here we are setting a single category. Assume will have the * default name */ - locale = default_name; + new_locale = default_name; /* But then look for an overriding environment variable */ if (name && strNE(name, "")) { - locale = name; + new_locale = name; } } else { @@ -911,7 +911,7 @@ S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale) /* If all the categories are the same, we can set LC_ALL to * that */ if (! did_override) { - locale = default_name; + new_locale = default_name; } else { @@ -928,8 +928,8 @@ S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale) } } } /* End of this being setlocale(LC_foo, "") */ - else if (strchr(locale, ';')) { - return setlocale_from_aggregate_LC_ALL(locale); + else if (strchr(new_locale, ';')) { + return setlocale_from_aggregate_LC_ALL(new_locale); } /* Here at the end of having to deal with the absence of querylocale(). @@ -971,7 +971,7 @@ S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale) * and in fact, we already have switched to it (in preparation for what * normally is to come). But since we're already there, continue to use * it instead of trying to create a new locale */ - if (mask == LC_ALL_MASK && isNAME_C_OR_POSIX(locale)) { + if (mask == LC_ALL_MASK && isNAME_C_OR_POSIX(new_locale)) { DEBUG_Lv(PerlIO_printf(Perl_debug_log, "%s:%d: will stay in C object\n", @@ -996,7 +996,7 @@ S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale) } /* Ready to create a new locale by modification of the exising one */ - new_obj = newlocale(mask, locale, old_obj); + new_obj = newlocale(mask, new_locale, old_obj); if (! new_obj) { dSAVE_ERRNO; @@ -1044,7 +1044,7 @@ S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale) } } - /* Here, we are using 'new_obj' which matches the input 'locale'. */ + /* Here, we are using 'new_obj' which matches the input 'new_locale'. */ DEBUG_Lv(PerlIO_printf(Perl_debug_log, "%s:%d: emulate_setlocale_i now using %p\n", __FILE__, __LINE__, new_obj)); @@ -1056,13 +1056,13 @@ S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale) # ifdef USE_QUERYLOCALE - if (strEQ(locale, "")) { - locale = querylocale_i(index); + if (strEQ(new_locale, "")) { + new_locale = querylocale_i(index); } # else - /* Here, 'locale' is the return value */ + /* Here, 'new_locale' is the return value */ /* Without querylocale(), we have to update our records */ @@ -1074,7 +1074,7 @@ S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale) * length as 'categories' */ for (i = 0; i <= LC_ALL_INDEX_; i++) { Safefree(PL_curlocales[i]); - PL_curlocales[i] = savepv(locale); + PL_curlocales[i] = savepv(new_locale); } FIX_GLIBC_LC_MESSAGES_BUG(LC_MESSAGES_INDEX_); @@ -1084,10 +1084,10 @@ S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale) /* Otherwise, update the single category, plus LC_ALL */ Safefree(PL_curlocales[index]); - PL_curlocales[index] = savepv(locale); + PL_curlocales[index] = savepv(new_locale); if ( PL_curlocales[LC_ALL_INDEX_] == NULL - || strNE(PL_curlocales[LC_ALL_INDEX_], locale)) + || strNE(PL_curlocales[LC_ALL_INDEX_], new_locale)) { Safefree(PL_curlocales[LC_ALL_INDEX_]); PL_curlocales[LC_ALL_INDEX_] = @@ -1099,7 +1099,7 @@ S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale) # endif - return locale; + return new_locale; } #endif /* End of the various implementations of the setlocale and diff --git a/proto.h b/proto.h index 2944e3eb4f57..3bfd89a347bd 100644 --- a/proto.h +++ b/proto.h @@ -5155,7 +5155,7 @@ STATIC const char* S_stdize_locale(pTHX_ const int category, const char* input_l STATIC const char* S_switch_category_locale_to_template(pTHX_ const int switch_category, const int template_category, const char * template_locale); #define PERL_ARGS_ASSERT_SWITCH_CATEGORY_LOCALE_TO_TEMPLATE # if defined(USE_POSIX_2008_LOCALE) -STATIC const char* S_emulate_setlocale_i(pTHX_ const unsigned int index, const char* locale); +STATIC const char* S_emulate_setlocale_i(pTHX_ const unsigned int index, const char* new_locale); #define PERL_ARGS_ASSERT_EMULATE_SETLOCALE_I STATIC const char* S_my_querylocale_i(pTHX_ const unsigned int index); #define PERL_ARGS_ASSERT_MY_QUERYLOCALE_I