make check cleaner, and simplify the code.

This commit is contained in:
christos 2018-01-21 01:18:48 +00:00
parent 25b3b2dc56
commit 7501cd820d
1 changed files with 36 additions and 52 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsemul_vt100.c,v 1.42 2018/01/20 23:27:06 rin Exp $ */
/* $NetBSD: wsemul_vt100.c,v 1.43 2018/01/21 01:18:48 christos Exp $ */
/*
* Copyright (c) 1998
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100.c,v 1.42 2018/01/20 23:27:06 rin Exp $");
__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100.c,v 1.43 2018/01/21 01:18:48 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_wsmsgattrs.h"
@ -230,7 +230,7 @@ wsemul_vt100_cnattach(const struct wsscreen_descr *type, void *cookie,
edp->isolatin1tab = edp->decgraphtab = edp->dectechtab = 0;
edp->nrctab = 0;
wsemul_vt100_reset(edp);
return (edp);
return edp;
}
void *
@ -263,7 +263,7 @@ wsemul_vt100_attach(int console, const struct wsscreen_descr *type,
edp->nrctab = malloc(128 * sizeof(int), M_DEVBUF, M_NOWAIT);
vt100_initchartables(edp);
wsemul_vt100_reset(edp);
return (edp);
return edp;
}
void
@ -461,7 +461,7 @@ wsemul_vt100_output_c0c1(struct wsemul_vt100_emuldata *edp, u_char c,
break;
case ASCII_ESC:
if (kernel) {
printf("wsemul_vt100_output_c0c1: ESC in kernel output ignored\n");
printf("%s: ESC in kernel output ignored\n", __func__);
break; /* ignore the ESC */
}
@ -490,7 +490,8 @@ wsemul_vt100_output_c0c1(struct wsemul_vt100_emuldata *edp, u_char c,
case ST: /* string end 8-bit */
/* XXX only in VT100_EMUL_STATE_STRING */
wsemul_vt100_handle_dcs(edp);
return (VT100_EMUL_STATE_NORMAL);
edp->state = VT100_EMUL_STATE_NORMAL;
break;
#endif
case ASCII_LF:
case ASCII_VT:
@ -504,7 +505,6 @@ static u_int
wsemul_vt100_output_esc(struct wsemul_vt100_emuldata *edp, u_char c)
{
struct vt100base_data *vd = &edp->bd;
u_int newstate = VT100_EMUL_STATE_NORMAL;
int i;
switch (c) {
@ -512,8 +512,7 @@ wsemul_vt100_output_esc(struct wsemul_vt100_emuldata *edp, u_char c)
vd->nargs = 0;
memset(vd->args, 0, sizeof (vd->args));
vd->modif1 = vd->modif2 = '\0';
newstate = VT100_EMUL_STATE_CSI;
break;
return VT100_EMUL_STATE_CSI;
case '7': /* DECSC */
vd->flags |= VTFL_SAVEDCURS;
edp->savedcursor_row = vd->crow;
@ -591,8 +590,7 @@ wsemul_vt100_output_esc(struct wsemul_vt100_emuldata *edp, u_char c)
case 'P': /* DCS */
vd->nargs = 0;
memset(vd->args, 0, sizeof (vd->args));
newstate = VT100_EMUL_STATE_DCS;
break;
return VT100_EMUL_STATE_DCS;
case 'c': /* RIS */
wsemul_vt100_reset(edp);
wsemul_vt100_ed(vd, 2);
@ -600,24 +598,19 @@ wsemul_vt100_output_esc(struct wsemul_vt100_emuldata *edp, u_char c)
break;
case '(': case ')': case '*': case '+': /* SCS */
edp->designating = c - '(';
newstate = VT100_EMUL_STATE_SCS94;
break;
return VT100_EMUL_STATE_SCS94;
case '-': case '.': case '/': /* SCS */
edp->designating = c - '-' + 1;
newstate = VT100_EMUL_STATE_SCS96;
break;
return VT100_EMUL_STATE_SCS96;
case '#':
newstate = VT100_EMUL_STATE_ESC_HASH;
break;
return VT100_EMUL_STATE_ESC_HASH;
case ' ': /* 7/8 bit */
newstate = VT100_EMUL_STATE_ESC_SPC;
break;
return VT100_EMUL_STATE_ESC_SPC;
case ']': /* OSC operating system command */
case '^': /* PM privacy message */
case '_': /* APC application program command */
/* ignored */
newstate = VT100_EMUL_STATE_STRING;
break;
return VT100_EMUL_STATE_STRING;
case '<': /* exit VT52 mode - ignored */
break;
default:
@ -626,19 +619,15 @@ wsemul_vt100_output_esc(struct wsemul_vt100_emuldata *edp, u_char c)
#endif
break;
}
return (newstate);
return VT100_EMUL_STATE_NORMAL;
}
static u_int
wsemul_vt100_output_scs94(struct wsemul_vt100_emuldata *edp, u_char c)
{
u_int newstate = VT100_EMUL_STATE_NORMAL;
switch (c) {
case '%': /* probably DEC supplemental graphic */
newstate = VT100_EMUL_STATE_SCS94_PERCENT;
break;
return VT100_EMUL_STATE_SCS94_PERCENT;
case 'A': /* british / national */
edp->chartab_G[edp->designating] = edp->nrctab;
break;
@ -661,7 +650,7 @@ wsemul_vt100_output_scs94(struct wsemul_vt100_emuldata *edp, u_char c)
#endif
break;
}
return (newstate);
return VT100_EMUL_STATE_NORMAL;
}
static u_int
@ -678,19 +667,17 @@ wsemul_vt100_output_scs94_percent(struct wsemul_vt100_emuldata *edp, u_char c)
#endif
break;
}
return (VT100_EMUL_STATE_NORMAL);
return VT100_EMUL_STATE_NORMAL;
}
static u_int
wsemul_vt100_output_scs96(struct wsemul_vt100_emuldata *edp, u_char c)
{
u_int newstate = VT100_EMUL_STATE_NORMAL;
int nrc;
switch (c) {
case '%': /* probably portuguese */
newstate = VT100_EMUL_STATE_SCS96_PERCENT;
break;
return VT100_EMUL_STATE_SCS96_PERCENT;
case 'A': /* ISO-latin-1 supplemental */
edp->chartab_G[edp->designating] = edp->isolatin1tab;
break;
@ -732,7 +719,7 @@ setnrc:
#endif
break;
}
return (newstate);
return VT100_EMUL_STATE_NORMAL;
}
static u_int
@ -748,7 +735,7 @@ wsemul_vt100_output_scs96_percent(struct wsemul_vt100_emuldata *edp, u_char c)
#endif
break;
}
return (VT100_EMUL_STATE_NORMAL);
return VT100_EMUL_STATE_NORMAL;
}
static u_int
@ -768,7 +755,7 @@ wsemul_vt100_output_esc_spc(struct wsemul_vt100_emuldata *edp,
#endif
break;
}
return (VT100_EMUL_STATE_NORMAL);
return VT100_EMUL_STATE_NORMAL;
}
static u_int
@ -778,7 +765,7 @@ wsemul_vt100_output_string(struct wsemul_vt100_emuldata *edp, u_char c)
if (vd->dcstype && vd->dcspos < DCS_MAXLEN)
vd->dcsarg[vd->dcspos++] = c;
return (VT100_EMUL_STATE_STRING);
return VT100_EMUL_STATE_STRING;
}
static u_int
@ -788,16 +775,15 @@ wsemul_vt100_output_string_esc(struct wsemul_vt100_emuldata *edp, u_char c)
if (c == '\\') { /* ST complete */
wsemul_vt100_handle_dcs(vd);
return (VT100_EMUL_STATE_NORMAL);
return VT100_EMUL_STATE_NORMAL;
} else
return (VT100_EMUL_STATE_STRING);
return VT100_EMUL_STATE_STRING;
}
static u_int
wsemul_vt100_output_dcs(struct wsemul_vt100_emuldata *edp, u_char c)
{
struct vt100base_data *vd = &edp->bd;
u_int newstate = VT100_EMUL_STATE_DCS;
switch (c) {
case '0': case '1': case '2': case '3': case '4':
@ -822,8 +808,7 @@ wsemul_vt100_output_dcs(struct wsemul_vt100_emuldata *edp, u_char c)
newstate = VT100_EMUL_STATE_STRING;
switch (c) {
case '$':
newstate = VT100_EMUL_STATE_DCS_DOLLAR;
break;
return VT100_EMUL_STATE_DCS_DOLLAR;
case '{': /* DECDLD soft charset */
case '!': /* DECRQUPSS user preferred supplemental set */
/* 'u' must follow - need another state */
@ -840,7 +825,7 @@ wsemul_vt100_output_dcs(struct wsemul_vt100_emuldata *edp, u_char c)
}
}
return (newstate);
return VT100_EMUL_STATE_DCS;
}
static u_int
@ -881,7 +866,7 @@ wsemul_vt100_output_dcs_dollar(struct wsemul_vt100_emuldata *edp, u_char c)
#endif
break;
}
return (VT100_EMUL_STATE_STRING);
return VT100_EMUL_STATE_STRING;
}
static u_int
@ -937,14 +922,13 @@ wsemul_vt100_output_esc_hash(struct wsemul_vt100_emuldata *edp, u_char c)
#endif
break;
}
return (VT100_EMUL_STATE_NORMAL);
return VT100_EMUL_STATE_NORMAL;
}
static u_int
wsemul_vt100_output_csi(struct wsemul_vt100_emuldata *edp, u_char c)
{
struct vt100base_data *vd = &edp->bd;
u_int newstate = VT100_EMUL_STATE_CSI;
switch (c) {
case '0': case '1': case '2': case '3': case '4':
@ -977,10 +961,9 @@ wsemul_vt100_output_csi(struct wsemul_vt100_emuldata *edp, u_char c)
vd->nargs = VT100_EMUL_NARGS;
}
wsemul_vt100_handle_csi(vd, c);
newstate = VT100_EMUL_STATE_NORMAL;
break;
return VT100_EMUL_STATE_NORMAL;
}
return (newstate);
return VT100_EMUL_STATE_CSI;
}
void
@ -991,7 +974,7 @@ wsemul_vt100_output(void *cookie, const u_char *data, u_int count, int kernel)
#ifdef DIAGNOSTIC
if (kernel && !edp->console)
panic("wsemul_vt100_output: kernel output, not console");
panic("%s: kernel output, not console", __func__);
#endif
if (vd->flags & VTFL_CURSORON)
@ -1006,12 +989,13 @@ wsemul_vt100_output(void *cookie, const u_char *data, u_int count, int kernel)
wsemul_vt100_output_normal(edp, *data, kernel);
continue;
}
KASSERT(edp->state <= __arraycount(vt100_output));
edp->state = vt100_output[edp->state - 1](edp, *data);
int state = edp->state - 1;
KASSERT(state < __arraycount(vt100_output));
edp->state = vt100_output[state](edp, *data);
}
if (vd->flags & VTFL_CURSORON)
(*vd->emulops->cursor)(vd->emulcookie, 1,
vd->crow, vd->ccol << vd->dw);
vd->crow, vd->ccol << vd->dw);
}
#ifdef WSDISPLAY_CUSTOM_OUTPUT