Commit 8801a864 authored by Ken Raeburn's avatar Ken Raeburn

* lisp.h (XCONS, XSTRING, XSYMBOL, XFLOAT, XPROCESS, XWINDOW, XSUBR, XBUFFER):

Verify correct object type before returning pointer, using eassert.
* frame.h (XFRAME): Likewise.

* buffer.c (Frename_buffer, Fset_buffer_multibyte,
swap_out_buffer_local_variables, Fmove_overlay): Don't apply XSYMBOL, XBUFFER,
etc, to values that may be nil or of the wrong type.
* data.c (set_internal): Likewise.
* dispextern.h (WINDOW_WANTS_MODELINE_P, WINDOW_WANTS_HEADER_LINE_P): Likewise.
* fileio.c (auto_save_1): Likewise.
* insdel.c (check_markers): Likewise.
* marker.c (buf_charpos_to_bytepos, unchain_marker): Likewise.
* undo.c (record_insert): Likewise.
* vmsproc.c (child_sig): Likewise.
* window.c (unshow_buffer, window_loop): Likewise.
* xterm.c (x_erase_phys_cursor): Likewise.
parent 326855a0
No preview for this file type
......@@ -887,14 +887,14 @@ This does not change the name of the visited file (if any).")
error ("Empty string is invalid as a buffer name");
tem = Fget_buffer (newname);
/* Don't short-circuit if UNIQUE is t. That is a useful way to rename
the buffer automatically so you can create another with the original name.
It makes UNIQUE equivalent to
(rename-buffer (generate-new-buffer-name NEWNAME)). */
if (NILP (unique) && XBUFFER (tem) == current_buffer)
return current_buffer->name;
if (!NILP (tem))
{
/* Don't short-circuit if UNIQUE is t. That is a useful way to
rename the buffer automatically so you can create another
with the original name. It makes UNIQUE equivalent to
(rename-buffer (generate-new-buffer-name NEWNAME)). */
if (NILP (unique) && XBUFFER (tem) == current_buffer)
return current_buffer->name;
if (!NILP (unique))
newname = Fgenerate_new_buffer_name (newname, current_buffer->name);
else
......@@ -1815,7 +1815,7 @@ but the contents viewed as characters do change.")
TEMP_SET_PT_BOTH (PT_BYTE, PT_BYTE);
tail = BUF_MARKERS (current_buffer);
while (XSYMBOL (tail) != XSYMBOL (Qnil))
while (! NILP (tail))
{
XMARKER (tail)->charpos = XMARKER (tail)->bytepos;
tail = XMARKER (tail)->chain;
......@@ -1880,7 +1880,7 @@ but the contents viewed as characters do change.")
It is also a signal that it should never create a marker. */
BUF_MARKERS (current_buffer) = Qnil;
while (XSYMBOL (tail) != XSYMBOL (Qnil))
while (! NILP (tail))
{
XMARKER (tail)->bytepos
= advance_to_char_boundary (XMARKER (tail)->bytepos);
......@@ -1996,7 +1996,7 @@ swap_out_buffer_local_variables (b)
/* Need not do anything if some other buffer's binding is now encached. */
tem = XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->buffer;
if (XBUFFER (tem) == current_buffer)
if (BUFFERP (tem) && XBUFFER (tem) == current_buffer)
{
/* Symbol is set up for this buffer's old local value.
Set it up for the current buffer with the default value. */
......@@ -3166,7 +3166,7 @@ buffer.")
obuffer = Fmarker_buffer (OVERLAY_START (overlay));
b = XBUFFER (buffer);
ob = XBUFFER (obuffer);
ob = BUFFERP (obuffer) ? XBUFFER (obuffer) : (struct buffer *) 0;
/* If the overlay has changed buffers, do a thorough redisplay. */
if (!EQ (buffer, obuffer))
......
......@@ -1012,7 +1012,8 @@ set_internal (symbol, newval, buf, bindflag)
isn't the right one, or if it's a Lisp_Buffer_Local_Value and
the default binding is loaded, the loaded binding may be the
wrong one. */
if (buf != XBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer)
if (!BUFFERP (XBUFFER_LOCAL_VALUE (valcontents)->buffer)
|| buf != XBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer)
|| (XBUFFER_LOCAL_VALUE (valcontents)->check_frame
&& !EQ (selected_frame, XBUFFER_LOCAL_VALUE (valcontents)->frame))
|| (BUFFER_LOCAL_VALUEP (valcontents)
......
......@@ -1066,6 +1066,7 @@ extern struct glyph_row scratch_glyph_row;
(!MINI_WINDOW_P (W) \
&& !(W)->pseudo_window_p \
&& FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME (W))) \
&& BUFFERP ((W)->buffer) \
&& !NILP (XBUFFER ((W)->buffer)->mode_line_format))
/* Value is non-zero if window W wants a top line. */
......@@ -1074,6 +1075,7 @@ extern struct glyph_row scratch_glyph_row;
(!MINI_WINDOW_P (W) \
&& !(W)->pseudo_window_p \
&& FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME (W))) \
&& BUFFERP ((W)->buffer) \
&& !NILP (XBUFFER ((W)->buffer)->header_line_format))
......
......@@ -5144,7 +5144,8 @@ auto_save_1 ()
struct stat st;
/* Get visited file's mode to become the auto save file's mode. */
if (stat (XSTRING (current_buffer->filename)->data, &st) >= 0)
if (! NILP (current_buffer->filename)
&& stat (XSTRING (current_buffer->filename)->data, &st) >= 0)
/* But make sure we can overwrite it later! */
auto_save_mode_bits = st.st_mode | 0600;
else
......
......@@ -383,7 +383,7 @@ struct frame
typedef struct frame *FRAME_PTR;
#define XFRAME(p) ((struct frame *) XPNTR (p))
#define XFRAME(p) (eassert (GC_FRAMEP(p)),(struct frame *) XPNTR (p))
#define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
/* Given a window, return its frame as a Lisp_Object. */
......
......@@ -83,7 +83,7 @@ check_markers ()
tail = BUF_MARKERS (current_buffer);
while (XSYMBOL (tail) != XSYMBOL (Qnil))
while (! NILP (tail))
{
if (XMARKER (tail)->buffer->text != current_buffer->text)
abort ();
......
......@@ -432,11 +432,11 @@ extern Lisp_Object make_number ();
/* Extract a value or address from a Lisp_Object. */
#define XCONS(a) ((struct Lisp_Cons *) XPNTR(a))
#define XCONS(a) (eassert (GC_CONSP(a)),(struct Lisp_Cons *) XPNTR(a))
#define XVECTOR(a) ((struct Lisp_Vector *) XPNTR(a))
#define XSTRING(a) ((struct Lisp_String *) XPNTR(a))
#define XSYMBOL(a) ((struct Lisp_Symbol *) XPNTR(a))
#define XFLOAT(a) ((struct Lisp_Float *) XPNTR(a))
#define XSTRING(a) (eassert (GC_STRINGP(a)),(struct Lisp_String *) XPNTR(a))
#define XSYMBOL(a) (eassert (GC_SYMBOLP(a)),(struct Lisp_Symbol *) XPNTR(a))
#define XFLOAT(a) (eassert (GC_FLOATP(a)),(struct Lisp_Float *) XPNTR(a))
/* Misc types. */
#define XMISC(a) ((union Lisp_Misc *) XPNTR(a))
......@@ -451,10 +451,10 @@ extern Lisp_Object make_number ();
#define XKBOARD_OBJFWD(a) (&(XMISC(a)->u_kboard_objfwd))
/* Pseudovector types. */
#define XPROCESS(a) ((struct Lisp_Process *) XPNTR(a))
#define XWINDOW(a) ((struct window *) XPNTR(a))
#define XSUBR(a) ((struct Lisp_Subr *) XPNTR(a))
#define XBUFFER(a) ((struct buffer *) XPNTR(a))
#define XPROCESS(a) (eassert (GC_PROCESSP(a)),(struct Lisp_Process *) XPNTR(a))
#define XWINDOW(a) (eassert (GC_WINDOWP(a)),(struct window *) XPNTR(a))
#define XSUBR(a) (eassert (GC_SUBRP(a)),(struct Lisp_Subr *) XPNTR(a))
#define XBUFFER(a) (eassert (GC_BUFFERP(a)),(struct buffer *) XPNTR(a))
#define XCHAR_TABLE(a) ((struct Lisp_Char_Table *) XPNTR(a))
#define XBOOL_VECTOR(a) ((struct Lisp_Bool_Vector *) XPNTR(a))
......
......@@ -168,7 +168,7 @@ buf_charpos_to_bytepos (b, charpos)
CONSIDER (cached_charpos, cached_bytepos);
tail = BUF_MARKERS (b);
while (XSYMBOL (tail) != XSYMBOL (Qnil))
while (! NILP (tail))
{
CONSIDER (XMARKER (tail)->charpos, XMARKER (tail)->bytepos);
......@@ -336,7 +336,7 @@ buf_bytepos_to_charpos (b, bytepos)
CONSIDER (cached_bytepos, cached_charpos);
tail = BUF_MARKERS (b);
while (XSYMBOL (tail) != XSYMBOL (Qnil))
while (! NILP (tail))
{
CONSIDER (XMARKER (tail)->bytepos, XMARKER (tail)->charpos);
......@@ -747,7 +747,7 @@ unchain_marker (marker)
tail = BUF_MARKERS (b);
prev = Qnil;
while (XSYMBOL (tail) != XSYMBOL (Qnil))
while (! GC_NILP (tail))
{
next = XMARKER (tail)->chain;
XUNMARK (next);
......
......@@ -54,7 +54,8 @@ record_insert (beg, length)
if (NILP (pending_boundary))
pending_boundary = Fcons (Qnil, Qnil);
if (current_buffer != XBUFFER (last_undo_buffer))
if (!BUFFERP (last_undo_buffer)
|| current_buffer != XBUFFER (last_undo_buffer))
Fundo_boundary ();
XSETBUFFER (last_undo_buffer, current_buffer);
......
......@@ -758,7 +758,7 @@ child_sig (vs)
pid = vs->pid;
sys$setef (vs->eventFlag);
for (tail = Vprocess_alist; XSYMBOL (tail) != XSYMBOL (Qnil); tail = XCDR (tail))
for (tail = Vprocess_alist; ! NILP (tail); tail = XCDR (tail))
{
proc = XCDR (XCAR (tail));
p = XPROCESS (proc);
......@@ -766,7 +766,7 @@ child_sig (vs)
break;
}
if (XSYMBOL (tail) == XSYMBOL (Qnil))
if (NILP (tail))
return;
p->status = Fcons (Qexit, Fcons (make_number (vs->exitStatus), Qnil))
......
......@@ -905,7 +905,8 @@ unshow_buffer (w)
So don't clobber point in that buffer. */
if (! EQ (buf, XWINDOW (selected_window)->buffer)
/* This line helps to fix Horsley's testbug.el bug. */
&& !(w != XWINDOW (b->last_selected_window)
&& !(WINDOWP (b->last_selected_window)
&& w != XWINDOW (b->last_selected_window)
&& EQ (buf, XWINDOW (b->last_selected_window)->buffer)))
temp_set_point_both (b,
clip_to_bounds (BUF_BEGV (b),
......@@ -915,7 +916,8 @@ unshow_buffer (w)
marker_byte_position (w->pointm),
BUF_ZV_BYTE (b)));
if (w == XWINDOW (b->last_selected_window))
if (WINDOWP (b->last_selected_window)
&& w == XWINDOW (b->last_selected_window))
b->last_selected_window = Qnil;
}
......@@ -1633,7 +1635,8 @@ window_loop (type, obj, mini, frames)
case GET_LARGEST_WINDOW:
/* Ignore dedicated windows and minibuffers. */
if (MINI_WINDOW_P (XWINDOW (w))
|| !NILP (XWINDOW (w)->dedicated))
|| !NILP (XWINDOW (w)->dedicated)
|| NILP (best_window))
break;
{
struct window *best_window_ptr = XWINDOW (best_window);
......
......@@ -10225,7 +10225,8 @@ x_erase_phys_cursor (w)
/* If the cursor is in the mouse face area, redisplay that when
we clear the cursor. */
if (w == XWINDOW (dpyinfo->mouse_face_window)
if (! NILP (dpyinfo->mouse_face_window)
&& w == XWINDOW (dpyinfo->mouse_face_window)
&& (vpos > dpyinfo->mouse_face_beg_row
|| (vpos == dpyinfo->mouse_face_beg_row
&& hpos >= dpyinfo->mouse_face_beg_col))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment