From: Eli Zaretskii <eliz@gnu.org>
Date: Tue, 14 Oct 2014 09:16:02 +0000 (+0300)
Subject: Increase 'level' in glyph struct; convert bad type aborts into assertions.
X-Git-Tag: emacs-25.0.90~2635^2~679^2~50^2~7
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c1621a49bdadc92c6c60965078dc9d83b2154770;p=emacs.git

Increase 'level' in glyph struct; convert bad type aborts into assertions.
---

diff --git a/src/bidi.c b/src/bidi.c
index d03aa4e3e10..fc47a583cfe 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -3161,6 +3161,9 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it)
 	bidi_cache_iterator_state (bidi_it, 1, 0);
     }
 
+  eassert (bidi_it->resolved_level >= 0
+	   && bidi_it->resolved_level <= BIDI_MAXDEPTH + 2);
+
   if (STRINGP (bidi_it->string.lstring))
     UNGCPRO;
 }
diff --git a/src/dispextern.h b/src/dispextern.h
index 9d7eb57fc8c..b87ae891a37 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -445,8 +445,8 @@ struct glyph
   /* True means don't display cursor here.  */
   bool_bf avoid_cursor_p : 1;
 
-  /* Resolved bidirectional level of this character [0..63].  */
-  unsigned resolved_level : 5;
+  /* Resolved bidirectional level of this character [0..127].  */
+  unsigned resolved_level : 7;
 
   /* Resolved bidirectional type of this character, see enum
      bidi_type_t below.  Note that according to UAX#9, only some
diff --git a/src/term.c b/src/term.c
index af1b62ccaaf..c8ff6f31575 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1514,8 +1514,7 @@ append_glyph (struct it *it)
       if (it->bidi_p)
 	{
 	  glyph->resolved_level = it->bidi_it.resolved_level;
-	  if ((it->bidi_it.type & 7) != it->bidi_it.type)
-	    emacs_abort ();
+	  eassert ((it->bidi_it.type & 7) == it->bidi_it.type);
 	  glyph->bidi_type = it->bidi_it.type;
 	}
       else
@@ -1711,8 +1710,7 @@ append_composite_glyph (struct it *it)
       if (it->bidi_p)
 	{
 	  glyph->resolved_level = it->bidi_it.resolved_level;
-	  if ((it->bidi_it.type & 7) != it->bidi_it.type)
-	    emacs_abort ();
+	  eassert ((it->bidi_it.type & 7) == it->bidi_it.type);
 	  glyph->bidi_type = it->bidi_it.type;
 	}
       else
@@ -1796,8 +1794,7 @@ append_glyphless_glyph (struct it *it, int face_id, const char *str)
   if (it->bidi_p)
     {
       glyph->resolved_level = it->bidi_it.resolved_level;
-      if ((it->bidi_it.type & 7) != it->bidi_it.type)
-	emacs_abort ();
+      eassert ((it->bidi_it.type & 7) == it->bidi_it.type);
       glyph->bidi_type = it->bidi_it.type;
     }
   else
diff --git a/src/xdisp.c b/src/xdisp.c
index 7cf1782b83f..70a1a2b8703 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -25166,8 +25166,7 @@ append_glyph (struct it *it)
       if (it->bidi_p)
 	{
 	  glyph->resolved_level = it->bidi_it.resolved_level;
-	  if ((it->bidi_it.type & 7) != it->bidi_it.type)
-	    emacs_abort ();
+	  eassert ((it->bidi_it.type & 7) == it->bidi_it.type);
 	  glyph->bidi_type = it->bidi_it.type;
 	}
       else
@@ -25250,8 +25249,7 @@ append_composite_glyph (struct it *it)
       if (it->bidi_p)
 	{
 	  glyph->resolved_level = it->bidi_it.resolved_level;
-	  if ((it->bidi_it.type & 7) != it->bidi_it.type)
-	    emacs_abort ();
+	  eassert ((it->bidi_it.type & 7) == it->bidi_it.type);
 	  glyph->bidi_type = it->bidi_it.type;
 	}
       ++it->glyph_row->used[area];
@@ -25439,8 +25437,7 @@ produce_image_glyph (struct it *it)
 	  if (it->bidi_p)
 	    {
 	      glyph->resolved_level = it->bidi_it.resolved_level;
-	      if ((it->bidi_it.type & 7) != it->bidi_it.type)
-		emacs_abort ();
+	      eassert ((it->bidi_it.type & 7) == it->bidi_it.type);
 	      glyph->bidi_type = it->bidi_it.type;
 	    }
 	  ++it->glyph_row->used[area];
@@ -25528,8 +25525,7 @@ append_stretch_glyph (struct it *it, Lisp_Object object,
       if (it->bidi_p)
 	{
 	  glyph->resolved_level = it->bidi_it.resolved_level;
-	  if ((it->bidi_it.type & 7) != it->bidi_it.type)
-	    emacs_abort ();
+	  eassert ((it->bidi_it.type & 7) == it->bidi_it.type);
 	  glyph->bidi_type = it->bidi_it.type;
 	}
       else
@@ -25989,8 +25985,7 @@ append_glyphless_glyph (struct it *it, int face_id, int for_no_font, int len,
       if (it->bidi_p)
 	{
 	  glyph->resolved_level = it->bidi_it.resolved_level;
-	  if ((it->bidi_it.type & 7) != it->bidi_it.type)
-	    emacs_abort ();
+	  eassert ((it->bidi_it.type & 7) == it->bidi_it.type);
 	  glyph->bidi_type = it->bidi_it.type;
 	}
       ++it->glyph_row->used[area];