changeset 108113:cfcf7c495ca4

Fix crash with bidi display on the last empty line (bug#6030). xdisp.c (display_line): Don't assume 2nd call to get_next_display_element cannot return zero. (Bug#6030) Move code that bidi-iterates out of display property to a separate function. xdisp.c (iterate_out_of_display_property): New function, body from pop_it. (pop_it): Use it.
author Eli Zaretskii <eliz@gnu.org>
date Sun, 25 Apr 2010 20:06:41 +0300
parents 21b1df34bc55 (current diff) a9a653a56eef (diff)
children 641672d44942
files src/ChangeLog src/xdisp.c
diffstat 2 files changed, 37 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sun Apr 25 09:23:01 2010 +0200
+++ b/src/ChangeLog	Sun Apr 25 20:06:41 2010 +0300
@@ -1,3 +1,10 @@
+2010-04-25  Eli Zaretskii  <eliz@gnu.org>
+
+	* xdisp.c (display_line): Don't assume 2nd call to
+	get_next_display_element cannot return zero.  (Bug#6030)
+	(iterate_out_of_display_property): New function, body from pop_it.
+	(pop_it): Use it.
+
 2010-04-24  Glenn Morris  <rgm@gnu.org>
 
 	* m/amdx86-64.h (START_FILES, LIB_STANDARD) [__OpenBSD__]:
--- a/src/xdisp.c	Sun Apr 25 09:23:01 2010 +0200
+++ b/src/xdisp.c	Sun Apr 25 20:06:41 2010 +0300
@@ -5259,6 +5259,33 @@
   ++it->sp;
 }
 
+static void
+iterate_out_of_display_property (it)
+     struct it *it;
+{
+  /* Maybe initialize paragraph direction.  If we are at the beginning
+     of a new paragraph, next_element_from_buffer may not have a
+     chance to do that.  */
+  if (it->bidi_it.first_elt && it->bidi_it.charpos < ZV)
+    bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it);
+  /* prev_stop can be zero, so check against BEGV as well.  */
+  while (it->bidi_it.charpos >= BEGV
+	 && it->prev_stop <= it->bidi_it.charpos
+	 && it->bidi_it.charpos < CHARPOS (it->position))
+    bidi_get_next_char_visually (&it->bidi_it);
+  /* Record the stop_pos we just crossed, for when we cross it
+     back, maybe.  */
+  if (it->bidi_it.charpos > CHARPOS (it->position))
+    it->prev_stop = CHARPOS (it->position);
+  /* If we ended up not where pop_it put us, resync IT's
+     positional members with the bidi iterator. */
+  if (it->bidi_it.charpos != CHARPOS (it->position))
+    {
+      SET_TEXT_POS (it->position,
+		    it->bidi_it.charpos, it->bidi_it.bytepos);
+      it->current.pos = it->position;
+    }
+}
 
 /* Restore IT's settings from IT->stack.  Called, for example, when no
    more overlay strings must be processed, and we return to delivering
@@ -5309,25 +5336,7 @@
 	     determine the paragraph base direction if the overlay we
 	     just processed is at the beginning of a new
 	     paragraph.  */
-	  if (it->bidi_it.first_elt && it->bidi_it.charpos < ZV)
-	    bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it);
-	  /* prev_stop can be zero, so check against BEGV as well.  */
-	  while (it->bidi_it.charpos >= BEGV
-		 && it->prev_stop <= it->bidi_it.charpos
-		 && it->bidi_it.charpos < CHARPOS (it->position))
-	    bidi_get_next_char_visually (&it->bidi_it);
-	  /* Record the stop_pos we just crossed, for when we cross it
-	     back, maybe.  */
-	  if (it->bidi_it.charpos > CHARPOS (it->position))
-	    it->prev_stop = CHARPOS (it->position);
-	  /* If we ended up not where pop_it put us, resync IT's
-	     positional members with the bidi iterator. */
-	  if (it->bidi_it.charpos != CHARPOS (it->position))
-	    {
-	      SET_TEXT_POS (it->position,
-			    it->bidi_it.charpos, it->bidi_it.bytepos);
-	      it->current.pos = it->position;
-	    }
+	  iterate_out_of_display_property (it);
 	}
       break;
     case GET_FROM_STRING:
@@ -17979,9 +17988,8 @@
 	  row_end = it->current;
 	  /* If the character at max_pos+1 is a newline, skip that as
 	     well.  Note that this may skip some invisible text.  */
-	  if (!get_next_display_element (it))
-	    abort ();
-	  if (ITERATOR_AT_END_OF_LINE_P (it))
+	  if (get_next_display_element (it)
+	      && ITERATOR_AT_END_OF_LINE_P (it))
 	    {
 	      set_iterator_to_next (it, 1);
 	      /* Record the position after the newline of a continued