From e8cc63c3bb3b5dc1015abf84a6b9eee2453f6898 Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 30 Oct 1994 04:05:50 +0000 Subject: More 8bit/ctype fixes, command mode --- usr.bin/window/scanner.c | 45 +++++++++++---------------------------------- usr.bin/window/ww.h | 2 +- usr.bin/window/wwgets.c | 7 +++++-- usr.bin/window/wwlabel.c | 12 ++++++++++-- 4 files changed, 27 insertions(+), 39 deletions(-) diff --git a/usr.bin/window/scanner.c b/usr.bin/window/scanner.c index d10719c..9bf691b 100644 --- a/usr.bin/window/scanner.c +++ b/usr.bin/window/scanner.c @@ -38,6 +38,7 @@ static char sccsid[] = "@(#)scanner.c 8.1 (Berkeley) 6/6/93"; #endif /* not lint */ +#include #include "value.h" #include "token.h" #include "context.h" @@ -110,22 +111,6 @@ loop: cx.x_token = T_EOF; state = -1; break; - case 'a': case 'b': case 'c': case 'd': case 'e': - case 'f': case 'g': case 'h': case 'i': case 'j': - case 'k': case 'l': case 'm': case 'n': case 'o': - case 'p': case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': case 'y': - case 'z': - case 'A': case 'B': case 'C': case 'D': case 'E': - case 'F': case 'G': case 'H': case 'I': case 'J': - case 'K': case 'L': case 'M': case 'N': case 'O': - case 'P': case 'Q': case 'R': case 'S': case 'T': - case 'U': case 'V': case 'W': case 'X': case 'Y': - case 'Z': - case '_': case '.': - *p++ = c; - state = 2; - break; case '"': state = 3; break; @@ -231,6 +216,11 @@ loop: state = -1; break; default: + if (isalpha(c) || c == '_' || c == '.') { + *p++ = c; + state = 2; + break; + } cx.x_val.v_num = c; cx.x_token = T_CHAR; state = -1; @@ -245,24 +235,6 @@ loop: break; case 2: /* unquoted string */ switch (c) { - case 'a': case 'b': case 'c': case 'd': case 'e': - case 'f': case 'g': case 'h': case 'i': case 'j': - case 'k': case 'l': case 'm': case 'n': case 'o': - case 'p': case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': case 'y': - case 'z': - case 'A': case 'B': case 'C': case 'D': case 'E': - case 'F': case 'G': case 'H': case 'I': case 'J': - case 'K': case 'L': case 'M': case 'N': case 'O': - case 'P': case 'Q': case 'R': case 'S': case 'T': - case 'U': case 'V': case 'W': case 'X': case 'Y': - case 'Z': - case '_': case '.': - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - if (p < buf + sizeof buf - 1) - *p++ = c; - break; case '"': state = 3; break; @@ -281,6 +253,11 @@ loop: } break; default: + if (isalnum(c) || c == '_' || c == '.') { + if (p < buf + sizeof buf - 1) + *p++ = c; + break; + } (void) s_ungetc(c); case EOF: *p = 0; diff --git a/usr.bin/window/ww.h b/usr.bin/window/ww.h index 9241492..1f65484 100644 --- a/usr.bin/window/ww.h +++ b/usr.bin/window/ww.h @@ -258,7 +258,7 @@ char *wwib; /* input (keyboard) buffer */ char *wwibe; /* wwib + sizeof buffer */ char *wwibp; /* current read position in buffer */ char *wwibq; /* current write position in buffer */ -#define wwmaskc(c) ((c) & 0x7f) +#define wwmaskc(c) ((c) & 0xff) #define wwgetc() (wwibp < wwibq ? wwmaskc(*wwibp++) : -1) #define wwpeekc() (wwibp < wwibq ? wwmaskc(*wwibp) : -1) #define wwungetc(c) (wwibp > wwib ? *--wwibp = (c) : -1) diff --git a/usr.bin/window/wwgets.c b/usr.bin/window/wwgets.c index 1141834..a7223b7 100644 --- a/usr.bin/window/wwgets.c +++ b/usr.bin/window/wwgets.c @@ -91,7 +91,10 @@ register struct ww *w; if (p >= buf + n - 1) wwputc(ctrl('g'), w); else - wwputs(unctrl(*p++ = c), w); + if (isctrl(c)) + wwputs(unctrl(*p++ = c), w); + else + wwputc(*p++ = c, w); } } *p = 0; @@ -104,6 +107,6 @@ struct ww *w; { register i; - for (i = strlen(unctrl(c)); --i >= 0;) + for (i = isctrl(c) ? strlen(unctrl(c)) : 1; --i >= 0;) (void) wwwrite(w, "\b \b", 3); } diff --git a/usr.bin/window/wwlabel.c b/usr.bin/window/wwlabel.c index 4bb128f..d4cc99e 100644 --- a/usr.bin/window/wwlabel.c +++ b/usr.bin/window/wwlabel.c @@ -61,6 +61,7 @@ char *l; register char *smap; char touched; unsigned char *p; + static unsigned char cbuf[2]; if (f->ww_fmap == 0) return; @@ -78,8 +79,14 @@ char *l; jj = MIN(w->ww_i.r, f->ww_i.r); j = w->ww_i.l + where; - while (j < jj && *l) - for (p = unctrl(*l++); j < jj && *p; j++, p++) { + while (j < jj && *l) { + if (isctrl(*l)) + p = unctrl(*l); + else { + cbuf[0] = *l; + p = cbuf; + } + for (l++; j < jj && *p; j++, p++) { /* can't label if not already framed */ if (win[j] & WWM_GLS) continue; @@ -92,5 +99,6 @@ char *l; } fmap[j] |= WWF_LABEL; } + } wwtouched[row] = touched; } -- cgit v1.1