a5bd9f6
From 46992a68784aedc4e53ce749a88b6034209af87e Mon Sep 17 00:00:00 2001
a5bd9f6
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
a5bd9f6
Date: Sat, 2 Mar 2013 11:47:59 +0100
a5bd9f6
Subject: [PATCH 181/364] 	* grub-core/normal/charset.c
a5bd9f6
 (grub_bidi_logical_to_visual): Add 	hook pass-through parameter. All users
a5bd9f6
 updated and unnested.
a5bd9f6
a5bd9f6
---
a5bd9f6
 grub-core/gfxmenu/font.c   |  2 +-
a5bd9f6
 grub-core/normal/charset.c | 14 +++++++++-----
a5bd9f6
 grub-core/normal/term.c    | 14 +++++++-------
a5bd9f6
 include/grub/unicode.h     |  3 ++-
a5bd9f6
 4 files changed, 19 insertions(+), 14 deletions(-)
a5bd9f6
a5bd9f6
diff --git a/grub-core/gfxmenu/font.c b/grub-core/gfxmenu/font.c
a5bd9f6
index 81a689d..7174837 100644
a5bd9f6
--- a/grub-core/gfxmenu/font.c
a5bd9f6
+++ b/grub-core/gfxmenu/font.c
a5bd9f6
@@ -52,7 +52,7 @@ grub_font_draw_string (const char *str, grub_font_t font,
a5bd9f6
     return grub_errno;
a5bd9f6
 
a5bd9f6
   visual_len = grub_bidi_logical_to_visual (logical, logical_len, &visual,
a5bd9f6
-					    0, 0, 0, 0, 0, 0);
a5bd9f6
+					    0, 0, 0, 0, 0, 0, 0);
a5bd9f6
   grub_free (logical);
a5bd9f6
   if (visual_len < 0)
a5bd9f6
     return grub_errno;
a5bd9f6
diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c
a5bd9f6
index bd9fbf4..ab3101b 100644
a5bd9f6
--- a/grub-core/normal/charset.c
a5bd9f6
+++ b/grub-core/normal/charset.c
a5bd9f6
@@ -512,7 +512,8 @@ static grub_ssize_t
a5bd9f6
 bidi_line_wrap (struct grub_unicode_glyph *visual_out,
a5bd9f6
 		struct grub_unicode_glyph *visual,
a5bd9f6
 		grub_size_t visual_len, unsigned *levels,
a5bd9f6
-		grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
a5bd9f6
+		grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual, void *getcharwidth_arg),
a5bd9f6
+		void *getcharwidth_arg,
a5bd9f6
 		grub_size_t maxwidth, grub_size_t startwidth,
a5bd9f6
 		grub_uint32_t contchar,
a5bd9f6
 		struct grub_term_pos *pos, int primitive_wrap,
a5bd9f6
@@ -577,7 +578,7 @@ bidi_line_wrap (struct grub_unicode_glyph *visual_out,
a5bd9f6
 	}
a5bd9f6
 
a5bd9f6
       if (getcharwidth && k != visual_len)
a5bd9f6
-	line_width += last_width = getcharwidth (&visual[k]);
a5bd9f6
+	line_width += last_width = getcharwidth (&visual[k], getcharwidth_arg);
a5bd9f6
 
a5bd9f6
       if (k != visual_len && (visual[k].base == ' '
a5bd9f6
 			      || visual[k].base == '\t')
a5bd9f6
@@ -752,7 +753,8 @@ static grub_ssize_t
a5bd9f6
 grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
a5bd9f6
 				  grub_size_t logical_len,
a5bd9f6
 				  struct grub_unicode_glyph *visual_out,
a5bd9f6
-				  grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
a5bd9f6
+				  grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual, void *getcharwidth_arg),
a5bd9f6
+				  void *getcharwidth_arg,
a5bd9f6
 				  grub_size_t maxwidth, grub_size_t startwidth,
a5bd9f6
 				  grub_uint32_t contchar,
a5bd9f6
 				  struct grub_term_pos *pos,
a5bd9f6
@@ -1116,7 +1118,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
a5bd9f6
   {
a5bd9f6
     grub_ssize_t ret;
a5bd9f6
     ret = bidi_line_wrap (visual_out, visual, visual_len, levels, 
a5bd9f6
-			  getcharwidth, maxwidth, startwidth, contchar,
a5bd9f6
+			  getcharwidth, getcharwidth_arg, maxwidth, startwidth, contchar,
a5bd9f6
 			  pos, primitive_wrap, log_end);
a5bd9f6
     grub_free (levels);
a5bd9f6
     grub_free (visual);
a5bd9f6
@@ -1128,7 +1130,8 @@ grub_ssize_t
a5bd9f6
 grub_bidi_logical_to_visual (const grub_uint32_t *logical,
a5bd9f6
 			     grub_size_t logical_len,
a5bd9f6
 			     struct grub_unicode_glyph **visual_out,
a5bd9f6
-			     grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
a5bd9f6
+			     grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual, void *getcharwidth_arg),
a5bd9f6
+			     void *getcharwidth_arg,
a5bd9f6
 			     grub_size_t max_length, grub_size_t startwidth,
a5bd9f6
 			     grub_uint32_t contchar, struct grub_term_pos *pos, int primitive_wrap)
a5bd9f6
 {
a5bd9f6
@@ -1147,6 +1150,7 @@ grub_bidi_logical_to_visual (const grub_uint32_t *logical,
a5bd9f6
 						  ptr - line_start,
a5bd9f6
 						  visual_ptr,
a5bd9f6
 						  getcharwidth,
a5bd9f6
+						  getcharwidth_arg,
a5bd9f6
 						  max_length,
a5bd9f6
 						  startwidth,
a5bd9f6
 						  contchar,
a5bd9f6
diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c
a5bd9f6
index dc03268..ae91071 100644
a5bd9f6
--- a/grub-core/normal/term.c
a5bd9f6
+++ b/grub-core/normal/term.c
a5bd9f6
@@ -840,6 +840,12 @@ print_backlog (struct grub_term_output *term,
a5bd9f6
   return 0;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
+static grub_ssize_t
a5bd9f6
+getcharwidth (const struct grub_unicode_glyph *c, void *term)
a5bd9f6
+{
a5bd9f6
+  return grub_term_getcharwidth (term, c);
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
 static int
a5bd9f6
 print_ucs4_real (const grub_uint32_t * str,
a5bd9f6
 		 const grub_uint32_t * last_position,
a5bd9f6
@@ -881,14 +887,8 @@ print_ucs4_real (const grub_uint32_t * str,
a5bd9f6
       int ret;
a5bd9f6
       struct grub_unicode_glyph *vptr;
a5bd9f6
 
a5bd9f6
-      auto grub_ssize_t getcharwidth (const struct grub_unicode_glyph *c);
a5bd9f6
-      grub_ssize_t getcharwidth (const struct grub_unicode_glyph *c)
a5bd9f6
-      {
a5bd9f6
-	return grub_term_getcharwidth (term, c);
a5bd9f6
-      }
a5bd9f6
-
a5bd9f6
       visual_len = grub_bidi_logical_to_visual (str, last_position - str,
a5bd9f6
-						&visual, getcharwidth,
a5bd9f6
+						&visual, getcharwidth, term,
a5bd9f6
 						get_maxwidth (term, 
a5bd9f6
 							      margin_left,
a5bd9f6
 							      margin_right),
a5bd9f6
diff --git a/include/grub/unicode.h b/include/grub/unicode.h
a5bd9f6
index eb5051a..5a96a19 100644
a5bd9f6
--- a/include/grub/unicode.h
a5bd9f6
+++ b/include/grub/unicode.h
a5bd9f6
@@ -240,7 +240,8 @@ grub_ssize_t
a5bd9f6
 grub_bidi_logical_to_visual (const grub_uint32_t *logical,
a5bd9f6
 			     grub_size_t logical_len,
a5bd9f6
 			     struct grub_unicode_glyph **visual_out,
a5bd9f6
-			     grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
a5bd9f6
+			     grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual, void *getcharwidth_arg),
a5bd9f6
+			     void *getcharwidth_arg,
a5bd9f6
 			     grub_size_t max_width,
a5bd9f6
 			     grub_size_t start_width, grub_uint32_t codechar,
a5bd9f6
 			     struct grub_term_pos *pos,
a5bd9f6
-- 
a5bd9f6
1.8.1.4
a5bd9f6