changeset 48758:0b855d91442b

(row_containing_pos): Check more carefully whether charpos is really in the row before returning it.
author Richard M. Stallman <rms@gnu.org>
date Mon, 09 Dec 2002 01:56:05 +0000
parents edfd05d8ef77
children adc625ac6c52
files src/xdisp.c
diffstat 1 files changed, 15 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Mon Dec 09 01:55:05 2002 +0000
+++ b/src/xdisp.c	Mon Dec 09 01:56:05 2002 +0000
@@ -11509,25 +11509,27 @@
 
   last_y = window_text_bottom_y (w) - dy;
 
-  while ((end == NULL || row < end)
-	 && MATRIX_ROW_BOTTOM_Y (row) < last_y
-	 && (MATRIX_ROW_END_CHARPOS (row) < charpos
+  while (1)
+    {
+      /* Give up if we have gone too far.  */
+      if (end && row >= end)
+	return NULL;
+      if (MATRIX_ROW_BOTTOM_Y (row) >= last_y)
+	return NULL;
+
+      /* If it is in this row, return this row.  */
+      if (! (MATRIX_ROW_END_CHARPOS (row) < charpos
 	     || (MATRIX_ROW_END_CHARPOS (row) == charpos
 		 /* The end position of a row equals the start
 		    position of the next row.  If CHARPOS is there, we
 		    would rather display it in the next line, except
 		    when this line ends in ZV.  */
 		 && !row->ends_at_zv_p
-		 && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))))
-    ++row;
-
-  /* Give up if CHARPOS not found.  */
-  if ((end && row >= end)
-      || charpos < MATRIX_ROW_START_CHARPOS (row)
-      || charpos > MATRIX_ROW_END_CHARPOS (row))
-    row = NULL;
-
-  return row;
+		 && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row)))
+	  && charpos >= MATRIX_ROW_START_CHARPOS (row))
+	return row;
+      ++row;
+    }
 }