From ec912c3bf6a774b643b3d43a01caaf0db5ae0258 Mon Sep 17 00:00:00 2001 From: bluhm Date: Thu, 5 May 2022 10:04:24 +0000 Subject: [PATCH] Fix line wrapping in wall(1). from Anton Borowka; OK mbuhl@ --- usr.bin/wall/wall.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.bin/wall/wall.c b/usr.bin/wall/wall.c index 30fcecea645..3fe0f11f0c2 100644 --- a/usr.bin/wall/wall.c +++ b/usr.bin/wall/wall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wall.c,v 1.35 2021/07/12 15:09:20 beck Exp $ */ +/* $OpenBSD: wall.c,v 1.36 2022/05/05 10:04:24 bluhm Exp $ */ /* $NetBSD: wall.c,v 1.6 1994/11/17 07:17:58 jtc Exp $ */ /* @@ -229,14 +229,17 @@ makemsg(char *fname) err(1, "can't read %s", fname); setegid(egid); } + cnt = 0; while (fgets(lbuf, sizeof(lbuf), stdin)) - for (cnt = 0, p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) { + for (p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) { if (cnt == 79 || ch == '\n') { for (; cnt < 79; ++cnt) putc(' ', fp); putc('\r', fp); putc('\n', fp); cnt = -1; + if (ch != '\n') + p--; } else if (!isu8cont(ch)) putc(isprint(ch) || isspace(ch) || ch == '\a' ? ch : '?', fp); -- 2.20.1