- Fix more and more white space nits.

- ANSIfy the last K&R function definition in this file.
This commit is contained in:
enami 2002-05-02 13:38:57 +00:00
parent f5e9be2ba8
commit e54e7305a2

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty.c,v 1.137 2002/04/20 06:04:35 simonb Exp $ */
/* $NetBSD: tty.c,v 1.138 2002/05/02 13:38:57 enami Exp $ */
/*-
* Copyright (c) 1982, 1986, 1990, 1991, 1993
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.137 2002/04/20 06:04:35 simonb Exp $");
__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.138 2002/05/02 13:38:57 enami Exp $");
#include "opt_uconsole.h"
@ -117,20 +117,20 @@ const char ttyout[] = "ttyout";
char const char_type[] = {
E|CC, O|CC, O|CC, E|CC, O|CC, E|CC, E|CC, O|CC, /* nul - bel */
O|BS, E|TB, E|NL, O|CC, E|VT, O|CR, O|CC, E|CC, /* bs - si */
O|CC, E|CC, E|CC, O|CC, E|CC, O|CC, O|CC, E|CC, /* dle - etb */
E|CC, O|CC, O|CC, E|CC, O|CC, E|CC, E|CC, O|CC, /* can - us */
O|NO, E|NO, E|NO, O|NO, E|NO, O|NO, O|NO, E|NO, /* sp - ' */
E|NO, O|NO, O|NO, E|NO, O|NO, E|NO, E|NO, O|NO, /* ( - / */
E|NA, O|NA, O|NA, E|NA, O|NA, E|NA, E|NA, O|NA, /* 0 - 7 */
O|NA, E|NA, E|NO, O|NO, E|NO, O|NO, O|NO, E|NO, /* 8 - ? */
O|NO, E|NA, E|NA, O|NA, E|NA, O|NA, O|NA, E|NA, /* @ - G */
E|NA, O|NA, O|NA, E|NA, O|NA, E|NA, E|NA, O|NA, /* H - O */
E|NA, O|NA, O|NA, E|NA, O|NA, E|NA, E|NA, O|NA, /* P - W */
O|NA, E|NA, E|NA, O|NO, E|NO, O|NO, O|NO, O|NA, /* X - _ */
E|NO, O|NA, O|NA, E|NA, O|NA, E|NA, E|NA, O|NA, /* ` - g */
O|NA, E|NA, E|NA, O|NA, E|NA, O|NA, O|NA, E|NA, /* h - o */
O|NA, E|NA, E|NA, O|NA, E|NA, O|NA, O|NA, E|NA, /* p - w */
E|NA, O|NA, O|NA, E|NO, O|NO, E|NO, E|NO, O|CC, /* x - del */
O|CC, E|CC, E|CC, O|CC, E|CC, O|CC, O|CC, E|CC, /* dle - etb */
E|CC, O|CC, O|CC, E|CC, O|CC, E|CC, E|CC, O|CC, /* can - us */
O|NO, E|NO, E|NO, O|NO, E|NO, O|NO, O|NO, E|NO, /* sp - ' */
E|NO, O|NO, O|NO, E|NO, O|NO, E|NO, E|NO, O|NO, /* ( - / */
E|NA, O|NA, O|NA, E|NA, O|NA, E|NA, E|NA, O|NA, /* 0 - 7 */
O|NA, E|NA, E|NO, O|NO, E|NO, O|NO, O|NO, E|NO, /* 8 - ? */
O|NO, E|NA, E|NA, O|NA, E|NA, O|NA, O|NA, E|NA, /* @ - G */
E|NA, O|NA, O|NA, E|NA, O|NA, E|NA, E|NA, O|NA, /* H - O */
E|NA, O|NA, O|NA, E|NA, O|NA, E|NA, E|NA, O|NA, /* P - W */
O|NA, E|NA, E|NA, O|NO, E|NO, O|NO, O|NO, O|NA, /* X - _ */
E|NO, O|NA, O|NA, E|NA, O|NA, E|NA, E|NA, O|NA, /* ` - g */
O|NA, E|NA, E|NA, O|NA, E|NA, O|NA, O|NA, E|NA, /* h - o */
O|NA, E|NA, E|NA, O|NA, E|NA, O|NA, O|NA, E|NA, /* p - w */
E|NA, O|NA, O|NA, E|NO, O|NO, E|NO, E|NO, O|CC, /* x - del */
/*
* Meta chars; should be settable per character set;
* for now, treat them all as normal characters.
@ -202,8 +202,8 @@ ttyopen(struct tty *tp, int dialout, int nonblock)
* processes to close the tty first.
*/
while (ISSET(tp->t_state, TS_DIALOUT) ||
(!ISSET(tp->t_state, TS_CARR_ON) &&
!ISSET(tp->t_cflag, CLOCAL | MDMBUF))) {
(!ISSET(tp->t_state, TS_CARR_ON) &&
!ISSET(tp->t_cflag, CLOCAL | MDMBUF))) {
tp->t_wopen++;
error = ttysleep(tp, &tp->t_rawq,
TTIPRI | PCATCH, ttopen, 0);
@ -218,7 +218,7 @@ ttyopen(struct tty *tp, int dialout, int nonblock)
* Don't allow a non-blocking non-dialout open if the
* device is already open for dialout.
*/
if (ISSET(tp->t_state, TS_DIALOUT)) {
if (ISSET(tp->t_state, TS_DIALOUT)) {
splx(s);
return (EBUSY);
}
@ -340,11 +340,9 @@ ttyinput(int c, struct tty *tp)
ttyflush(tp, FREAD | FWRITE);
pgsignal(tp->t_pgrp, SIGINT, 1);
return (0);
}
else if (ISSET(iflag, PARMRK))
} else if (ISSET(iflag, PARMRK))
goto parmrk;
}
else if ((ISSET(error, TTY_PE) && ISSET(iflag, INPCK)) ||
} else if ((ISSET(error, TTY_PE) && ISSET(iflag, INPCK)) ||
ISSET(error, TTY_FE)) {
if (ISSET(iflag, IGNPAR))
return (0);
@ -353,12 +351,10 @@ ttyinput(int c, struct tty *tp)
(void)putc(0 | TTY_QUOTE, &tp->t_rawq);
(void)putc(c | TTY_QUOTE, &tp->t_rawq);
return (0);
}
else
} else
c = 0;
}
}
else if (c == 0377 &&
} else if (c == 0377 &&
ISSET(iflag, ISTRIP|IGNPAR|INPCK|PARMRK) == (INPCK|PARMRK)) {
/* "Escape" a valid character of '\377'. */
(void)putc(0377 | TTY_QUOTE, &tp->t_rawq);
@ -518,7 +514,7 @@ ttyinput(int c, struct tty *tp)
* erase whitespace
*/
while ((c = unputc(&tp->t_rawq)) == ' ' ||
c == '\t')
c == '\t')
ttyrub(c, tp);
if (c == -1)
goto endcase;
@ -544,7 +540,7 @@ ttyinput(int c, struct tty *tp)
if (c == -1)
goto endcase;
} while (c != ' ' && c != '\t' &&
(alt == 0 || ISALPHA(c) == ctype));
(alt == 0 || ISALPHA(c) == ctype));
(void)putc(c, &tp->t_rawq);
goto endcase;
}
@ -831,7 +827,7 @@ ttioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p)
*(int *)data = tp->t_linesw->l_no;
break;
case TIOCGLINED:
(void)strncpy((char *)data, tp->t_linesw->l_name,
(void)strncpy((char *)data, tp->t_linesw->l_name,
TTLINEDNAMELEN - 1);
break;
case TIOCGWINSZ: /* get window size */
@ -938,7 +934,7 @@ ttioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p)
dev_t device;
/* Null terminate to prevent buffer overflow */
name[TTLINEDNAMELEN - 1] = '\0';
name[TTLINEDNAMELEN - 1] = '\0';
lp = ttyldisc_lookup(name);
setldisc:
@ -989,7 +985,7 @@ ttioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p)
/* Session ctty vnode pointer set in vnode layer. */
if (!SESS_LEADER(p) ||
((p->p_session->s_ttyvp || tp->t_session) &&
(tp->t_session != p->p_session)))
(tp->t_session != p->p_session)))
return (EPERM);
SESSHOLD(p->p_session);
tp->t_session = p->p_session;
@ -1080,8 +1076,7 @@ ttnread(struct tty *tp)
* Wait for output to drain.
*/
int
ttywait(tp)
struct tty *tp;
ttywait(struct tty *tp)
{
int error, s;
@ -1241,7 +1236,8 @@ ttymodem(struct tty *tp, int flag)
CLR(tp->t_state, TS_CARR_ON);
if (ISSET(tp->t_state, TS_ISOPEN) && !CONNECTED(tp)) {
if (tp->t_session && tp->t_session->s_leader)
psignal(tp->t_session->s_leader, SIGHUP);
psignal(tp->t_session->s_leader,
SIGHUP);
ttyflush(tp, FREAD | FWRITE);
return (0);
}
@ -1452,7 +1448,7 @@ ttread(struct tty *tp, struct uio *uio, int flag)
pgsignal(tp->t_pgrp, SIGTSTP, 1);
if (first) {
error = ttysleep(tp, &lbolt,
TTIPRI | PCATCH, ttybg, 0);
TTIPRI | PCATCH, ttybg, 0);
if (error)
break;
goto loop;
@ -1485,7 +1481,7 @@ ttread(struct tty *tp, struct uio *uio, int flag)
* the input queue has gone down.
*/
s = spltty();
if (ISSET(tp->t_state, TS_TBLOCK) && tp->t_rawq.c_cc < TTYHOG/5) {
if (ISSET(tp->t_state, TS_TBLOCK) && tp->t_rawq.c_cc < TTYHOG / 5) {
if (ISSET(tp->t_iflag, IXOFF) &&
cc[VSTART] != _POSIX_VDISABLE &&
putc(cc[VSTART], &tp->t_outq) == 0) {
@ -1851,7 +1847,7 @@ ttyecho(int c, struct tty *tp)
ISSET(tp->t_lflag, EXTPROC))
return;
if (((ISSET(tp->t_lflag, ECHOCTL) &&
(ISSET(c, TTY_CHARMASK) <= 037 && c != '\t' && c != '\n')) ||
(ISSET(c, TTY_CHARMASK) <= 037 && c != '\t' && c != '\n')) ||
ISSET(c, TTY_CHARMASK) == 0177)) {
(void)ttyoutput('^', tp);
CLR(c, ~TTY_CHARMASK);
@ -1884,7 +1880,7 @@ int
ttspeedtab(int speed, struct speedtab *table)
{
for ( ; table->sp_speed != -1; table++)
for (; table->sp_speed != -1; table++)
if (table->sp_speed == speed)
return (table->sp_code);
return (-1);
@ -1997,10 +1993,10 @@ ttyinfo(struct tty *tp)
*/
#define ISRUN(p) (((p)->p_stat == SRUN) || ((p)->p_stat == SIDL) || \
((p)->p_stat == SONPROC))
#define TESTAB(a, b) ((a)<<1 | (b))
#define ONLYA 2
#define ONLYB 1
#define BOTH 3
#define TESTAB(a, b) ((a)<<1 | (b))
#define ONLYA 2
#define ONLYB 1
#define BOTH 3
static int
proc_compare(struct proc *p1, struct proc *p2)
@ -2035,7 +2031,7 @@ proc_compare(struct proc *p1, struct proc *p2)
case ONLYB:
return (0);
case BOTH:
return (p2->p_pid > p1->p_pid); /* tie - return highest pid */
return (p2->p_pid > p1->p_pid); /* tie - return highest pid */
}
/*
* pick the one with the smallest sleep time
@ -2100,6 +2096,7 @@ ttysleep(struct tty *tp, void *chan, int pri, const char *wmesg, int timo)
void
tty_init(void)
{
ttyldisc_init();
TAILQ_INIT(&ttylist);
@ -2163,7 +2160,7 @@ ttymalloc(void)
clalloc(&tp->t_outq, 1024, 0);
/* Set default line discipline. */
tp->t_linesw = linesw[0];
return(tp);
return (tp);
}
/*