Skip to content

Commit

Permalink
bsddialog: Fix off-by-one in upstream's minibarlen calculation
Browse files Browse the repository at this point in the history
The text in the [...] is 14 characters long, but that includes the
terminator that isn't rendered, so there are only 13 visible characters
(plus the square brackets).
  • Loading branch information
jrtc27 committed Jul 19, 2024
1 parent 2283ee3 commit b2ad856
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contrib/bsddialog/lib/barbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ do_mixedgauge(struct bsddialog_conf *conf, const char *text, int rows, int cols,
for (i = 0; i < (int)nminibars; i++)
max_minibarlen = MAX(max_minibarlen,
(int)strcols(CHECK_STR(minilabels[i])));
max_minibarlen += 3 + 16; /* seps + [...] */
max_minibarlen += 3 + 15; /* seps + [...] */
max_minibarlen = MAX(max_minibarlen, MIN_WMGBOX); /* mainbar */

if (prepare_dialog(conf, text, rows, cols, &d) != 0)
Expand All @@ -247,7 +247,7 @@ do_mixedgauge(struct bsddialog_conf *conf, const char *text, int rows, int cols,
hnotext = maxh;
}
if (maxw < max_minibarlen) {
label_len_cap = maxw - (3 + 16); /* seps + [...] */
label_len_cap = maxw - (3 + 15); /* seps + [...] */
max_minibarlen = maxw;
}
}
Expand Down

0 comments on commit b2ad856

Please sign in to comment.