emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r108879: Fix bug #11857 with messed u


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r108879: Fix bug #11857 with messed up display for insanely large hscroll values.
Date: Thu, 05 Jul 2012 18:04:57 +0300
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 108879
fixes bug: http://debbugs.gnu.org/11857
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Thu 2012-07-05 18:04:57 +0300
message:
  Fix bug #11857 with messed up display for insanely large hscroll values.
  
   src/xdisp.c (window_hscroll_limited): New function.
   (pos_visible_p, init_iterator): Use it to avoid overflow of pixel
   coordinates when window's hscroll is set to insanely large
   values.
   src/window.h (struct window) <hscroll, min_hscroll>: Change type to 'int'.
modified:
  src/ChangeLog
  src/window.h
  src/xdisp.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-07-05 12:07:29 +0000
+++ b/src/ChangeLog     2012-07-05 15:04:57 +0000
@@ -1,3 +1,13 @@
+2012-07-05  Eli Zaretskii  <address@hidden>
+
+       * xdisp.c (window_hscroll_limited): New function.
+       (pos_visible_p, init_iterator): Use it to avoid overflow of pixel
+       coordinates when window's hscroll is set to insanely large
+       values.  (Bug#11857)
+
+       * window.h (struct window) <hscroll, min_hscroll>: Change type to
+       'int'.
+
 2012-07-05  Juanma Barranquero  <address@hidden>
 
        * makefile.w32-in ($(BLD)/dired.$(O), $(BLD)/fileio.$(O)): Fix typo.

=== modified file 'src/window.h'
--- a/src/window.h      2012-07-03 18:24:42 +0000
+++ b/src/window.h      2012-07-05 15:04:57 +0000
@@ -238,11 +238,11 @@
     int sequence_number;
 
     /* Number of columns display within the window is scrolled to the left.  */
-    ptrdiff_t hscroll;
+    int hscroll;
 
     /* Minimum hscroll for automatic hscrolling.  This is the value
        the user has set, by set-window-hscroll for example.  */
-    ptrdiff_t min_hscroll;
+    int min_hscroll;
 
     /* Displayed buffer's text modification events counter as of last time
        display completed.  */

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2012-07-05 06:32:41 +0000
+++ b/src/xdisp.c       2012-07-05 15:04:57 +0000
@@ -1251,6 +1251,23 @@
   return spec;
 }
 
+
+/* Limit insanely large values of W->hscroll on frame F to the largest
+   value that will still prevent first_visible_x and last_visible_x of
+   'struct it' from overflowing an int.  */
+static inline int
+window_hscroll_limited (struct window *w, struct frame *f)
+{
+  int window_hscroll = w->hscroll;
+  int window_text_width = window_box_width (w, TEXT_AREA);
+  int colwidth = FRAME_COLUMN_WIDTH (f);
+
+  if (window_hscroll > (INT_MAX - window_text_width) / colwidth - 1)
+    window_hscroll = (INT_MAX - window_text_width) / colwidth - 1;
+
+  return window_hscroll;
+}
+
 /* Return 1 if position CHARPOS is visible in window W.
    CHARPOS < 0 means return info about WINDOW_END position.
    If visible, set *X and *Y to pixel coordinates of top left corner.
@@ -1563,7 +1580,9 @@
   current_header_line_height = current_mode_line_height = -1;
 
   if (visible_p && w->hscroll > 0)
-    *x -= w->hscroll * WINDOW_FRAME_COLUMN_WIDTH (w);
+    *x -=
+      window_hscroll_limited (w, WINDOW_XFRAME (w))
+      * WINDOW_FRAME_COLUMN_WIDTH (w);
 
 #if 0
   /* Debugging code.  */
@@ -2759,8 +2778,8 @@
     }
   else
     {
-      it->first_visible_x
-       = it->w->hscroll * FRAME_COLUMN_WIDTH (it->f);
+      it->first_visible_x =
+       window_hscroll_limited (it->w, it->f) * FRAME_COLUMN_WIDTH (it->f);
       it->last_visible_x = (it->first_visible_x
                            + window_box_width (w, TEXT_AREA));
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]