-/* $OpenBSD: tty.c,v 1.170 2021/10/24 00:02:25 jsg Exp $ */
+/* $OpenBSD: tty.c,v 1.171 2021/12/02 15:13:49 deraadt Exp $ */
/* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */
/*-
{
u_char *cp;
int savecol;
- int tabc, s;
+ int tabc, s, cc;
if (!ISSET(tp->t_lflag, ECHO) || ISSET(tp->t_lflag, EXTPROC))
return 0;
SET(tp->t_state, TS_CNTTB);
SET(tp->t_lflag, FLUSHO);
tp->t_column = tp->t_rocol;
- for (cp = firstc(&tp->t_rawq, &tabc); cp;
- cp = nextc(&tp->t_rawq, cp, &tabc))
+ for (cp = firstc(&tp->t_rawq, &tabc, &cc); cp;
+ cp = nextc(&tp->t_rawq, cp, &tabc, &cc))
ttyecho(tabc, tp);
CLR(tp->t_lflag, FLUSHO);
CLR(tp->t_state, TS_CNTTB);
ttyretype(struct tty *tp)
{
u_char *cp;
- int s, c;
+ int s, c, cc;
/* Echo the reprint character. */
if (tp->t_cc[VREPRINT] != _POSIX_VDISABLE)
(void)ttyoutput('\n', tp);
s = spltty();
- for (cp = firstc(&tp->t_canq, &c); cp; cp = nextc(&tp->t_canq, cp, &c))
+ for (cp = firstc(&tp->t_canq, &c, &cc); cp;
+ cp = nextc(&tp->t_canq, cp, &c, &cc))
ttyecho(c, tp);
- for (cp = firstc(&tp->t_rawq, &c); cp; cp = nextc(&tp->t_rawq, cp, &c))
+ for (cp = firstc(&tp->t_rawq, &c, &cc); cp;
+ cp = nextc(&tp->t_rawq, cp, &c, &cc))
ttyecho(c, tp);
CLR(tp->t_state, TS_ERASE);
splx(s);
-/* $OpenBSD: tty_subr.c,v 1.34 2021/12/01 17:04:26 deraadt Exp $ */
+/* $OpenBSD: tty_subr.c,v 1.35 2021/12/02 15:13:49 deraadt Exp $ */
/* $NetBSD: tty_subr.c,v 1.13 1996/02/09 19:00:43 christos Exp $ */
/*
return count;
}
-static int cc;
-
/*
* Given a non-NULL pointer into the clist return the pointer
* to the next character in the list or return NULL if no more chars.
* masked.
*/
u_char *
-nextc(struct clist *clp, u_char *cp, int *c)
+nextc(struct clist *clp, u_char *cp, int *c, int *ccp)
{
if (clp->c_cf == cp) {
/*
* First time initialization.
*/
- cc = clp->c_cc;
+ *ccp = clp->c_cc;
}
- if (cc == 0 || cp == NULL)
+ if (*ccp == 0 || cp == NULL)
return NULL;
- if (--cc == 0)
+ if (--(*ccp) == 0)
return NULL;
if (++cp == clp->c_ce)
cp = clp->c_cs;
* *c is set to the NEXT character
*/
u_char *
-firstc(struct clist *clp, int *c)
+firstc(struct clist *clp, int *c, int *ccp)
{
u_char *cp;
- cc = clp->c_cc;
- if (cc == 0)
+ *ccp = clp->c_cc;
+ if (*ccp == 0)
return NULL;
cp = clp->c_cf;
*c = *cp & 0xff;
-/* $OpenBSD: tty.h,v 1.39 2020/07/14 14:33:06 deraadt Exp $ */
+/* $OpenBSD: tty.h,v 1.40 2021/12/02 15:13:49 deraadt Exp $ */
/* $NetBSD: tty.h,v 1.30.4.1 1996/06/02 09:08:13 mrg Exp $ */
/*-
int getc(struct clist *q);
void ndflush(struct clist *q, int cc);
int ndqb(struct clist *q, int flag);
-u_char *nextc(struct clist *q, u_char *cp, int *c);
+u_char *firstc(struct clist *clp, int *c, int *cc);
+u_char *nextc(struct clist *q, u_char *cp, int *c, int *cc);
int putc(int c, struct clist *q);
int q_to_b(struct clist *q, u_char *cp, int cc);
int unputc(struct clist *q);
void tty_init(void);
struct tty *ttymalloc(int);
void ttyfree(struct tty *);
-u_char *firstc(struct clist *clp, int *c);
int cttyopen(dev_t, int, int, struct proc *);
int cttyread(dev_t, struct uio *, int);