]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
rev: stop adding new line at the end when input does not have it
authorSami Kerola <kerolasa@iki.fi>
Sun, 2 Jun 2013 17:51:16 +0000 (18:51 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 7 Jun 2013 10:24:46 +0000 (12:24 +0200)
When the rev(1) is executed twice outcome is expected to be exactly what
it was originally.  That includes not adding new line at the end of the
output.  The oneliner below demonstrates earlier issue.

$ printf "abc\n123" | rev | rev

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
tests/expected/misc/rev
tests/ts/misc/rev
text-utils/rev.c

index 263923f757e4be724df405f21aacd3bbb8cb0818..41fdf4c13f0f6b0cffb7529f9b40490ed544dea3 100644 (file)
@@ -1,2 +1,4 @@
 53bbf0d98205319cee2ba589e205c68b  -
-b407c257ed73b43cb992e778f925f7a3  -
+35484965b7a2fd45a471c0d80cb9752c  -
+cba
+321
\ No newline at end of file
index f36a799b22ecd0b4323affc5b0aefe0249416301..035ce8230e35bf41a09712857b805b585693ef29 100755 (executable)
@@ -23,4 +23,6 @@ for I in {0..512}; do printf "%s " {a..z}; done | md5sum >> $TS_OUTPUT 2>&1
 for I in {0..512}; do printf "%s " {a..z}; done | \
                                    $TS_CMD_REV | md5sum >> $TS_OUTPUT 2>&1
 
+printf "abc\n123" | $TS_CMD_REV >> $TS_OUTPUT 2>&1
+
 ts_finalize
index 95545064a616a97b24ac87771a0e1d6129fee4ff..0456c2b144c63f309ab37c4fe9085e17d5b5fef3 100644 (file)
@@ -159,7 +159,8 @@ int main(int argc, char *argv[])
                                if (*t != 0)
                                        putwchar(*t);
                        }
-                       putwchar('\n');
+                       if (!feof(fp))
+                               putwchar('\n');
                }
 
                fflush(fp);