libroot/locale: Only set all locales if we checked the whole set.
If we only checked one, then of course we can't set LC_ALL,
as that will override ones we didn't verify were the same.
Seems this code has been wrong since it was first imported in 2010.
Fixes #19446.
Diff
src/system/libroot/posix/locale/LocaleInternal.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
@@ -49,6 +49,7 @@
to = LC_LAST;
} else
from = to = category;
bool haveDifferentLocales = false;
locale = NULL;
for (int lc = from; lc <= to; lc++) {
@@ -62,7 +63,7 @@
if (lastLocale != NULL && strcasecmp(locale, lastLocale) != 0)
haveDifferentLocales = true;
}
if (!haveDifferentLocales) {
if (from == 1 && to == LC_LAST && !haveDifferentLocales) {
locales[LC_ALL] = locale;
}