diff options
author | Алексей Шилин <rootlexx@mail.ru> | 2014-01-29 01:23:46 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2014-02-09 20:22:33 +0000 |
commit | 476ce37019df5b1cb917c5b50e71f9bce5911401 (patch) | |
tree | 7e207caa284a827d176567e521222ddda21098d6 /tests | |
parent | 17d92a9106c6d07cc985e6e14f5501dec3db57f2 (diff) | |
download | coreutils-476ce37019df5b1cb917c5b50e71f9bce5911401.tar.xz |
head: fix --lines=-0 outputting nothing if no newline at EOF
* src/head.c (elide_tail_lines_pipe): Just output all input in
this case to avoid the issue and also avoid redundant '\n' processing.
(elide_tail_lines_seekable): Likewise.
* tests/misc/head-elide-tail.pl: Add tests for no '\n' at EOF.
* NEWS: Mention the fix.
Fixes http://bugs.gnu.org/16329
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/misc/head-elide-tail.pl | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/misc/head-elide-tail.pl b/tests/misc/head-elide-tail.pl index 758e1c9d0..3c178d695 100755 --- a/tests/misc/head-elide-tail.pl +++ b/tests/misc/head-elide-tail.pl @@ -52,6 +52,8 @@ my @Tests = ['elide-l2', "--lines=-1", {IN=>"a"}, {OUT=>''}], ['elide-l3', "--lines=-1", {IN=>"a\nb"}, {OUT=>"a\n"}], ['elide-l4', "--lines=-1", {IN=>"a\nb\n"}, {OUT=>"a\n"}], + ['elide-l5', "--lines=-0", {IN=>"a\nb\n"}, {OUT=>"a\nb\n"}], + ['elide-l6', "--lines=-0", {IN=>"a\nb"}, {OUT=>"a\nb"}], ); if ($ENV{RUN_EXPENSIVE_TESTS}) @@ -80,9 +82,10 @@ if ($ENV{RUN_EXPENSIVE_TESTS}) } $s =~ s/(.)/$1\n/g; - for my $file_size (0..20) + $s .= 'u'; # test without trailing '\n' + for my $file_size (0..21) { - for my $n_elide (0..20) + for my $n_elide (0..21) { my $input = substr $s, 0, 2 * $file_size; my $out_len = $n_elide < $file_size ? $file_size - $n_elide : 0; |