diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 2001-06-26 01:43:52 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 2001-06-26 01:43:52 +0000 |
commit | b031f22d4a1dca32f7e37582068dc85a31d57ac3 (patch) | |
tree | 52ba75bcc6684e041805a0aa609e0d7251b6764e | |
parent | 8fce7fd44f28b235c44546186fd4c93b2a25e8b7 (diff) | |
download | src-test2-b031f22d4a1dca32f7e37582068dc85a31d57ac3.tar.gz src-test2-b031f22d4a1dca32f7e37582068dc85a31d57ac3.zip |
Notes
-rw-r--r-- | games/morse/morse.6 | 16 | ||||
-rw-r--r-- | games/morse/morse.c | 19 |
2 files changed, 19 insertions, 16 deletions
diff --git a/games/morse/morse.6 b/games/morse/morse.6 index 65752e4b2ed8..dec7fbe47bcd 100644 --- a/games/morse/morse.6 +++ b/games/morse/morse.6 @@ -137,18 +137,20 @@ minor glitch that is generated during program startup. speaker device file .El .Sh ENVIRONMENT -.Bl -tag -width LC_CTYPE -compact -.It Ev LC_ALL -.It Ev LC_CTYPE -.It Ev LANG -If one of these variables (in this priority) is set to a locale ending in +.Pp +If your +.Ev LC_CTYPE +locale codeset is .Ql KOI8-R , characters with the high-order bit set are being interpreted as -Cyrillic characters. In all other cases, they are being interpreted +Cyrillic characters. If your +.Ev LC_CTYPE +locale codeset is +.Ql ISO8859-1 +compatible, they are being interpreted as belonging to the .Ql ISO-8859-1 character set. -.El .Sh SEE ALSO .Xr speaker 4 .Sh HISTORY diff --git a/games/morse/morse.c b/games/morse/morse.c index 6579e8dd020c..832228d978ef 100644 --- a/games/morse/morse.c +++ b/games/morse/morse.c @@ -54,6 +54,7 @@ static const char rcsid[] = #include <ctype.h> #include <fcntl.h> +#include <langinfo.h> #include <locale.h> #include <signal.h> #include <stdio.h> @@ -228,13 +229,13 @@ tone_t sound; "usage: morse [-s] [-p] [-e] [-d device] [-w speed] [-f frequency] [string ...]\n" #endif -static const struct morsetab *hightab = iso8859tab; +static const struct morsetab *hightab; int main(int argc, char **argv) { int ch, lflags; - char *p; + char *p, *codeset; while ((ch = getopt(argc, argv, GETOPTOPTS)) != -1) switch ((char) ch) { @@ -318,14 +319,14 @@ main(int argc, char **argv) argc -= optind; argv += optind; - if(((p = getenv("LC_ALL")) && *p) || - ((p = getenv("LC_CTYPE")) && *p) || - ((p = getenv("LANG")) && *p)) { - if(strlen(p) >= sizeof(".KOI8-R") && - strcasecmp(&p[strlen(p) + 1 - sizeof(".KOI8-R")], ".KOI8-R") == 0) + if (setlocale(LC_CTYPE, "") != NULL && + *(codeset = nl_langinfo(CODESET)) != '\0') { + if (strcmp(codeset, "KOI8-R") == 0) hightab = koi8rtab; + else if (strcmp(codeset, "ISO8859-1") == 0 || + strcmp(codeset, "ISO8859-15") == 0) + hightab = iso8859tab; } - (void) setlocale(LC_CTYPE, ""); if (*argv) { do { @@ -372,7 +373,7 @@ morse(char c) } } for (m = ((unsigned char)c < 0x80? mtab: hightab); - m->inchar != '\0'; + m != NULL && m->inchar != '\0'; m++) { if (m->inchar == c) { if (pflag) { |