Blame SOURCES/0182-grub-core-normal-charset.c-grub_bidi_logical_to_visu.patch

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