(del_range_1, del_range_byte, del_range_both): Handle
authorGerd Moellmann <gerd@gnu.org>
Tue, 13 Feb 2001 16:29:20 +0000 (16:29 +0000)
committerGerd Moellmann <gerd@gnu.org>
Tue, 13 Feb 2001 16:29:20 +0000 (16:29 +0000)
case that TO ends up beyond ZV after running before-change-functions.

src/ChangeLog
src/insdel.c

index 670e999..3d7451d 100644 (file)
@@ -1,5 +1,8 @@
 2001-02-13  Gerd Moellmann  <gerd@gnu.org>
 
+       * insdel.c (del_range_1, del_range_byte, del_range_both): Handle
+       case that TO ends up beyond ZV after running before-change-functions.
+
        * window.c (window_loop) <GET_BUFFER_WINDOW>: Prefer to return
        the selected window if it is showing the buffer in question.
 
index 5574f85..7ea1181 100644 (file)
@@ -1552,7 +1552,7 @@ del_range_1 (from, to, prepare, ret_string)
     {
       int range_length = to - from;
       prepare_to_modify_buffer (from, to, &from);
-      to = from + range_length;
+      to = min (ZV, from + range_length);
     }
 
   from_byte = CHAR_TO_BYTE (from);
@@ -1595,7 +1595,12 @@ del_range_byte (from_byte, to_byte, prepare)
 
       if (old_from != from)
        from_byte = CHAR_TO_BYTE (from);
-      if (old_to == Z - to)
+      if (to > ZV)
+       {
+         to = ZV;
+         to_byte = ZV_BYTE;
+       }
+      else if (old_to == Z - to)
        to_byte = CHAR_TO_BYTE (to);
     }
 
@@ -1634,7 +1639,12 @@ del_range_both (from, from_byte, to, to_byte, prepare)
 
       if (old_from != from)
        from_byte = CHAR_TO_BYTE (from);
-      if (old_to == Z - to)
+      if (to > ZV)
+       {
+         to = ZV;
+         to_byte = ZV_BYTE;
+       }
+      else if (old_to == Z - to)
        to_byte = CHAR_TO_BYTE (to);
     }