Re: [systemd-devel] [PATCH 2/2] util.c:is_locale_utf8(): check, if "C" was set on purpose

2013-07-16 Thread Lennart Poettering
On Thu, 27.06.13 11:26, har...@redhat.com (har...@redhat.com) wrote:

> From: Harald Hoyer 
> 
> 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.

Applied, but folded the check into one line. Please verify!

Thanks!

> ---
>  src/shared/util.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/shared/util.c b/src/shared/util.c
> index 04811ff..c4b644b 100644
> --- a/src/shared/util.c
> +++ b/src/shared/util.c
> @@ -5387,6 +5387,10 @@ bool is_locale_utf8(void) {
>  
>  cached_answer = streq(set, "C");
>  
> +/* LC_CTYPE=="C", now check, if it was set by purpose */
> +if (cached_answer && (getenv("LC_ALL") || getenv("LC_CTYPE") || 
> getenv("LANG")))
> +cached_answer = false;
> +
>  out:
>  return (bool)cached_answer;
>  }


Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 2/2] util.c:is_locale_utf8(): check, if "C" was set on purpose

2013-06-27 Thread harald
From: Harald Hoyer 

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.
---
 src/shared/util.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/shared/util.c b/src/shared/util.c
index 04811ff..c4b644b 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5387,6 +5387,10 @@ bool is_locale_utf8(void) {
 
 cached_answer = streq(set, "C");
 
+/* LC_CTYPE=="C", now check, if it was set by purpose */
+if (cached_answer && (getenv("LC_ALL") || getenv("LC_CTYPE") || 
getenv("LANG")))
+cached_answer = false;
+
 out:
 return (bool)cached_answer;
 }
-- 
1.8.3.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel