(cl-macroexpand-all): Declare.
[bpt/emacs.git] / src / insdel.c
index 6736b22..a41f03b 100644 (file)
@@ -1,13 +1,14 @@
 /* Buffer insertion/deletion and gap motion for GNU Emacs.
    Copyright (C) 1985, 1986, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
-                 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+                 2002, 2003, 2004, 2005, 2006, 2007, 2008
+                 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,9 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
 #include <config.h>
@@ -415,13 +414,8 @@ adjust_markers_for_insert (from, from_byte, to, to_byte, before_markers)
 
   for (m = BUF_MARKERS (current_buffer); m; m = m->next)
     {
-      /* In a single-byte buffer, a marker's two positions must be
-        equal.  */
-      if (Z == Z_BYTE)
-       {
-         if (m->charpos != m->bytepos)
-           abort ();
-       }
+      eassert (m->bytepos >= m->charpos
+              && m->bytepos - m->charpos <= Z_BYTE - Z);
 
       if (m->bytepos == from_byte)
        {
@@ -468,9 +462,7 @@ adjust_point (nchars, nbytes)
   BUF_PT_BYTE (current_buffer) += nbytes;
 
   /* In a single-byte buffer, the two positions must be equal.  */
-  if (ZV == ZV_BYTE
-      && PT != PT_BYTE)
-    abort ();
+  eassert (PT_BYTE >= PT && PT_BYTE - PT <= ZV_BYTE - ZV);
 }
 \f
 /* Adjust markers for a replacement of a text at FROM (FROM_BYTE) of
@@ -1178,7 +1170,7 @@ insert_from_string_1 (string, pos, pos_byte, nchars, nbytes,
 
 void
 insert_from_gap (nchars, nbytes)
-     register int nchars, nbytes;
+     register EMACS_INT nchars, nbytes;
 {
   if (NILP (current_buffer->enable_multibyte_characters))
     nchars = nbytes;
@@ -1358,7 +1350,7 @@ insert_from_buffer_1 (buf, from, nchars, inherit)
 
   /* Get the intervals for the part of the string we are inserting.  */
   intervals = BUF_INTERVALS (buf);
-  if (outgoing_nbytes < BUF_Z_BYTE (buf) - BUF_BEG_BYTE (buf))
+  if (nchars < BUF_Z (buf) - BUF_BEG (buf))
     {
       if (buf == current_buffer && PT <= from)
        from += nchars;
@@ -2171,10 +2163,11 @@ prepare_to_modify_buffer (start, end, preserve_ptr)
   (! NILP (end_marker) ? Fmarker_position (end_marker) : end)
 
 /* Set a variable to nil if an error occurred.
-   VAL is a cons-cell whose car is the variable name, and whose cdr is
-   either nil (to mean that there was indeed an error), or non-nil to mean
-   that the was no error (which thus causes this function to do
-   nothing).  */
+   Don't change the variable if there was no error.
+   VAL is a cons-cell (VARIABLE . NO-ERROR-FLAG).
+   VARIABLE is the variable to maybe set to nil.
+   NO-ERROR-FLAG is nil if there was an error,
+   anything else meaning no error (so this function does nothing).  */
 Lisp_Object
 reset_var_on_error (val)
      Lisp_Object val;