aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2018-02-12 20:02:36 +0200
committerEli Zaretskii2018-02-12 20:02:36 +0200
commita22820a31c191451334eec101125f7b621d6dbc0 (patch)
tree1bb99e8b7ff05ed13e0d7cac9b3c768a936a32cf
parent26f64410fd6845cde1a06373eea05e256b87513d (diff)
downloademacs-a22820a31c191451334eec101125f7b621d6dbc0.tar.gz
emacs-a22820a31c191451334eec101125f7b621d6dbc0.zip
Avoid aborts in cm.c due to too small TTY frame
* src/frame.c (frame_windows_min_size): Limit TTY frames to a minimum height large enough to allow for a menu bar, the mode line, one text line and one echo-area line. This avoids aborts in cm.c:cmcheckmagic. (Bug#30320)
-rw-r--r--src/frame.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/frame.c b/src/frame.c
index d5b080d688a..a86f05191a8 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -341,7 +341,9 @@ DEFUN ("frame-windows-min-size", Fframe_windows_min_size,
341 * of `window-min-height' (`window-min-width' if HORIZONTAL is non-nil). 341 * of `window-min-height' (`window-min-width' if HORIZONTAL is non-nil).
342 * With IGNORE non-nil the values of these variables are ignored. 342 * With IGNORE non-nil the values of these variables are ignored.
343 * 343 *
344 * In either case, never return a value less than 1. 344 * In either case, never return a value less than 1. For TTY frames,
345 * additionally limit the minimum frame height to a value large enough
346 * to support the menu bar, the mode line, and the echo area.
345 */ 347 */
346static int 348static int
347frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal, 349frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal,
@@ -349,6 +351,7 @@ frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal,
349{ 351{
350 struct frame *f = XFRAME (frame); 352 struct frame *f = XFRAME (frame);
351 Lisp_Object par_size; 353 Lisp_Object par_size;
354 int retval;
352 355
353 if ((!NILP (horizontal) 356 if ((!NILP (horizontal)
354 && NUMBERP (par_size = get_frame_param (f, Qmin_width))) 357 && NUMBERP (par_size = get_frame_param (f, Qmin_width)))
@@ -361,15 +364,27 @@ frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal,
361 if (min_size < 1) 364 if (min_size < 1)
362 min_size = 1; 365 min_size = 1;
363 366
364 return (NILP (pixelwise) 367 retval = (NILP (pixelwise)
365 ? min_size 368 ? min_size
366 : min_size * (NILP (horizontal) 369 : min_size * (NILP (horizontal)
367 ? FRAME_LINE_HEIGHT (f) 370 ? FRAME_LINE_HEIGHT (f)
368 : FRAME_COLUMN_WIDTH (f))); 371 : FRAME_COLUMN_WIDTH (f)));
369 } 372 }
370 else 373 else
371 return XINT (call4 (Qframe_windows_min_size, frame, horizontal, 374 retval = XINT (call4 (Qframe_windows_min_size, frame, horizontal,
372 ignore, pixelwise)); 375 ignore, pixelwise));
376 /* Don't allow too small height of text-mode frames, or else cm.c
377 might abort in cmcheckmagic. */
378 if ((FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) && NILP (horizontal))
379 {
380 int min_height = (FRAME_MENU_BAR_LINES (f)
381 + FRAME_WANTS_MODELINE_P (f)
382 + 2); /* one text line and one echo-area line */
383 if (retval < min_height)
384 retval = min_height;
385 }
386
387 return retval;
373} 388}
374 389
375 390