Do unctrl in right way

Handle '\377' properly
This commit is contained in:
Andrey A. Chernov 1995-11-05 09:02:10 +00:00
parent 0efc3a394d
commit dbc57b8da7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=12097

View File

@ -301,7 +301,7 @@ done()
* turns \n into \r\n * turns \n into \r\n
*/ */
wr_fputs(s) wr_fputs(s)
register char *s; register unsigned char *s;
{ {
#define PUTC(c) if (putchar(c) == EOF) goto err; #define PUTC(c) if (putchar(c) == EOF) goto err;
@ -309,12 +309,18 @@ wr_fputs(s)
for (; *s != '\0'; ++s) { for (; *s != '\0'; ++s) {
if (*s == '\n') { if (*s == '\n') {
PUTC('\r'); PUTC('\r');
PUTC('\n');
} else if (!isprint(*s) && !isspace(*s) && *s != '\007') { } else if (!isprint(*s) && !isspace(*s) && *s != '\007') {
PUTC('^'); if (*s & 0x80) {
PUTC((*s^0x40)&~0x80); /* DEL to ?, others to alpha */ *s &= ~0x80;
} else PUTC('M');
PUTC(*s); PUTC('-');
}
if (iscntrl(*s)) {
*s ^= 0x40;
PUTC('^');
}
}
PUTC(*s);
} }
return; return;