Skip to content

Commit

Permalink
S_update_PL_curlocales(): accept arbitrary LC_ALL string
Browse files Browse the repository at this point in the history
Prior to this commit, this function couldn't handle an LC_ALL string
that wasn't just a single locale for all categories.  But now that we
can parse a disparate string, update this function to use that.
  • Loading branch information
khwilliamson committed May 6, 2023
1 parent cc5a581 commit fa980da
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions locale.c
Expand Up @@ -2276,7 +2276,6 @@ S_update_PL_curlocales_i(pTHX_
* our mapping of libc category number to our internal equivalents. */

PERL_ARGS_ASSERT_UPDATE_PL_CURLOCALES_I;
PERL_UNUSED_ARG(caller_line);
assert(index <= LC_ALL_INDEX_);

if (index != LC_ALL_INDEX_) {
Expand All @@ -2290,12 +2289,31 @@ S_update_PL_curlocales_i(pTHX_
PL_curlocales[LC_ALL_INDEX_] = NULL;
}
else { /* LC_ALL */

/* For LC_ALL, we change all individual categories to correspond,
* including the LC_ALL element */
for (unsigned int i = 0; i <= LC_ALL_INDEX_; i++) {
Safefree(PL_curlocales[i]);
PL_curlocales[i] = savepv(new_locale);
PL_curlocales[i] = NULL;
}

switch (parse_LC_ALL_string(new_locale,
(const char **) &PL_curlocales,
true, /* Always fill array */
true, /* Panic if fails, as to get here
it earlier had to have succeeded
*/
caller_line))

{
case invalid:
case no_array:
case only_element_0:
locale_panic_via_("Unexpected return from parse_LC_ALL_string",
__FILE__, caller_line);

case full_array:
/* parse_LC_ALL_string() has already filled PL_curlocales properly,
* except for the LC_ALL element, which should be set to
* 'new_locale'. */
PL_curlocales[LC_ALL_INDEX_] = savepv(new_locale);
}
}
}
Expand Down

0 comments on commit fa980da

Please sign in to comment.