From ac3253d328fb2f90b26fdefd69e58b034b8b2264 Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 1 Sep 1997 13:58:22 +0000 Subject: Fix Cyrillic (KOI8-R) code table detection and processing Remove yet one setuid() --- games/morse/morse.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'games') diff --git a/games/morse/morse.c b/games/morse/morse.c index a78e29f..03118ba 100644 --- a/games/morse/morse.c +++ b/games/morse/morse.c @@ -157,6 +157,7 @@ static struct morsetab koi8rtab[] = { 'Ç', "--.", /* ge */ 'Ä', "-..", /* de */ 'Å', ".", /* ye */ + '£', ".", /* yo, the same as ye */ 'Ö', "...-", /* she */ 'Ú', "--..", /* ze */ 'É', "..", /* i */ @@ -242,7 +243,6 @@ main(int argc, char **argv) if (pflag && (freq == 0)) freq = FREQUENCY; - (void)setuid(getuid()); #ifdef SPEAKER if (pflag) { if ((spkr = open(SPEAKER, O_WRONLY, 0)) == -1) { @@ -259,21 +259,21 @@ main(int argc, char **argv) argc -= optind; argv += optind; - if((p = getenv("LC_CTYPE")) || (p = getenv("LANG"))) { - if(strlen(p) >= strlen("KOI8-R") && - strcasecmp(&p[strlen(p) - strlen("KOI8-R")], "KOI8-R") == 0) + if((p = getenv("LC_CTYPE")) || + (p = getenv("LC_ALL")) || + (p = getenv("LANG"))) { + if(strlen(p) >= sizeof(".KOI8-R") && + strcasecmp(&p[strlen(p) + 1 - sizeof(".KOI8-R")], ".KOI8-R") == 0) hightab = koi8rtab; - setlocale(LC_CTYPE, p); - } else { - setlocale(LC_CTYPE, ""); } + (void) setlocale(LC_CTYPE, ""); if (*argv) { do { for (p = *argv; *p; ++p) { - morse((int) *p); + morse(*p); } - morse((int) ' '); + morse(' '); } while (*++argv); } else { while ((ch = getchar()) != EOF) @@ -287,8 +287,8 @@ morse(char c) { struct morsetab *m; - if (isalpha(c)) - c = tolower(c); + if (isalpha((unsigned char)c)) + c = tolower((unsigned char)c); if ((c == '\r') || (c == '\n')) c = ' '; if (c == ' ') { @@ -330,7 +330,7 @@ play(const char *s) const char *c; for (c = s; *c != '\0'; c++) { - switch ((int) *c) { + switch (*c) { case '.': sound.frequency = freq; sound.duration = dot_clock; -- cgit v1.1