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.
This commit is contained in:
Todd C. Miller
2012-09-04 10:42:09 -04:00
parent d787df3c1d
commit e5257d48d7

View File

@@ -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;
}