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;
}
#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
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;
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;
#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