diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 2003-06-10 02:15:00 +0000 |
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 2003-06-10 02:15:00 +0000 |
| commit | ddcab7eeac04e49f3d12c692ab6d0abb7db8068c (patch) | |
| tree | e7cc827d18ff197aa3e563f7009a9ea4e573c8aa /usr.bin/catman | |
| parent | 1d35769ff1efc4a3508138ec05c5e949465f14ad (diff) | |
Notes
Diffstat (limited to 'usr.bin/catman')
| -rw-r--r-- | usr.bin/catman/catman.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/usr.bin/catman/catman.c b/usr.bin/catman/catman.c index 5d181d7d276b9..265388d999907 100644 --- a/usr.bin/catman/catman.c +++ b/usr.bin/catman/catman.c @@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$"); #include <dirent.h> #include <err.h> #include <fcntl.h> +#include <locale.h> +#include <langinfo.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -709,24 +711,19 @@ determine_locale(void) { char *sep; - locale = getenv("LC_ALL"); - if (locale == NULL) - locale = getenv("LC_CTYPE"); - if (locale == NULL) - locale = getenv("LANG"); - if (locale == NULL) { - warnx("-L option used, but no locale in environment\n"); + if ((locale = setlocale(LC_CTYPE, "")) == NULL) { + warnx("-L option used, but no locale found\n"); return; } sep = strchr(locale, '_'); - if (sep != NULL && isupper(sep[1]) && isupper(sep[2])) { + if (sep != NULL && isupper((unsigned char)sep[1]) + && isupper((unsigned char)sep[2])) { asprintf(&lang_locale, "%.*s%s", sep - locale, locale, &sep[3]); } - sep = strchr(locale, '.'); - if (sep != NULL) { + sep = nl_langinfo(CODESET); + if (sep != NULL && *sep != '\0' && strcmp(sep, "US-ASCII") != 0) { int i; - sep++; for (i = 0; locale_device[i] != NULL; i += 2) { if (strcmp(sep, locale_device[i]) == 0) { nroff_device = locale_device[i + 1]; @@ -734,8 +731,11 @@ determine_locale(void) } } } - if (verbose) + if (verbose) { + if (lang_locale != NULL) + fprintf(stderr, "short locale is %s\n", lang_locale); fprintf(stderr, "nroff device is %s\n", nroff_device); + } } static void |
