From: Rich Felker Date: Thu, 24 Jul 2014 07:02:17 +0000 (-0400) Subject: fix locale environment variable logic for empty strings X-Git-Tag: v1.1.4~25 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=674e28af2deaa3ef2b71af18f7a18af22467d5ef;p=oweals%2Fmusl.git fix locale environment variable logic for empty strings per POSIX (XBD 8.2) LC_*/LANG environment variables set to to the empty string are supposed to be treated as if they were not set at all. --- diff --git a/src/locale/__setlocalecat.c b/src/locale/__setlocalecat.c index f1e4bf07..a947dbff 100644 --- a/src/locale/__setlocalecat.c +++ b/src/locale/__setlocalecat.c @@ -16,9 +16,9 @@ static const char envvars[][12] = { int __setlocalecat(locale_t loc, int cat, const char *val) { if (!*val) { - (val = getenv("LC_ALL")) || - (val = getenv(envvars[cat])) || - (val = getenv("LANG")) || + (val = getenv("LC_ALL")) && *val || + (val = getenv(envvars[cat])) && *val || + (val = getenv("LANG")) && *val || (val = "C.UTF-8"); }