Skip to content

Commit

Permalink
locale.c: Change internal variable name
Browse files Browse the repository at this point in the history
The new name better reflects its purpose, so is less confusing
  • Loading branch information
khwilliamson committed Apr 29, 2021
1 parent cf7cdee commit 6d43101
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion embed.fnc
Expand Up @@ -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
Expand Down
42 changes: 21 additions & 21 deletions locale.c
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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 {

Expand All @@ -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 {
Expand Down Expand Up @@ -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 {

Expand All @@ -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().
Expand Down Expand Up @@ -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",
Expand All @@ -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;
Expand Down Expand Up @@ -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));
Expand All @@ -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 */

Expand All @@ -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_);
Expand All @@ -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_] =
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion proto.h
Expand Up @@ -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
Expand Down

0 comments on commit 6d43101

Please sign in to comment.