Make variable forwarding explicit rather the using special values.
[bpt/emacs.git] / src / insdel.c
index bdd4505..6cc797a 100644 (file)
@@ -1,6 +1,6 @@
 /* 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, 2008, 2009
+                 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
                  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -54,7 +54,7 @@ static void adjust_point (EMACS_INT nchars, EMACS_INT nbytes);
 Lisp_Object Fcombine_after_change_execute ();
 
 /* Non-nil means don't call the after-change-functions right away,
-   just record an element in Vcombine_after_change_calls_list.  */
+   just record an element in combine_after_change_list.  */
 Lisp_Object Vcombine_after_change_calls;
 
 /* List of elements of the form (BEG-UNCHANGED END-UNCHANGED CHANGE-AMOUNT)
@@ -370,14 +370,14 @@ adjust_markers_for_delete (EMACS_INT from, EMACS_INT from_byte,
               re-inserted text after undoing a deletion, and must be
               adjusted to move them to the correct place.  */
              XSETMISC (marker, m);
-           record_marker_adjustment (marker, from - charpos);
+             record_marker_adjustment (marker, from - charpos);
            }
          else if (charpos < to)
            { /* Before-insertion markers will automatically move forward
               upon re-inserting the deleted text, so we have to arrange
               for them to move backward to the correct position.  */
              XSETMISC (marker, m);
-           record_marker_adjustment (marker, charpos - to);
+             record_marker_adjustment (marker, to - charpos);
            }
          m->charpos = from;
          m->bytepos = from_byte;
@@ -512,16 +512,16 @@ make_gap_larger (EMACS_INT nbytes_added)
   /* If we have to get more space, get enough to last a while.  */
   nbytes_added += 2000;
 
-  /* Don't allow a buffer size that won't fit in an int
-     even if it will fit in a Lisp integer.
-     That won't work because so many places use `int'.
-
-     Make sure we don't introduce overflows in the calculation.  */
-
-  if (Z_BYTE - BEG_BYTE + GAP_SIZE
-      >= (((EMACS_INT) 1 << (min (VALBITS, BITS_PER_INT) - 1)) - 1
-         - nbytes_added))
-    error ("Buffer exceeds maximum size");
+  { EMACS_INT total_size = Z_BYTE - BEG_BYTE + GAP_SIZE + nbytes_added;
+    if (total_size < 0
+       /* Don't allow a buffer size that won't fit in a Lisp integer.  */
+       || total_size != XINT (make_number (total_size))
+       /* Don't allow a buffer size that won't fit in an int
+          even if it will fit in a Lisp integer.
+          That won't work because so many places still use `int'.  */
+       || total_size != (EMACS_INT) (int) total_size)
+      error ("Buffer exceeds maximum size");
+  }
 
   enlarge_buffer_text (current_buffer, nbytes_added);
 
@@ -648,7 +648,7 @@ copy_text (const unsigned char *from_addr, unsigned char *to_addr,
       while (bytes_left > 0)
        {
          int thislen, c;
-         c = STRING_CHAR_AND_LENGTH (from_addr, bytes_left, thislen);
+         c = STRING_CHAR_AND_LENGTH (from_addr, thislen);
          if (! ASCII_CHAR_P (c))
            c &= 0xFF;
          *to_addr++ = c;