Fix linewrapper when levels=NULL
This commit is contained in:
parent
eb67952309
commit
cacd173d3e
1 changed files with 23 additions and 22 deletions
|
@ -553,25 +553,24 @@ line_wrap (struct grub_unicode_glyph *visual_out,
|
||||||
struct grub_unicode_glyph *outptr = visual_out;
|
struct grub_unicode_glyph *outptr = visual_out;
|
||||||
unsigned line_start = 0;
|
unsigned line_start = 0;
|
||||||
grub_ssize_t line_width = startwidth;
|
grub_ssize_t line_width = startwidth;
|
||||||
|
unsigned k;
|
||||||
|
|
||||||
auto void revert (unsigned start, unsigned end);
|
auto void revert (unsigned start, unsigned end);
|
||||||
void revert (unsigned start, unsigned end)
|
void revert (unsigned start, unsigned end)
|
||||||
{
|
{
|
||||||
struct grub_unicode_glyph t;
|
struct grub_unicode_glyph t;
|
||||||
unsigned k, tl;
|
unsigned i, tl;
|
||||||
for (k = 0; k <= (end - start) / 2; k++)
|
for (i = 0; i <= (end - start) / 2; i++)
|
||||||
{
|
{
|
||||||
t = visual[start + k];
|
t = visual[start + i];
|
||||||
visual[start + k] = visual[end - k];
|
visual[start + i] = visual[end - i];
|
||||||
visual[end - k] = t;
|
visual[end - i] = t;
|
||||||
tl = levels[start + k];
|
tl = levels[start + i];
|
||||||
levels[start + k] = levels[end - k];
|
levels[start + i] = levels[end - i];
|
||||||
levels[end - k] = tl;
|
levels[end - i] = tl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned k;
|
|
||||||
|
|
||||||
if (!visual_len)
|
if (!visual_len)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -582,10 +581,14 @@ line_wrap (struct grub_unicode_glyph *visual_out,
|
||||||
line_width += last_width = getcharwidth (&visual[k]);
|
line_width += last_width = getcharwidth (&visual[k]);
|
||||||
if (((grub_ssize_t) maxwidth > 0
|
if (((grub_ssize_t) maxwidth > 0
|
||||||
&& line_width > (grub_ssize_t) maxwidth) || k == visual_len)
|
&& line_width > (grub_ssize_t) maxwidth) || k == visual_len)
|
||||||
|
{
|
||||||
|
if (levels)
|
||||||
{
|
{
|
||||||
unsigned min_odd_level = 0xffffffff;
|
unsigned min_odd_level = 0xffffffff;
|
||||||
unsigned max_level = 0;
|
unsigned max_level = 0;
|
||||||
unsigned i, j;
|
unsigned j;
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
for (i = line_start; i < k; i++)
|
for (i = line_start; i < k; i++)
|
||||||
{
|
{
|
||||||
if (levels[i] > max_level)
|
if (levels[i] > max_level)
|
||||||
|
@ -594,8 +597,6 @@ line_wrap (struct grub_unicode_glyph *visual_out,
|
||||||
min_odd_level = levels[i];
|
min_odd_level = levels[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (levels)
|
|
||||||
{
|
|
||||||
/* FIXME: can be optimized. */
|
/* FIXME: can be optimized. */
|
||||||
for (j = max_level; j >= min_odd_level; j--)
|
for (j = max_level; j >= min_odd_level; j--)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue