From: Mischa POSLAWSKY Date: Sat, 12 Nov 2022 23:06:49 +0000 (+0100) Subject: crop limits beyond available lines X-Git-Tag: v1.09~29 X-Git-Url: http://git.shiar.nl/barcat.git/commitdiff_plain/843b8a4b9817d4d7d59f279ca2e74d2ae374fc78 crop limits beyond available lines Silence warnings about unitialized values. --- 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