X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/33bb679af9e323408c8089f0b5675a54776d60d5..0a2aedfe6d650e825a50f25f972bac20d669f5cb:/src/dispnew.c?ds=sidebyside diff --git a/src/dispnew.c b/src/dispnew.c index fe07f793cb..82d0b76a95 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -7,8 +7,8 @@ This file is part of GNU Emacs. GNU Emacs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +the Free Software Foundation, either version 3 of the License, or (at +your option) any later version. GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -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; } @@ -681,7 +683,9 @@ void clear_glyph_matrix_rows (struct glyph_matrix *matrix, int start, int end) { eassert (start <= end); - eassert (start >= 0 && start < matrix->nrows); + eassert (start >= 0 && (start < matrix->nrows + /* matrix->nrows can be 0 for the initial frame. */ + || (matrix->nrows == 0))); eassert (end >= 0 && end <= matrix->nrows); for (; start < end; ++start) @@ -5173,8 +5177,8 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p #ifdef HAVE_WINDOW_SYSTEM if (it.what == IT_IMAGE) { - if ((img = IMAGE_FROM_ID (it.f, it.image_id)) != NULL - && !NILP (img->spec)) + img = IMAGE_OPT_FROM_ID (it.f, it.image_id); + if (img && !NILP (img->spec)) *object = img->spec; } #endif @@ -5271,7 +5275,7 @@ mode_line_string (struct window *w, enum window_part part, if (glyph->type == IMAGE_GLYPH) { struct image *img; - img = IMAGE_FROM_ID (WINDOW_XFRAME (w), glyph->u.img_id); + img = IMAGE_OPT_FROM_ID (WINDOW_XFRAME (w), glyph->u.img_id); if (img != NULL) *object = img->spec; y0 -= row->ascent - glyph->ascent; @@ -5358,7 +5362,7 @@ marginal_area_string (struct window *w, enum window_part part, if (glyph->type == IMAGE_GLYPH) { struct image *img; - img = IMAGE_FROM_ID (WINDOW_XFRAME (w), glyph->u.img_id); + img = IMAGE_OPT_FROM_ID (WINDOW_XFRAME (w), glyph->u.img_id); if (img != NULL) *object = img->spec; y0 -= row->ascent - glyph->ascent; @@ -5667,7 +5671,7 @@ DEFUN ("sleep-for", Fsleep_for, Ssleep_for, 1, 2, 0, SECONDS may be a floating-point value, meaning that you can wait for a fraction of a second. Optional second arg MILLISECONDS specifies an additional wait period, in milliseconds; this is for backwards compatibility. -(Not all operating systems support waiting for a fraction of a second.) */) +\(Not all operating systems support waiting for a fraction of a second.) */) (Lisp_Object seconds, Lisp_Object milliseconds) { double duration = extract_float (seconds); @@ -6034,11 +6038,11 @@ init_display (void) #endif /* If no window system has been specified, try to use the terminal. */ - if (! isatty (0)) + if (! isatty (STDIN_FILENO)) fatal ("standard input is not a tty"); #ifdef WINDOWSNT - terminal_type = "w32console"; + terminal_type = (char *)"w32console"; #else terminal_type = getenv ("TERM"); #endif