if (FRAME_MINIBUF_ONLY_P (f))
return;
- if (INTEGERP (value))
+ if (TYPE_RANGED_INTEGERP (int, value))
nlines = XINT (value);
else
nlines = 0;
/* If buf is a 'hidden' buffer (i.e. one whose name starts with
a space), try to find another one. */
if (SREF (Fbuffer_name (buf), 0) == ' ')
- buf = Fother_buffer (buf, Qnil, Qnil);
+ buf = other_buffer_safely (buf);
/* Use set_window_buffer, not Fset_window_buffer, and don't let
hooks be run by it. The reason is that the whole frame/window
\f
/* Construct a frame that refers to a terminal. */
-static int tty_frame_count;
+static printmax_t tty_frame_count;
struct frame *
make_initial_frame (void)
{
register struct frame *f;
Lisp_Object frame;
- char name[20];
+ char name[sizeof "F" + INT_STRLEN_BOUND (printmax_t)];
if (!terminal->name)
error ("Terminal is not live, can't create new frames on it");
Vframe_list = Fcons (frame, Vframe_list);
tty_frame_count++;
- sprintf (name, "F%d", tty_frame_count);
+ sprintf (name, "F%"pMd, tty_frame_count);
f->name = build_string (name);
f->visible = 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
0 if all frames aside from F are invisible.
(Exception: if F is the terminal frame, and we are using X, return 1.) */
-int
+static int
other_visible_frames (FRAME_PTR f)
{
/* We know the selected frame is visible,
return 1;
}
-DEFUN ("other-visible-frames-p", Fother_visible_frames_p, Sother_visible_frames_p, 0, 1, 0,
- doc: /* Return t if there are other visible frames beside FRAME.
-FRAME defaults to the selected frame. */)
- (Lisp_Object frame)
-{
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- return other_visible_frames (XFRAME (frame)) ? Qt : Qnil;
-}
-
/* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
unconditionally. x_connection_closed and delete_terminal use
this. Any other value of FORCE implements the semantics
/* Return the buffer-list of the selected frame. */
-Lisp_Object
+static Lisp_Object
frame_buffer_list (Lisp_Object frame)
{
return XFRAME (frame)->buffer_list;
}
-/* Set the buffer-list of the selected frame. */
-
-void
-set_frame_buffer_list (Lisp_Object frame, Lisp_Object list)
-{
- XFRAME (frame)->buffer_list = list;
-}
-
/* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
void
/* If NAME is nil, set the name to F<num>. */
if (NILP (name))
{
- char namebuf[20];
+ char namebuf[sizeof "F" + INT_STRLEN_BOUND (printmax_t)];
/* Check for no change needed in this very common case
before we do any consing. */
return;
tty_frame_count++;
- sprintf (namebuf, "F%d", tty_frame_count);
+ sprintf (namebuf, "F%"pMd, tty_frame_count);
name = build_string (namebuf);
}
else
val = values[i];
store_frame_param (f, prop, val);
- /* Changing the background color might change the background
- mode, so that we have to load new defface specs.
- Call frame-set-background-mode to do that. */
- if (EQ (prop, Qbackground_color))
- call1 (Qframe_set_background_mode, frame);
+ if (EQ (prop, Qforeground_color)
+ || EQ (prop, Qbackground_color))
+ update_face_from_frame_parameter (f, prop, val);
}
}
return Qnil;
/* Record in these vectors all the parms specified. */
Lisp_Object *parms;
Lisp_Object *values;
- size_t i, p;
+ ptrdiff_t i, p;
int left_no_change = 0, top_no_change = 0;
int icon_left_no_change = 0, icon_top_no_change = 0;
int size_changed = 0;
f->size_hint_flags &= ~ (XNegative | YNegative);
if (EQ (left, Qminus))
f->size_hint_flags |= XNegative;
- else if (INTEGERP (left))
+ else if (TYPE_RANGED_INTEGERP (int, left))
{
leftpos = XINT (left);
if (leftpos < 0)
}
else if (CONSP (left) && EQ (XCAR (left), Qminus)
&& CONSP (XCDR (left))
- && INTEGERP (XCAR (XCDR (left))))
+ && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (left)), INT_MAX))
{
leftpos = - XINT (XCAR (XCDR (left)));
f->size_hint_flags |= XNegative;
}
else if (CONSP (left) && EQ (XCAR (left), Qplus)
&& CONSP (XCDR (left))
- && INTEGERP (XCAR (XCDR (left))))
+ && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left))))
{
leftpos = XINT (XCAR (XCDR (left)));
}
if (EQ (top, Qminus))
f->size_hint_flags |= YNegative;
- else if (INTEGERP (top))
+ else if (TYPE_RANGED_INTEGERP (int, top))
{
toppos = XINT (top);
if (toppos < 0)
}
else if (CONSP (top) && EQ (XCAR (top), Qminus)
&& CONSP (XCDR (top))
- && INTEGERP (XCAR (XCDR (top))))
+ && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (top)), INT_MAX))
{
toppos = - XINT (XCAR (XCDR (top)));
f->size_hint_flags |= YNegative;
}
else if (CONSP (top) && EQ (XCAR (top), Qplus)
&& CONSP (XCDR (top))
- && INTEGERP (XCAR (XCDR (top))))
+ && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top))))
{
toppos = XINT (XCAR (XCDR (top)));
}
{
char buf[16];
Lisp_Object tem;
+ unsigned long w;
/* Represent negative positions (off the top or left screen edge)
in a way that Fmodify_frame_parameters will understand correctly. */
for non-toolkit scroll bar.
ruler-mode.el depends on this. */
: Qnil));
- sprintf (buf, "%ld", (long) FRAME_X_WINDOW (f));
+ /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
+ MS-Windows it returns a value whose type is HANDLE, which is
+ actually a pointer. Explicit casting avoids compiler
+ warnings. */
+ w = (unsigned long) FRAME_X_WINDOW (f);
+ sprintf (buf, "%lu", w);
store_in_alist (alistptr, Qwindow_id,
build_string (buf));
#ifdef HAVE_X_WINDOWS
/* Tooltip frame may not have this widget. */
if (FRAME_X_OUTPUT (f)->widget)
#endif
- sprintf (buf, "%ld", (long) FRAME_OUTER_WINDOW (f));
+ {
+ w = (unsigned long) FRAME_OUTER_WINDOW (f);
+ sprintf (buf, "%lu", w);
+ }
store_in_alist (alistptr, Qouter_window_id,
build_string (buf));
#endif
x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
do_pending_window_change (0);
}
- else if (INTEGERP (arg) && XINT (arg) > 0
+ else if (RANGED_INTEGERP (1, arg, INT_MAX)
&& XFASTINT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
{
if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM)
{
double alpha = 1.0;
double newval[2];
- int i, ialpha;
+ int i;
Lisp_Object item;
for (i = 0; i < 2; i++)
}
else if (INTEGERP (item))
{
- ialpha = XINT (item);
+ EMACS_INT ialpha = XINT (item);
if (ialpha < 0 || 100 < ialpha)
args_out_of_range (make_number (0), make_number (100));
else
void
validate_x_resource_name (void)
{
- int len = 0;
+ ptrdiff_t len = 0;
/* Number of valid characters in the resource name. */
- int good_count = 0;
+ ptrdiff_t good_count = 0;
/* Number of invalid characters in the resource name. */
- int bad_count = 0;
+ ptrdiff_t bad_count = 0;
Lisp_Object new;
- int i;
+ ptrdiff_t i;
if (!STRINGP (Vx_resource_class))
Vx_resource_class = build_string (EMACS_CLASS);
if (bad_count == 0)
return;
- /* If name is entirely invalid, or nearly so, use `emacs'. */
- if (good_count < 2)
+ /* If name is entirely invalid, or nearly so, or is so implausibly
+ large that alloca might not work, use `emacs'. */
+ if (good_count < 2 || MAX_ALLOCA - sizeof ".customization" < len)
{
Vx_resource_name = build_string ("emacs");
return;
{
char *name_key;
char *class_key;
+ char *result;
struct frame *sf = SELECTED_FRAME ();
+ ptrdiff_t invocation_namelen = SBYTES (Vinvocation_name);
+ USE_SAFE_ALLOCA;
/* Allocate space for the components, the dots which separate them,
and the final '\0'. */
- name_key = (char *) alloca (SBYTES (Vinvocation_name)
- + strlen (attribute) + 2);
+ SAFE_ALLOCA (name_key, char *, invocation_namelen + strlen (attribute) + 2);
class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
+ strlen (class) + 2);
- sprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute);
+ esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute);
sprintf (class_key, "%s.%s", EMACS_CLASS, class);
- return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb,
- name_key, class_key);
+ result = x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb,
+ name_key, class_key);
+ SAFE_FREE ();
+ return result;
}
#endif
if (!EQ (tem0, Qunbound))
{
CHECK_NUMBER (tem0);
+ if (! (0 <= XINT (tem0) && XINT (tem0) <= INT_MAX))
+ xsignal1 (Qargs_out_of_range, tem0);
FRAME_LINES (f) = XINT (tem0);
}
if (!EQ (tem1, Qunbound))
{
CHECK_NUMBER (tem1);
+ if (! (0 <= XINT (tem1) && XINT (tem1) <= INT_MAX))
+ xsignal1 (Qargs_out_of_range, tem1);
SET_FRAME_COLS (f, XINT (tem1));
}
if (!NILP (tem2) && !EQ (tem2, Qunbound))
? tool_bar_button_relief
: DEFAULT_TOOL_BAR_BUTTON_RELIEF);
- if (INTEGERP (Vtool_bar_button_margin)
- && XINT (Vtool_bar_button_margin) > 0)
+ if (RANGED_INTEGERP (1, Vtool_bar_button_margin, INT_MAX))
margin = XFASTINT (Vtool_bar_button_margin);
else if (CONSP (Vtool_bar_button_margin)
- && INTEGERP (XCDR (Vtool_bar_button_margin))
- && XINT (XCDR (Vtool_bar_button_margin)) > 0)
+ && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin), INT_MAX))
margin = XFASTINT (XCDR (Vtool_bar_button_margin));
else
margin = 0;
}
else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus)
&& CONSP (XCDR (tem0))
- && INTEGERP (XCAR (XCDR (tem0))))
+ && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (tem0)), INT_MAX))
{
f->top_pos = - XINT (XCAR (XCDR (tem0)));
window_prompting |= YNegative;
}
else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus)
&& CONSP (XCDR (tem0))
- && INTEGERP (XCAR (XCDR (tem0))))
+ && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0))))
{
f->top_pos = XINT (XCAR (XCDR (tem0)));
}
}
else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus)
&& CONSP (XCDR (tem1))
- && INTEGERP (XCAR (XCDR (tem1))))
+ && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (tem1)), INT_MAX))
{
f->left_pos = - XINT (XCAR (XCDR (tem1)));
window_prompting |= XNegative;
}
else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus)
&& CONSP (XCDR (tem1))
- && INTEGERP (XCAR (XCDR (tem1))))
+ && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1))))
{
f->left_pos = XINT (XCAR (XCDR (tem1)));
}
void
syms_of_frame (void)
{
- Qframep = intern_c_string ("framep");
- staticpro (&Qframep);
- Qframe_live_p = intern_c_string ("frame-live-p");
- staticpro (&Qframe_live_p);
- Qexplicit_name = intern_c_string ("explicit-name");
- staticpro (&Qexplicit_name);
- Qheight = intern_c_string ("height");
- staticpro (&Qheight);
- Qicon = intern_c_string ("icon");
- staticpro (&Qicon);
- Qminibuffer = intern_c_string ("minibuffer");
- staticpro (&Qminibuffer);
- Qmodeline = intern_c_string ("modeline");
- staticpro (&Qmodeline);
- Qonly = intern_c_string ("only");
- staticpro (&Qonly);
- Qwidth = intern_c_string ("width");
- staticpro (&Qwidth);
- Qgeometry = intern_c_string ("geometry");
- staticpro (&Qgeometry);
- Qicon_left = intern_c_string ("icon-left");
- staticpro (&Qicon_left);
- Qicon_top = intern_c_string ("icon-top");
- staticpro (&Qicon_top);
- Qtooltip = intern_c_string ("tooltip");
- staticpro (&Qtooltip);
- Qleft = intern_c_string ("left");
- staticpro (&Qleft);
- Qright = intern_c_string ("right");
- staticpro (&Qright);
- Quser_position = intern_c_string ("user-position");
- staticpro (&Quser_position);
- Quser_size = intern_c_string ("user-size");
- staticpro (&Quser_size);
- Qwindow_id = intern_c_string ("window-id");
- staticpro (&Qwindow_id);
+ DEFSYM (Qframep, "framep");
+ DEFSYM (Qframe_live_p, "frame-live-p");
+ DEFSYM (Qexplicit_name, "explicit-name");
+ DEFSYM (Qheight, "height");
+ DEFSYM (Qicon, "icon");
+ DEFSYM (Qminibuffer, "minibuffer");
+ DEFSYM (Qmodeline, "modeline");
+ DEFSYM (Qonly, "only");
+ DEFSYM (Qwidth, "width");
+ DEFSYM (Qgeometry, "geometry");
+ DEFSYM (Qicon_left, "icon-left");
+ DEFSYM (Qicon_top, "icon-top");
+ DEFSYM (Qtooltip, "tooltip");
+ DEFSYM (Qleft, "left");
+ DEFSYM (Qright, "right");
+ DEFSYM (Quser_position, "user-position");
+ DEFSYM (Quser_size, "user-size");
+ DEFSYM (Qwindow_id, "window-id");
#ifdef HAVE_X_WINDOWS
- Qouter_window_id = intern_c_string ("outer-window-id");
- staticpro (&Qouter_window_id);
+ DEFSYM (Qouter_window_id, "outer-window-id");
#endif
- Qparent_id = intern_c_string ("parent-id");
- staticpro (&Qparent_id);
- Qx = intern_c_string ("x");
- staticpro (&Qx);
- Qw32 = intern_c_string ("w32");
- staticpro (&Qw32);
- Qpc = intern_c_string ("pc");
- staticpro (&Qpc);
- Qmac = intern_c_string ("mac");
- staticpro (&Qmac);
- Qns = intern_c_string ("ns");
- staticpro (&Qns);
- Qvisible = intern_c_string ("visible");
- staticpro (&Qvisible);
- Qbuffer_predicate = intern_c_string ("buffer-predicate");
- staticpro (&Qbuffer_predicate);
- Qbuffer_list = intern_c_string ("buffer-list");
- staticpro (&Qbuffer_list);
- Qburied_buffer_list = intern_c_string ("buried-buffer-list");
- staticpro (&Qburied_buffer_list);
- Qdisplay_type = intern_c_string ("display-type");
- staticpro (&Qdisplay_type);
- Qbackground_mode = intern_c_string ("background-mode");
- staticpro (&Qbackground_mode);
- Qnoelisp = intern_c_string ("noelisp");
- staticpro (&Qnoelisp);
- Qtty_color_mode = intern_c_string ("tty-color-mode");
- staticpro (&Qtty_color_mode);
- Qtty = intern_c_string ("tty");
- staticpro (&Qtty);
- Qtty_type = intern_c_string ("tty-type");
- staticpro (&Qtty_type);
-
- Qface_set_after_frame_default = intern_c_string ("face-set-after-frame-default");
- staticpro (&Qface_set_after_frame_default);
-
- Qfullwidth = intern_c_string ("fullwidth");
- staticpro (&Qfullwidth);
- Qfullheight = intern_c_string ("fullheight");
- staticpro (&Qfullheight);
- Qfullboth = intern_c_string ("fullboth");
- staticpro (&Qfullboth);
- Qmaximized = intern_c_string ("maximized");
- staticpro (&Qmaximized);
- Qx_resource_name = intern_c_string ("x-resource-name");
- staticpro (&Qx_resource_name);
-
- Qx_frame_parameter = intern_c_string ("x-frame-parameter");
- staticpro (&Qx_frame_parameter);
-
- Qterminal = intern_c_string ("terminal");
- staticpro (&Qterminal);
- Qterminal_live_p = intern_c_string ("terminal-live-p");
- staticpro (&Qterminal_live_p);
+ DEFSYM (Qparent_id, "parent-id");
+ DEFSYM (Qx, "x");
+ DEFSYM (Qw32, "w32");
+ DEFSYM (Qpc, "pc");
+ DEFSYM (Qmac, "mac");
+ DEFSYM (Qns, "ns");
+ DEFSYM (Qvisible, "visible");
+ DEFSYM (Qbuffer_predicate, "buffer-predicate");
+ DEFSYM (Qbuffer_list, "buffer-list");
+ DEFSYM (Qburied_buffer_list, "buried-buffer-list");
+ DEFSYM (Qdisplay_type, "display-type");
+ DEFSYM (Qbackground_mode, "background-mode");
+ DEFSYM (Qnoelisp, "noelisp");
+ DEFSYM (Qtty_color_mode, "tty-color-mode");
+ DEFSYM (Qtty, "tty");
+ DEFSYM (Qtty_type, "tty-type");
+
+ DEFSYM (Qface_set_after_frame_default, "face-set-after-frame-default");
+
+ DEFSYM (Qfullwidth, "fullwidth");
+ DEFSYM (Qfullheight, "fullheight");
+ DEFSYM (Qfullboth, "fullboth");
+ DEFSYM (Qmaximized, "maximized");
+ DEFSYM (Qx_resource_name, "x-resource-name");
+ DEFSYM (Qx_frame_parameter, "x-frame-parameter");
+
+ DEFSYM (Qterminal, "terminal");
+ DEFSYM (Qterminal_live_p, "terminal-live-p");
#ifdef HAVE_NS
- Qns_parse_geometry = intern_c_string ("ns-parse-geometry");
- staticpro (&Qns_parse_geometry);
+ DEFSYM (Qns_parse_geometry, "ns-parse-geometry");
#endif
{
DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars,
doc: /* Default position of scroll bars on this window-system. */);
#ifdef HAVE_WINDOW_SYSTEM
-#if defined(HAVE_NTGUI) || defined(NS_IMPL_COCOA) || (defined(USE_GTK) && defined(USE_TOOLKIT_SCROLL_BARS))
+#if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
/* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
default. */
Vdefault_frame_scroll_bars = Qright;
in `delete-frame-functions' (indirectly) calls `delete-frame'
recursively). */);
Vdelete_frame_functions = Qnil;
- Qdelete_frame_functions = intern_c_string ("delete-frame-functions");
- staticpro (&Qdelete_frame_functions);
+ DEFSYM (Qdelete_frame_functions, "delete-frame-functions");
DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode,
doc: /* Non-nil if Menu-Bar mode is enabled.
defsubr (&Sframe_list);
defsubr (&Snext_frame);
defsubr (&Sprevious_frame);
- defsubr (&Sother_visible_frames_p);
defsubr (&Sdelete_frame);
defsubr (&Smouse_position);
defsubr (&Smouse_pixel_position);