From 81b0623a6c86e314b50041f0648f76f6f168add6 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 23 Mar 2010 16:28:35 +0100 Subject: [PATCH] Make few more points bidi-clean --- normal/menu_entry.c | 6 +++--- normal/term.c | 23 +++++++++-------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/normal/menu_entry.c b/normal/menu_entry.c index 74887b8ab..be2d18fc9 100644 --- a/normal/menu_entry.c +++ b/normal/menu_entry.c @@ -1094,10 +1094,10 @@ complete (struct screen *screen, int continuous, int update) else grub_putcode (' ', screen->terms[i].term); - while (*p && p < endp) - grub_putcode (*p++, screen->terms[i].term); + grub_print_ucs4 (p, ucs4 + ucs4len < endp ? ucs4 + ucs4len : endp, + 0, 0, screen->terms[i].term); - if (*p) + if (ucs4 + ucs4len > endp) grub_putcode (GRUB_TERM_DISP_RIGHT, screen->terms[i].term); grub_term_gotoxy (screen->terms[i].term, pos >> 8, pos & 0xFF); } diff --git a/normal/term.c b/normal/term.c index a2a313779..9488f68bc 100644 --- a/normal/term.c +++ b/normal/term.c @@ -165,17 +165,12 @@ map_code (grub_uint32_t in, struct grub_term_output *term) void grub_puts_terminal (const char *str, struct grub_term_output *term) { - grub_uint32_t code; - grub_ssize_t ret; - const grub_uint8_t *ptr = (const grub_uint8_t *) str; - const grub_uint8_t *end; - end = (const grub_uint8_t *) (str + grub_strlen (str)); + grub_uint32_t *unicode_str, *unicode_last_position; + grub_utf8_to_ucs4_alloc (str, &unicode_str, + &unicode_last_position); - while (*ptr) - { - ret = grub_utf8_to_ucs4 (&code, 1, ptr, end - ptr, &ptr); - grub_putcode (code, term); - } + grub_print_ucs4 (unicode_str, unicode_last_position, 0, 0, term); + grub_free (unicode_str); } grub_uint16_t * @@ -574,13 +569,13 @@ void grub_xputs_normal (const char *str) { grub_term_output_t term; + grub_uint32_t *unicode_str, *unicode_last_position; + grub_utf8_to_ucs4_alloc (str, &unicode_str, + &unicode_last_position); FOR_ACTIVE_TERM_OUTPUTS(term) { - grub_uint32_t *unicode_str, *unicode_last_position; - grub_utf8_to_ucs4_alloc (str, &unicode_str, - &unicode_last_position); grub_print_ucs4 (unicode_str, unicode_last_position, 0, 0, term); - grub_free (unicode_str); } + grub_free (unicode_str); }