summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1994-03-14 01:29:37 +0000
committerRichard M. Stallman <rms@gnu.org>1994-03-14 01:29:37 +0000
commit9c28748f65118e5a3f750bb871f832adeb7ea4da (patch)
treed61bfd3677e8ce77c9c274ffa0af12f8784e6bdd /src
parentf1ecfe9bc4c2aabf12cb15d11dc97d181b3779b2 (diff)
downloademacs-9c28748f65118e5a3f750bb871f832adeb7ea4da.tar.gz
(Finsert_file_contents): Don't let same_at_end be less than same_at_start.
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/fileio.c b/src/fileio.c
index a26e8010f7f..0e6f8b3aff0 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2607,6 +2607,8 @@ and (2) it puts less data in the undo list.")
char buffer[1 << 14];
int same_at_start = BEGV;
int same_at_end = ZV;
+ int overlap;
+
immediate_quit = 1;
QUIT;
/* Count how many chars at the start of the file
@@ -2678,9 +2680,16 @@ and (2) it puts less data in the undo list.")
break;
}
immediate_quit = 0;
+
+ /* Don't try to reuse the same piece of text twice. */
+ overlap = same_at_start - BEGV - (same_at_end + st.st_size - ZV);
+ if (overlap > 0)
+ same_at_end += overlap;
+
/* Arrange to read only the nonmatching middle part of the file. */
XFASTINT (beg) = same_at_start - BEGV;
XFASTINT (end) = st.st_size - (ZV - same_at_end);
+
del_range_1 (same_at_start, same_at_end, 0);
/* Insert from the file at the proper position. */
SET_PT (same_at_start);