From 476ce37019df5b1cb917c5b50e71f9bce5911401 Mon Sep 17 00:00:00 2001 From: Алексей Шилин Date: Wed, 29 Jan 2014 01:23:46 +0000 Subject: 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 --- tests/misc/head-elide-tail.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests') 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; -- cgit v1.2.3-54-g00ecf