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

Lennart Poettering lennart at poettering.net
Tue Jul 16 10:04:01 PDT 2013


On Thu, 27.06.13 11:26, harald at redhat.com (harald at redhat.com) wrote:

> From: Harald Hoyer <harald at redhat.com>
> 
> 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.


More information about the systemd-devel mailing list