Fix from PR7655: translation of keyboard command in systat is Wrong.
(breaks netstat's :ignore command for upper-case service names)
This commit is contained in:
parent
f7141a0ffb
commit
728f40d730
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: cmds.c,v 1.9 1998/12/19 22:26:13 christos Exp $ */
|
/* $NetBSD: cmds.c,v 1.10 1999/08/02 02:01:57 sommerfeld Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1980, 1992, 1993
|
* Copyright (c) 1980, 1992, 1993
|
||||||
@ -38,7 +38,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)cmds.c 8.2 (Berkeley) 4/29/95";
|
static char sccsid[] = "@(#)cmds.c 8.2 (Berkeley) 4/29/95";
|
||||||
#endif
|
#endif
|
||||||
__RCSID("$NetBSD: cmds.c,v 1.9 1998/12/19 22:26:13 christos Exp $");
|
__RCSID("$NetBSD: cmds.c,v 1.10 1999/08/02 02:01:57 sommerfeld Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -185,13 +185,19 @@ status()
|
|||||||
error("Showing %s, refresh every %d seconds.", curcmd->c_name, naptime);
|
error("Showing %s, refresh every %d seconds.", curcmd->c_name, naptime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* case insensitive prefix comparison */
|
||||||
int
|
int
|
||||||
prefix(s1, s2)
|
prefix(s1, s2)
|
||||||
char *s1, *s2;
|
char *s1, *s2;
|
||||||
{
|
{
|
||||||
|
char c1, c2;
|
||||||
|
|
||||||
while (*s1 == *s2) {
|
while (1) {
|
||||||
if (*s1 == '\0')
|
c1 = *s1 >= 'A' && *s1 <= 'Z' ? *s1 + 'a' - 'A' : *s1;
|
||||||
|
c2 = *s2 >= 'A' && *s2 <= 'Z' ? *s2 + 'a' - 'A' : *s2;
|
||||||
|
if (c1 != c2)
|
||||||
|
break;
|
||||||
|
if (c1 == '\0')
|
||||||
return (1);
|
return (1);
|
||||||
s1++, s2++;
|
s1++, s2++;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: keyboard.c,v 1.5 1998/07/12 05:59:00 mrg Exp $ */
|
/* $NetBSD: keyboard.c,v 1.6 1999/08/02 02:01:57 sommerfeld Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1980, 1992, 1993
|
* Copyright (c) 1980, 1992, 1993
|
||||||
@ -38,7 +38,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)keyboard.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)keyboard.c 8.1 (Berkeley) 6/6/93";
|
||||||
#endif
|
#endif
|
||||||
__RCSID("$NetBSD: keyboard.c,v 1.5 1998/07/12 05:59:00 mrg Exp $");
|
__RCSID("$NetBSD: keyboard.c,v 1.6 1999/08/02 02:01:57 sommerfeld Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -55,8 +55,8 @@ __RCSID("$NetBSD: keyboard.c,v 1.5 1998/07/12 05:59:00 mrg Exp $");
|
|||||||
int
|
int
|
||||||
keyboard()
|
keyboard()
|
||||||
{
|
{
|
||||||
char ch, *line;
|
char ch, rch, *line;
|
||||||
int linesz;
|
int i, linesz;
|
||||||
sigset_t set;
|
sigset_t set;
|
||||||
|
|
||||||
sigemptyset(&set);
|
sigemptyset(&set);
|
||||||
@ -79,6 +79,7 @@ keyboard()
|
|||||||
clearerr(stdin);
|
clearerr(stdin);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
rch = ch;
|
||||||
if (ch >= 'A' && ch <= 'Z')
|
if (ch >= 'A' && ch <= 'Z')
|
||||||
ch += 'a' - 'A';
|
ch += 'a' - 'A';
|
||||||
if (col == 0) {
|
if (col == 0) {
|
||||||
@ -124,15 +125,19 @@ keyboard()
|
|||||||
clrtoeol();
|
clrtoeol();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (isprint(ch) || ch == ' ') {
|
if (isprint(rch) || ch == ' ') {
|
||||||
if (col < linesz) {
|
if (col < linesz) {
|
||||||
line[col] = ch;
|
line[col] = rch;
|
||||||
mvaddch(CMDLINE, col, ch);
|
mvaddch(CMDLINE, col, rch);
|
||||||
col++;
|
col++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (col == 0 || (ch != '\r' && ch != '\n'));
|
} while (col == 0 || (ch != '\r' && ch != '\n'));
|
||||||
line[col] = '\0';
|
line[col] = '\0';
|
||||||
|
/* pass commands as lowercase */
|
||||||
|
for (i = 1; i < col && line[i] != ' '; i++)
|
||||||
|
if (line[i] >= 'A' && line[i] <= 'Z')
|
||||||
|
line[i] += 'a' - 'A';
|
||||||
sigprocmask(SIG_BLOCK, &set, NULL);
|
sigprocmask(SIG_BLOCK, &set, NULL);
|
||||||
command(line + 1);
|
command(line + 1);
|
||||||
sigprocmask(SIG_UNBLOCK, &set, NULL);
|
sigprocmask(SIG_UNBLOCK, &set, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user