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.
+2000-03-30 Ken Raeburn <raeburn@gnu.org>
+
+ * 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.
+
2000-03-30 Gerd Moellmann <gerd@gnu.org>
* xfns.c (free_image_cache): Free the cache structure itself
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
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;
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);
/* 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. */
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))
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)
(!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. */
(!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))
\f
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
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. */
tail = BUF_MARKERS (current_buffer);
- while (XSYMBOL (tail) != XSYMBOL (Qnil))
+ while (! NILP (tail))
{
if (XMARKER (tail)->buffer->text != current_buffer->text)
abort ();
/* 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))
#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))
CONSIDER (cached_charpos, cached_bytepos);
tail = BUF_MARKERS (b);
- while (XSYMBOL (tail) != XSYMBOL (Qnil))
+ while (! NILP (tail))
{
CONSIDER (XMARKER (tail)->charpos, XMARKER (tail)->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);
tail = BUF_MARKERS (b);
prev = Qnil;
- while (XSYMBOL (tail) != XSYMBOL (Qnil))
+ while (! GC_NILP (tail))
{
next = XMARKER (tail)->chain;
XUNMARK (next);
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);
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);
break;
}
- if (XSYMBOL (tail) == XSYMBOL (Qnil))
+ if (NILP (tail))
return;
p->status = Fcons (Qexit, Fcons (make_number (vs->exitStatus), Qnil))
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),
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;
}
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);
/* 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))