Skip to content

Commit

Permalink
fix for -t truncate mode
Browse files Browse the repository at this point in the history
A previous change caused truncate mode to show all lines,
not just the first N
  • Loading branch information
codekitchen committed Feb 21, 2020
1 parent 63c4144 commit 9909fd3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ void read_show_output(FILE *s, size_t *count, size_t *shown, size_t *total) {
termput0("cd");
int lines_left = s_lines - 2;
for (;;) {
ssize_t display_len =
read_line(s, truncate_lines ? s_cols : s_cols * lines_left);
size_t max_display_len;
if (truncate_lines)
max_display_len = lines_left > 0 ? s_cols : 0;
else
max_display_len = s_cols * lines_left;
ssize_t display_len = read_line(s, max_display_len);
if (display_len < 0)
break;
*total += 1;
Expand Down

0 comments on commit 9909fd3

Please sign in to comment.