From fc092135ab7ccebbc46b397659dd0b6a50267ead Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Tue, 8 Apr 1997 13:52:53 +0000 Subject: Fix 8bit chars handling --- usr.bin/wall/wall.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'usr.bin/wall') diff --git a/usr.bin/wall/wall.c b/usr.bin/wall/wall.c index 8bef548d2c6fd..4351888c9c4f8 100644 --- a/usr.bin/wall/wall.c +++ b/usr.bin/wall/wall.c @@ -124,7 +124,8 @@ void makemsg(fname) char *fname; { - register int ch, cnt; + register int cnt; + register unsigned char ch; struct tm *lt; struct passwd *pw; struct stat sbuf; @@ -172,13 +173,21 @@ makemsg(fname) } while (fgets(lbuf, sizeof(lbuf), stdin)) for (cnt = 0, p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) { + again: if (cnt == 79 || ch == '\n') { for (; cnt < 79; ++cnt) putc(' ', fp); putc('\r', fp); putc('\n', fp); cnt = 0; - } else if (!isprint(ch) && !isspace(ch) && ch != '\007') { + } else if ( !isprint(ch) && !isspace(ch) + && ch != '\007' && ch != '\010' + ) { + if (ch & 0x80) { + ch &= 0x7F; + (void)fprintf(fp, "M-"); + goto again; + } putc('^', fp); putc(ch^0x40, fp); /* DEL to ?, others to alpha */ } else -- cgit v1.3