menu: fix line count calculation for long lines

It gave one extra screen line if length was exactly equal to screen
width.

Reported by Michael Chang.
Also-By: Michael Chang <mchang@suse.com>
This commit is contained in:
Andrei Borzenkov 2015-12-30 06:20:51 +03:00
parent dbab354157
commit 93ecc3f1f8

View file

@ -126,9 +126,13 @@ ensure_space (struct line *linep, int extra)
static int
get_logical_num_lines (struct line *linep, struct per_term_screen *term_screen)
{
return (grub_getstringwidth (linep->buf, linep->buf + linep->len,
term_screen->term)
/ (unsigned) term_screen->geo.entry_width) + 1;
grub_size_t width = grub_getstringwidth (linep->buf, linep->buf + linep->len,
term_screen->term);
/* Empty line still consumes space on screen */
return width ? (width + (unsigned) term_screen->geo.entry_width - 1) /
(unsigned) term_screen->geo.entry_width
: 1;
}
static void