commit db1dc984c3c4b492d9b3e20fbed30d06100d084a
Author:     Richard Ipsum <[email protected]>
AuthorDate: Fri Oct 9 15:52:09 2020 +0100
Commit:     Michael Forney <[email protected]>
CommitDate: Wed Oct 14 15:03:20 2020 -0700

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

diff --git a/fold.c b/fold.c
index dfce7c8..0d68b37 100644
--- a/fold.c
+++ b/fold.c
@@ -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;

Reply via email to