[Fontconfig] [PATCH] Check not only existence but also emptyness of environments

Akira TAGOH akira at tagoh.org
Mon Jun 4 02:09:16 PDT 2012


On Mon, Jun 4, 2012 at 5:51 PM,  <gzjjgod at gmail.com> wrote:
> From: Jiang Jiang <gzjjgod at gmail.com>
>
> Locale environment variables, especially LC_ALL, can be empty but
> still set. If we don't check, FcGetDefaultLangs() will fallback to
> "en" for LC_ALL="" case, even if LANG and LC_CTYPE are set.

Right.

> diff --git a/src/fcdefault.c b/src/fcdefault.c
> index 674374c..400d9f5 100644
> --- a/src/fcdefault.c
> +++ b/src/fcdefault.c
> @@ -46,11 +46,11 @@ FcGetDefaultLangs (void)
>     char *langs;
>
>     langs = getenv ("FC_LANG");
> -    if (!langs)
> +    if (!langs || !strlen(langs))
>        langs = getenv ("LC_ALL");
> -    if (!langs)
> +    if (!langs || !strlen(langs))
>        langs = getenv ("LC_CTYPE");
> -    if (!langs)
> +    if (!langs || !strlen(langs))
>        langs = getenv ("LANG");
>     if (langs)
>     {
> --
> 1.7.4.1

Though it would be sufficient to just check if langs[0] is 0 or not.

Thanks anyway.

-- 
Akira TAGOH


More information about the Fontconfig mailing list