From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH] wall: wrap message header when it exceeds 79 characters
Date: Sun, 27 Jul 2014 20:01:06 +0100 [thread overview]
Message-ID: <1406487666-19466-1-git-send-email-kerolasa@iki.fi> (raw)
Header truncation started to happen more often after commit
d81c30553f4fb49173d38f69edff4b0b67a18b65 that made the header to be
longer.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
term-utils/wall.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/term-utils/wall.c b/term-utils/wall.c
index 598e9f2..acada29 100644
--- a/term-utils/wall.c
+++ b/term-utils/wall.c
@@ -202,6 +202,8 @@ static char *makemsg(char *fname, char **mvec, int mvecsz,
char *whom, *where, *date;
struct passwd *pw;
time_t now;
+ ssize_t len;
+ int i;
if (!(whom = getlogin()) || !*whom)
whom = (pw = getpwuid(getuid())) ? pw->pw_name : "???";
@@ -232,7 +234,10 @@ static char *makemsg(char *fname, char **mvec, int mvecsz,
fprintf(fp, "\r%*s\r\n", TERM_WIDTH, " ");
sprintf(lbuf, _("Broadcast message from %s@%s (%s) (%s):"),
whom, hostname, where, date);
- fprintf(fp, "%-*.*s\007\007\r\n", TERM_WIDTH, TERM_WIDTH, lbuf);
+ len = strlen(lbuf);
+ for (i = 0; 0 < len; i++)
+ len -= fprintf(fp, "%-*.*s\007\007\r\n", TERM_WIDTH, TERM_WIDTH,
+ lbuf + (i * TERM_WIDTH)) + 4;
free(hostname);
free(date);
}
--
2.0.3
next reply other threads:[~2014-07-27 19:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-27 19:01 Sami Kerola [this message]
2014-07-29 7:44 ` [PATCH] wall: wrap message header when it exceeds 79 characters Karel Zak
2014-07-29 8:27 ` Sami Kerola
2014-07-29 16:00 ` Dale R. Worley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1406487666-19466-1-git-send-email-kerolasa@iki.fi \
--to=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox