gzjjgod at gmail.com
2012-Jun-04 08:51 UTC
[Fontconfig] [PATCH] Check not only existence but also emptyness of environments
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.
---
src/fcdefault.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
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
Akira TAGOH
2012-Jun-04 09:09 UTC
[Fontconfig] [PATCH] Check not only existence but also emptyness of environments
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.1Though it would be sufficient to just check if langs[0] is 0 or not. Thanks anyway. -- Akira TAGOH