locale-setup: merge locale handling in PID1 and localed

This commit is contained in:
Yu Watanabe
2022-06-14 09:07:00 +09:00
parent d2e96a4f87
commit 3d36b5d7e7
12 changed files with 332 additions and 308 deletions

View File

@@ -339,6 +339,17 @@ void locale_variables_free(char *l[_VARIABLE_LC_MAX]) {
l[i] = mfree(l[i]);
}
void locale_variables_simplify(char *l[_VARIABLE_LC_MAX]) {
assert(l);
for (LocaleVariable p = 0; p < _VARIABLE_LC_MAX; p++) {
if (p == VARIABLE_LANG)
continue;
if (isempty(l[p]) || streq_ptr(l[VARIABLE_LANG], l[p]))
l[p] = mfree(l[p]);
}
}
static const char * const locale_variable_table[_VARIABLE_LC_MAX] = {
[VARIABLE_LANG] = "LANG",
[VARIABLE_LANGUAGE] = "LANGUAGE",

View File

@@ -53,3 +53,4 @@ void locale_variables_free(char* l[_VARIABLE_LC_MAX]);
static inline void locale_variables_freep(char*(*l)[_VARIABLE_LC_MAX]) {
locale_variables_free(*l);
}
void locale_variables_simplify(char *l[_VARIABLE_LC_MAX]);