summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2009-09-09 16:48:02 +0200
committerJim Meyering <meyering@redhat.com>2009-09-10 12:25:04 +0200
commit0bbb9d7785957437182fc633b2d387cc51ee918e (patch)
tree0d7c2962c911b153ab1c90c09e67ccbddc82f3d6 /src
parentf1e1e89e8166153852de1cc1777edb40dc4c08e9 (diff)
downloadcoreutils-0bbb9d7785957437182fc633b2d387cc51ee918e.tar.xz
dd conv=unblock: print final newline consistently
* src/dd.c (dd_copy) [C_UNBLOCK]: Always print the final newline for non-empty output, not just when output size is a multiple of cbs. * doc/coreutils.texi (dd invocation) [conv=unblock]: Mention that dd prints a newline after each output record, not just when replacing trailing spaces. Reported by Ulrich Drepper. * tests/dd/unblock: New file. Test for this. * tests/Makefile.am (TESTS): Add it. * NEWS (Bug fixes): Mention it.
Diffstat (limited to 'src')
-rw-r--r--src/dd.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/dd.c b/src/dd.c
index 04665f98f..76a31e981 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -1785,10 +1785,11 @@ dd_copy (void)
output_char (space_character);
}
- if ((conversions_mask & C_UNBLOCK) && col == conversion_blocksize)
- /* Add a final '\n' if there are exactly `conversion_blocksize'
- characters in the final record. */
- output_char (newline_character);
+ if (col && (conversions_mask & C_UNBLOCK))
+ {
+ /* If there was any output, add a final '\n'. */
+ output_char (newline_character);
+ }
/* Write out the last block. */
if (oc != 0)