* grub-core/normal/charset.c (bidi_line_wrap): Eliminate nested
functions. (grub_bidi_line_logical_to_visual): Likewise.
This commit is contained in:
parent
ec0ebb3fc2
commit
c03995d297
2 changed files with 61 additions and 52 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/normal/charset.c (bidi_line_wrap): Eliminate nested
|
||||||
|
functions.
|
||||||
|
(grub_bidi_line_logical_to_visual): Likewise.
|
||||||
|
|
||||||
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Remove vestiges of -Wunsafe-loop-optimisations.
|
Remove vestiges of -Wunsafe-loop-optimisations.
|
||||||
|
|
|
@ -523,28 +523,11 @@ grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen,
|
||||||
return ptr - in;
|
return ptr - in;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_ssize_t
|
static void
|
||||||
bidi_line_wrap (struct grub_unicode_glyph *visual_out,
|
revert (struct grub_unicode_glyph *visual,
|
||||||
struct grub_unicode_glyph *visual,
|
struct grub_term_pos *pos,
|
||||||
grub_size_t visual_len,
|
unsigned start, unsigned end)
|
||||||
grub_size_t (*getcharwidth) (const struct grub_unicode_glyph *visual, void *getcharwidth_arg),
|
|
||||||
void *getcharwidth_arg,
|
|
||||||
grub_size_t maxwidth, grub_size_t startwidth,
|
|
||||||
grub_uint32_t contchar,
|
|
||||||
struct grub_term_pos *pos, int primitive_wrap,
|
|
||||||
grub_size_t log_end)
|
|
||||||
{
|
{
|
||||||
struct grub_unicode_glyph *outptr = visual_out;
|
|
||||||
unsigned line_start = 0;
|
|
||||||
grub_ssize_t line_width = startwidth;
|
|
||||||
unsigned k;
|
|
||||||
grub_ssize_t last_space = -1;
|
|
||||||
grub_ssize_t last_space_width = 0;
|
|
||||||
int lines = 0;
|
|
||||||
|
|
||||||
auto void revert (unsigned start, unsigned end);
|
|
||||||
void revert (unsigned start, unsigned end)
|
|
||||||
{
|
|
||||||
struct grub_unicode_glyph t;
|
struct grub_unicode_glyph t;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int a = 0, b = 0;
|
int a = 0, b = 0;
|
||||||
|
@ -565,7 +548,27 @@ bidi_line_wrap (struct grub_unicode_glyph *visual_out,
|
||||||
pos[visual[end - i].orig_pos].x = a + b - pos[visual[end - i].orig_pos].x;
|
pos[visual[end - i].orig_pos].x = a + b - pos[visual[end - i].orig_pos].x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static grub_ssize_t
|
||||||
|
bidi_line_wrap (struct grub_unicode_glyph *visual_out,
|
||||||
|
struct grub_unicode_glyph *visual,
|
||||||
|
grub_size_t visual_len,
|
||||||
|
grub_size_t (*getcharwidth) (const struct grub_unicode_glyph *visual, void *getcharwidth_arg),
|
||||||
|
void *getcharwidth_arg,
|
||||||
|
grub_size_t maxwidth, grub_size_t startwidth,
|
||||||
|
grub_uint32_t contchar,
|
||||||
|
struct grub_term_pos *pos, int primitive_wrap,
|
||||||
|
grub_size_t log_end)
|
||||||
|
{
|
||||||
|
struct grub_unicode_glyph *outptr = visual_out;
|
||||||
|
unsigned line_start = 0;
|
||||||
|
grub_ssize_t line_width = startwidth;
|
||||||
|
unsigned k;
|
||||||
|
grub_ssize_t last_space = -1;
|
||||||
|
grub_ssize_t last_space_width = 0;
|
||||||
|
int lines = 0;
|
||||||
|
|
||||||
if (!visual_len)
|
if (!visual_len)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -644,7 +647,7 @@ bidi_line_wrap (struct grub_unicode_glyph *visual_out,
|
||||||
in = i;
|
in = i;
|
||||||
if (visual[i].bidi_level >= j && (i + 1 == k
|
if (visual[i].bidi_level >= j && (i + 1 == k
|
||||||
|| visual[i+1].bidi_level < j))
|
|| visual[i+1].bidi_level < j))
|
||||||
revert (in, i);
|
revert (visual, pos, in, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -790,34 +793,34 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
|
||||||
unsigned cur_level;
|
unsigned cur_level;
|
||||||
int bidi_needed = 0;
|
int bidi_needed = 0;
|
||||||
|
|
||||||
auto void push_stack (unsigned new_override, unsigned new_level);
|
#define push_stack(new_override, new_level) \
|
||||||
void push_stack (unsigned new_override, unsigned new_level)
|
{ \
|
||||||
{
|
if (new_level > GRUB_BIDI_MAX_EXPLICIT_LEVEL) \
|
||||||
if (new_level > GRUB_BIDI_MAX_EXPLICIT_LEVEL)
|
{ \
|
||||||
{
|
invalid_pushes++; \
|
||||||
invalid_pushes++;
|
} \
|
||||||
return;
|
else \
|
||||||
}
|
{ \
|
||||||
stack_level[stack_depth] = cur_level;
|
stack_level[stack_depth] = cur_level; \
|
||||||
stack_override[stack_depth] = cur_override;
|
stack_override[stack_depth] = cur_override; \
|
||||||
stack_depth++;
|
stack_depth++; \
|
||||||
cur_level = new_level;
|
cur_level = new_level; \
|
||||||
cur_override = new_override;
|
cur_override = new_override; \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
auto void pop_stack (void);
|
#define pop_stack() \
|
||||||
void pop_stack (void)
|
{ \
|
||||||
{
|
if (invalid_pushes) \
|
||||||
if (invalid_pushes)
|
{ \
|
||||||
{
|
invalid_pushes--; \
|
||||||
invalid_pushes--;
|
} \
|
||||||
return;
|
else if (stack_depth) \
|
||||||
}
|
{ \
|
||||||
if (!stack_depth)
|
stack_depth--; \
|
||||||
return;
|
cur_level = stack_level[stack_depth]; \
|
||||||
stack_depth--;
|
cur_override = stack_override[stack_depth]; \
|
||||||
cur_level = stack_level[stack_depth];
|
} \
|
||||||
cur_override = stack_override[stack_depth];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
visual = grub_malloc (sizeof (visual[0]) * logical_len);
|
visual = grub_malloc (sizeof (visual[0]) * logical_len);
|
||||||
|
|
Loading…
Reference in a new issue