* 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>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
static void
|
||||
revert (struct grub_unicode_glyph *visual,
|
||||
struct grub_term_pos *pos,
|
||||
unsigned start, unsigned 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;
|
||||
unsigned i;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
@ -644,7 +647,7 @@ bidi_line_wrap (struct grub_unicode_glyph *visual_out,
|
|||
in = i;
|
||||
if (visual[i].bidi_level >= j && (i + 1 == k
|
||||
|| 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;
|
||||
int bidi_needed = 0;
|
||||
|
||||
auto void push_stack (unsigned new_override, unsigned new_level);
|
||||
void push_stack (unsigned new_override, unsigned new_level)
|
||||
{
|
||||
if (new_level > GRUB_BIDI_MAX_EXPLICIT_LEVEL)
|
||||
{
|
||||
invalid_pushes++;
|
||||
return;
|
||||
}
|
||||
stack_level[stack_depth] = cur_level;
|
||||
stack_override[stack_depth] = cur_override;
|
||||
stack_depth++;
|
||||
cur_level = new_level;
|
||||
cur_override = new_override;
|
||||
#define push_stack(new_override, new_level) \
|
||||
{ \
|
||||
if (new_level > GRUB_BIDI_MAX_EXPLICIT_LEVEL) \
|
||||
{ \
|
||||
invalid_pushes++; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
stack_level[stack_depth] = cur_level; \
|
||||
stack_override[stack_depth] = cur_override; \
|
||||
stack_depth++; \
|
||||
cur_level = new_level; \
|
||||
cur_override = new_override; \
|
||||
} \
|
||||
}
|
||||
|
||||
auto void pop_stack (void);
|
||||
void pop_stack (void)
|
||||
{
|
||||
if (invalid_pushes)
|
||||
{
|
||||
invalid_pushes--;
|
||||
return;
|
||||
}
|
||||
if (!stack_depth)
|
||||
return;
|
||||
stack_depth--;
|
||||
cur_level = stack_level[stack_depth];
|
||||
cur_override = stack_override[stack_depth];
|
||||
#define pop_stack() \
|
||||
{ \
|
||||
if (invalid_pushes) \
|
||||
{ \
|
||||
invalid_pushes--; \
|
||||
} \
|
||||
else if (stack_depth) \
|
||||
{ \
|
||||
stack_depth--; \
|
||||
cur_level = stack_level[stack_depth]; \
|
||||
cur_override = stack_override[stack_depth]; \
|
||||
} \
|
||||
}
|
||||
|
||||
visual = grub_malloc (sizeof (visual[0]) * logical_len);
|
||||
|
|
Loading…
Add table
Reference in a new issue