diff src/buffer.c @ 28417:4b675266db04

* 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.
author Ken Raeburn <raeburn@raeburn.org>
date Thu, 30 Mar 2000 09:56:31 +0000
parents 1555145f8c35
children 5da961b04d97
line wrap: on
line diff
--- a/src/buffer.c	Thu Mar 30 09:37:06 2000 +0000
+++ b/src/buffer.c	Thu Mar 30 09:56:31 2000 +0000
@@ -887,14 +887,14 @@
     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 @@
       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 @@
 	 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 @@
 
       /* 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 @@
 
   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))