changeset 36070:2a1ee495a194

(del_range_1, del_range_byte, del_range_both): Handle case that TO ends up beyond ZV after running before-change-functions.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 13 Feb 2001 16:28:36 +0000
parents c71ca27faca4
children 25ad8ec698df
files src/insdel.c
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/insdel.c	Tue Feb 13 15:44:58 2001 +0000
+++ b/src/insdel.c	Tue Feb 13 16:28:36 2001 +0000
@@ -1552,7 +1552,7 @@
     {
       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 @@
 
       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 @@
 
       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);
     }