Skip to content

Commit 6fd65f1

Browse files
khwilliamsonscottchiefbaker
authored andcommitted
locale.c: Don't ever use system LC_ALL
This fixes Perl#20231 LC_ALL is a compendium of the individual locale categories, such as LC_CTYPE, LC_NUMERIC, .... When all categories are in the same locale, it acts just like an individual category. But when the categories are not in the same locale, some means must be used to indicate that. Platforms differ in how they represent this. Alpine uses: a;b;c;d;e;f where each letter is replaced by the correct locale for a given category. Which category is in which position is deterministic, and platform-specific. Other platforms separate by a '/'. And glibc uses a more informative format: LC_CTYPE=a;LC_NUMBERIC=b; ... This has the advantage that it's obvious to the reader what is what, and the order in the string is irrelevant. It might be possible, but painful, for a Configure probe to figure out what the syntax is for the current platform. I chose not to do that. A platform might come along with a novel syntax unanticipated by whatever probe we came up with. Instead, perl uses the glibc format internally, and when it needs to get or set LC_ALL from the system, it loops through each category individually, so that by the time it has done all of them, LC_ALL will have been implicitly handled. The breaking commit a7ff7ac failed to do that.
1 parent 8931857 commit 6fd65f1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

locale.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4649,8 +4649,12 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
46494649
# endif
46504650
# ifdef USE_PL_CURLOCALES
46514651

4652-
/* Initialize our records. If we have POSIX 2008, we have LC_ALL */
4653-
void_setlocale_c(LC_ALL, porcelain_setlocale(LC_ALL, NULL));
4652+
/* Initialize our records. */
4653+
for (i = 0; i < NOMINAL_LC_ALL_INDEX; i++) {
4654+
(void) emulate_setlocale_i(i, porcelain_setlocale(categories[i], NULL),
4655+
RECALCULATE_LC_ALL_ON_FINAL_INTERATION,
4656+
__LINE__);
4657+
}
46544658

46554659
# endif
46564660

0 commit comments

Comments
 (0)