From 843b8a4b9817d4d7d59f279ca2e74d2ae374fc78 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 13 Nov 2022 00:06:49 +0100 Subject: [PATCH] crop limits beyond available lines Silence warnings about unitialized values. --- barcat | 4 ++-- t/t1514-limit_beyond_end.in | 1 + t/t1514-limit_beyond_end_-L-5.out | 0 3 files changed, 3 insertions(+), 2 deletions(-) create mode 120000 t/t1514-limit_beyond_end.in create mode 100644 t/t1514-limit_beyond_end_-L-5.out diff --git a/barcat b/barcat index b65271e..35ef3b3 100755 --- a/barcat +++ b/barcat @@ -194,7 +194,7 @@ sub color { sub show_lines { state $nr = - $opt{hidemin} < 0 ? @lines + $opt{hidemin} + 1 : + $opt{hidemin} < 0 ? max(0, @lines + $opt{hidemin} + 1) : $opt{hidemin}; @lines > $nr or return; @@ -203,7 +203,7 @@ if (defined $opt{hidemax}) { if ($opt{hidemin} and $opt{hidemin} < 0) { $limit -= $opt{hidemax} - 1; } - else { + elsif ($opt{hidemax} <= $limit) { $limit = $opt{hidemax} - 1; } } diff --git a/t/t1514-limit_beyond_end.in b/t/t1514-limit_beyond_end.in new file mode 120000 index 0000000..02f1de9 --- /dev/null +++ b/t/t1514-limit_beyond_end.in @@ -0,0 +1 @@ +t1700-empty_input.in \ No newline at end of file diff --git a/t/t1514-limit_beyond_end_-L-5.out b/t/t1514-limit_beyond_end_-L-5.out new file mode 100644 index 0000000..e69de29 -- 2.30.0