fold: don't putchar('\n') if last byte is '\n'

This commit is contained in:
Richard Ipsum 2020-10-09 15:52:09 +01:00 committed by Michael Forney
parent 0d42b4f3d1
commit db1dc984c3

3
fold.c
View File

@ -23,7 +23,8 @@ foldline(struct line *l) {
len = ((sflag && spacesect) ? spacesect : i) - last;
if (fwrite(l->data + last, 1, len, stdout) != len)
eprintf("fwrite <stdout>:");
putchar('\n');
if (l->data[i] != '\n')
putchar('\n');
last = (sflag && spacesect) ? spacesect : i;
col = 0;
spacesect = 0;