]> code.delx.au - gnu-emacs/commitdiff
Ensure positive number of glyphs for margins of positive width
authorEli Zaretskii <eliz@gnu.org>
Fri, 15 Jan 2016 15:36:47 +0000 (17:36 +0200)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 22 Mar 2016 00:05:55 +0000 (17:05 -0700)
* src/dispnew.c (margin_glyphs_to_reserve): Always return a
positive value when a non-zero width of the marginal area was
requested.  (Bug#22356)

[This reapplies commit 740849fe986b62a839bce4bbf67d0036fc1be0b9,
which was inadvertently lost by merge commit
7823745acbe9b87eea2db4ef434e379fc903ec35.]

src/dispnew.c

index 9cf12f1a9959ef12be5266d34cfab2f96013cf90..3a0532a693b0047910289cef8f78fa183380e39c 100644 (file)
@@ -321,7 +321,9 @@ margin_glyphs_to_reserve (struct window *w, int total_glyphs, int margin)
       int width = w->total_cols;
       double d = max (0, margin);
       d = min (width / 2 - 1, d);
-      return (int) ((double) total_glyphs / width * d);
+      /* Since MARGIN is positive, we cannot possibly have less than
+        one glyph for the marginal area.  */
+      return max (1, (int) ((double) total_glyphs / width * d));
     }
   return 0;
 }