summaryrefslogtreecommitdiffstats
path: root/games/morse
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
parent8451fa99babc868a0ebf3d47a69392fe7206ba50 (diff)
downloadFreeBSD-src-fbe0ca3c4a6a4427efcfd700e338df7ad189c6b1.zip
FreeBSD-src-fbe0ca3c4a6a4427efcfd700e338df7ad189c6b1.tar.gz
Convert to nl_langinfo(CODESET)
Diffstat (limited to 'games/morse')
-rw-r--r--games/morse/morse.616
-rw-r--r--games/morse/morse.c19
2 files changed, 19 insertions, 16 deletions
diff --git a/games/morse/morse.6 b/games/morse/morse.6
index 65752e4..dec7fbe 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 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