summaryrefslogtreecommitdiffstats
path: root/src/basic
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-06-14 02:07:00 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-06-14 13:56:23 +0200
commit3d36b5d7e7b191fca7c5c65dbab94d99cf5f0230 (patch)
tree6f68c94200e0e9f58abe486fdd0dcf2e8dd58d32 /src/basic
parentlocale-util: align locale entries (diff)
downloadsystemd-3d36b5d7e7b191fca7c5c65dbab94d99cf5f0230.tar.xz
systemd-3d36b5d7e7b191fca7c5c65dbab94d99cf5f0230.zip
locale-setup: merge locale handling in PID1 and localed
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/locale-util.c11
-rw-r--r--src/basic/locale-util.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c
index 667b045226..d8518ec06a 100644
--- a/src/basic/locale-util.c
+++ b/src/basic/locale-util.c
@@ -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",
diff --git a/src/basic/locale-util.h b/src/basic/locale-util.h
index bab927146b..8990cb6a75 100644
--- a/src/basic/locale-util.h
+++ b/src/basic/locale-util.h
@@ -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]);