summaryrefslogtreecommitdiffstats
path: root/games/morse/morse.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-06-26 01:43:52 +0000
committerache <ache@FreeBSD.org>2001-06-26 01:43:52 +0000
commitfbe0ca3c4a6a4427efcfd700e338df7ad189c6b1 (patch)
tree52ba75bcc6684e041805a0aa609e0d7251b6764e /games/morse/morse.c
parent8451fa99babc868a0ebf3d47a69392fe7206ba50 (diff)
downloadFreeBSD-src-fbe0ca3c4a6a4427efcfd700e338df7ad189c6b1.zip
FreeBSD-src-fbe0ca3c4a6a4427efcfd700e338df7ad189c6b1.tar.gz
Convert to nl_langinfo(CODESET)
Diffstat (limited to 'games/morse/morse.c')
-rw-r--r--games/morse/morse.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/games/morse/morse.c b/games/morse/morse.c
index 6579e8d..832228d 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) {
OpenPOWER on IntegriCloud