From e5257d48d7851a1e5d3a4fc99359d47e213c7a8d Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 4 Sep 2012 10:42:09 -0400 Subject: [PATCH] Print a trailing newline in lbuf_print() when there is not enough space to do word wrapping and the lbuf does not end with a newline. --- common/lbuf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/lbuf.c b/common/lbuf.c index 4618b94b5..3b20323fc 100644 --- a/common/lbuf.c +++ b/common/lbuf.c @@ -247,8 +247,12 @@ lbuf_print(struct lbuf *lbuf) /* For very small widths just give up... */ len = lbuf->continuation ? strlen(lbuf->continuation) : 0; if (lbuf->cols <= lbuf->indent + len + 20) { - lbuf->buf[lbuf->len] = '\0'; - lbuf->output(lbuf->buf); + if (lbuf->len > 0) { + lbuf->buf[lbuf->len] = '\0'; + lbuf->output(lbuf->buf); + if (lbuf->buf[lbuf->len - 1] != '\n') + lbuf->output("\n"); + } goto done; }