\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. */
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
(Lisp_Object frame, Lisp_Object x, Lisp_Object y)
{
CHECK_LIVE_FRAME (frame);
- CHECK_NUMBER (x);
- CHECK_NUMBER (y);
+ CHECK_TYPE_RANGED_INTEGER (int, x);
+ CHECK_TYPE_RANGED_INTEGER (int, y);
/* I think this should be done with a hook. */
#ifdef HAVE_WINDOW_SYSTEM
(Lisp_Object frame, Lisp_Object x, Lisp_Object y)
{
CHECK_LIVE_FRAME (frame);
- CHECK_NUMBER (x);
- CHECK_NUMBER (y);
+ CHECK_TYPE_RANGED_INTEGER (int, x);
+ CHECK_TYPE_RANGED_INTEGER (int, y);
/* I think this should be done with a hook. */
#ifdef HAVE_WINDOW_SYSTEM
}
static int
-frame_name_fnn_p (char *str, EMACS_INT len)
+frame_name_fnn_p (char *str, ptrdiff_t len)
{
if (len > 1 && str[0] == 'F' && '0' <= str[1] && str[1] <= '9')
{
/* 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
if (STRINGP (value) && !FRAME_WINDOW_P (f))
{
const char *color_name;
- EMACS_INT csz;
+ ptrdiff_t csz;
if (EQ (parameter, Qbackground_color))
{
#endif
{
- int length = XINT (Flength (alist));
- int i;
- Lisp_Object *parms
- = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
- Lisp_Object *values
- = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
+ EMACS_INT length = XFASTINT (Flength (alist));
+ ptrdiff_t i;
+ Lisp_Object *parms;
+ Lisp_Object *values;
+ USE_SAFE_ALLOCA;
+ SAFE_ALLOCA_LISP (parms, 2 * length);
+ values = parms + length;
/* Extract parm names and values into those vectors. */
|| EQ (prop, Qbackground_color))
update_face_from_frame_parameter (f, prop, val);
}
+
+ SAFE_FREE ();
}
return Qnil;
}
{
register struct frame *f;
- CHECK_NUMBER (lines);
+ CHECK_TYPE_RANGED_INTEGER (int, lines);
if (NILP (frame))
frame = selected_frame;
CHECK_LIVE_FRAME (frame);
(Lisp_Object frame, Lisp_Object cols, Lisp_Object pretend)
{
register struct frame *f;
- CHECK_NUMBER (cols);
+ CHECK_TYPE_RANGED_INTEGER (int, cols);
if (NILP (frame))
frame = selected_frame;
CHECK_LIVE_FRAME (frame);
register struct frame *f;
CHECK_LIVE_FRAME (frame);
- CHECK_NUMBER (cols);
- CHECK_NUMBER (rows);
+ CHECK_TYPE_RANGED_INTEGER (int, cols);
+ CHECK_TYPE_RANGED_INTEGER (int, rows);
f = XFRAME (frame);
/* I think this should be done with a hook. */
register struct frame *f;
CHECK_LIVE_FRAME (frame);
- CHECK_NUMBER (xoffset);
- CHECK_NUMBER (yoffset);
+ CHECK_TYPE_RANGED_INTEGER (int, xoffset);
+ CHECK_TYPE_RANGED_INTEGER (int, yoffset);
f = XFRAME (frame);
/* I think this should be done with a hook. */
prop = parms[i];
val = values[i];
- if (EQ (prop, Qwidth) && NATNUMP (val))
+ if (EQ (prop, Qwidth) && RANGED_INTEGERP (0, val, INT_MAX))
{
size_changed = 1;
width = XFASTINT (val);
}
- else if (EQ (prop, Qheight) && NATNUMP (val))
+ else if (EQ (prop, Qheight) && RANGED_INTEGERP (0, val, INT_MAX))
{
size_changed = 1;
height = XFASTINT (val);
}
/* Don't die if just one of these was set. */
- if (EQ (left, Qunbound))
+ if (! TYPE_RANGED_INTEGERP (int, left))
{
left_no_change = 1;
if (f->left_pos < 0)
else
XSETINT (left, f->left_pos);
}
- if (EQ (top, Qunbound))
+ if (! TYPE_RANGED_INTEGERP (int, top))
{
top_no_change = 1;
if (f->top_pos < 0)
}
/* If one of the icon positions was not set, preserve or default it. */
- if (EQ (icon_left, Qunbound) || ! INTEGERP (icon_left))
+ if (! TYPE_RANGED_INTEGERP (int, icon_left))
{
icon_left_no_change = 1;
icon_left = Fcdr (Fassq (Qicon_left, f->param_alist));
if (NILP (icon_left))
XSETINT (icon_left, 0);
}
- if (EQ (icon_top, Qunbound) || ! INTEGERP (icon_top))
+ if (! TYPE_RANGED_INTEGERP (int, icon_top))
{
icon_top_no_change = 1;
icon_top = Fcdr (Fassq (Qicon_top, f->param_alist));
{
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
{
if (NILP (new_value))
f->extra_line_spacing = 0;
- else if (NATNUMP (new_value))
+ else if (RANGED_INTEGERP (0, new_value, INT_MAX))
f->extra_line_spacing = XFASTINT (new_value);
else
signal_error ("Invalid line-spacing", new_value);
void
x_set_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
- CHECK_NUMBER (arg);
+ CHECK_TYPE_RANGED_INTEGER (int, arg);
if (XINT (arg) == f->border_width)
return;
{
int old = FRAME_INTERNAL_BORDER_WIDTH (f);
- CHECK_NUMBER (arg);
+ CHECK_TYPE_RANGED_INTEGER (int, arg);
FRAME_INTERNAL_BORDER_WIDTH (f) = XINT (arg);
if (FRAME_INTERNAL_BORDER_WIDTH (f) < 0)
FRAME_INTERNAL_BORDER_WIDTH (f) = 0;
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
f->top_pos = 0;
else
{
- CHECK_NUMBER (tem0);
+ CHECK_TYPE_RANGED_INTEGER (int, tem0);
f->top_pos = XINT (tem0);
if (f->top_pos < 0)
window_prompting |= YNegative;
f->left_pos = 0;
else
{
- CHECK_NUMBER (tem1);
+ CHECK_TYPE_RANGED_INTEGER (int, tem1);
f->left_pos = XINT (tem1);
if (f->left_pos < 0)
window_prompting |= XNegative;
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;
defsubr (&Sframe_list);
defsubr (&Snext_frame);
defsubr (&Sprevious_frame);
- defsubr (&Sother_visible_frames_p);
defsubr (&Sdelete_frame);
defsubr (&Smouse_position);
defsubr (&Smouse_pixel_position);