diff options
author | ache <ache@FreeBSD.org> | 2004-02-01 10:32:22 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2004-02-01 10:32:22 +0000 |
commit | 5ee996794258ec5082ee3d155d2f0bbabcfbbff5 (patch) | |
tree | 85cb778a4173c37831de4aa92bf6a6c2f5765f05 | |
parent | 291c8ffa961d791ea783513131ec0f611b0d8bf1 (diff) | |
download | FreeBSD-src-5ee996794258ec5082ee3d155d2f0bbabcfbbff5.zip FreeBSD-src-5ee996794258ec5082ee3d155d2f0bbabcfbbff5.tar.gz |
Fix printout case when LANG is overwritten by LC_ALL
-rw-r--r-- | usr.bin/locale/locale.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/usr.bin/locale/locale.c b/usr.bin/locale/locale.c index 9a1e437..4748c44 100644 --- a/usr.bin/locale/locale.c +++ b/usr.bin/locale/locale.c @@ -421,16 +421,19 @@ void showlocale(void) { size_t i; - const char *lang, *vval, *eval; + const char *lang, *vval, *eval, *lcall; - setlocale(LC_ALL, ""); + (void)setlocale(LC_ALL, ""); - lang = getenv("LANG"); - if (lang == NULL) { + if ((lang = getenv("LANG")) == NULL) lang = ""; - } - printf("LANG=%s\n", lang); /* XXX: if LANG is null, then set it to "C" to get implied values? */ + if ((lcall = getenv("LC_ALL")) == NULL) + lcall = ""; + if (!*lcall || !strcmp(lang, lcall)) + printf("LANG=%s\n", lang); + else + printf("LANG=\"%s\"\n", lcall); for (i = 0; i < NLCINFO; i++) { vval = setlocale(lcinfo[i].id, NULL); @@ -451,11 +454,7 @@ showlocale(void) } } - vval = getenv("LC_ALL"); - if (vval == NULL) { - vval = ""; - } - printf("LC_ALL=%s\n", vval); + printf("LC_ALL=%s\n", lcall); } /* |