summaryrefslogtreecommitdiffstats
path: root/usr.bin/write
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1995-11-05 09:02:10 +0000
committerache <ache@FreeBSD.org>1995-11-05 09:02:10 +0000
commitf139309c06a66d018ff8743b1fc7d87e90927a90 (patch)
tree001a634728fb53c43f7f40488434d4227929dd67 /usr.bin/write
parent27df45564a0a76bc96c2b6b0708bab9d5c7f0756 (diff)
downloadFreeBSD-src-f139309c06a66d018ff8743b1fc7d87e90927a90.zip
FreeBSD-src-f139309c06a66d018ff8743b1fc7d87e90927a90.tar.gz
Do unctrl in right way
Handle '\377' properly
Diffstat (limited to 'usr.bin/write')
-rw-r--r--usr.bin/write/write.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/usr.bin/write/write.c b/usr.bin/write/write.c
index 8bf8ab6..fdd4827 100644
--- a/usr.bin/write/write.c
+++ b/usr.bin/write/write.c
@@ -301,7 +301,7 @@ done()
* turns \n into \r\n
*/
wr_fputs(s)
- register char *s;
+ register unsigned char *s;
{
#define PUTC(c) if (putchar(c) == EOF) goto err;
@@ -309,12 +309,18 @@ wr_fputs(s)
for (; *s != '\0'; ++s) {
if (*s == '\n') {
PUTC('\r');
- PUTC('\n');
} else if (!isprint(*s) && !isspace(*s) && *s != '\007') {
- PUTC('^');
- PUTC((*s^0x40)&~0x80); /* DEL to ?, others to alpha */
- } else
- PUTC(*s);
+ if (*s & 0x80) {
+ *s &= ~0x80;
+ PUTC('M');
+ PUTC('-');
+ }
+ if (iscntrl(*s)) {
+ *s ^= 0x40;
+ PUTC('^');
+ }
+ }
+ PUTC(*s);
}
return;
OpenPOWER on IntegriCloud