[systemd-commits] src/shared
Lennart Poettering
lennart at kemper.freedesktop.org
Tue Jul 16 10:03:43 PDT 2013
src/shared/util.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
New commits:
commit 6cf2f1d94dc7749bcdff5385838bdc8eba9c3001
Author: Harald Hoyer <harald at redhat.com>
Date: Thu Jun 27 11:26:36 2013 +0200
util.c:is_locale_utf8(): check, if "C" was set on purpose
If you have a ASCII only terminal, there is no way to set the charmap to
ANSI_X3.4-1968, other than using LC_CTYPE=C.
We don't want to assume a UTF-8 capable terminal in this case and only
do so, if LANG, LC_ALL and LC_CTYPE are unset.
diff --git a/src/shared/util.c b/src/shared/util.c
index 19ca8ad..15abd50 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5420,20 +5420,24 @@ bool is_locale_utf8(void) {
goto out;
}
- /* For LC_CTYPE=="C" return true,
- * because CTYPE is effectly unset and
- * everything defaults to UTF-8 nowadays. */
-
+ /* For LC_CTYPE=="C" return true, because CTYPE is effectly
+ * unset and everything can do to UTF-8 nowadays. */
set = setlocale(LC_CTYPE, NULL);
if (!set) {
cached_answer = true;
goto out;
}
- cached_answer = streq(set, "C");
+ /* Check result, but ignore the result if C was set
+ * explicitly. */
+ cached_answer =
+ streq(set, "C") &&
+ !getenv("LC_ALL") &&
+ !getenv("LC_CTYPE") &&
+ !getenv("LANG");
out:
- return (bool)cached_answer;
+ return (bool) cached_answer;
}
const char *draw_special_char(DrawSpecialChar ch) {
More information about the systemd-commits
mailing list