diff options
| author | Richard M. Stallman | 1994-03-14 01:29:37 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-03-14 01:29:37 +0000 |
| commit | 9c28748f65118e5a3f750bb871f832adeb7ea4da (patch) | |
| tree | d61bfd3677e8ce77c9c274ffa0af12f8784e6bdd /src | |
| parent | f1ecfe9bc4c2aabf12cb15d11dc97d181b3779b2 (diff) | |
| download | emacs-9c28748f65118e5a3f750bb871f832adeb7ea4da.tar.gz emacs-9c28748f65118e5a3f750bb871f832adeb7ea4da.zip | |
(Finsert_file_contents): Don't let same_at_end be less than same_at_start.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 9 |
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.") | |||
| 2607 | char buffer[1 << 14]; | 2607 | char buffer[1 << 14]; |
| 2608 | int same_at_start = BEGV; | 2608 | int same_at_start = BEGV; |
| 2609 | int same_at_end = ZV; | 2609 | int same_at_end = ZV; |
| 2610 | int overlap; | ||
| 2611 | |||
| 2610 | immediate_quit = 1; | 2612 | immediate_quit = 1; |
| 2611 | QUIT; | 2613 | QUIT; |
| 2612 | /* Count how many chars at the start of the file | 2614 | /* Count how many chars at the start of the file |
| @@ -2678,9 +2680,16 @@ and (2) it puts less data in the undo list.") | |||
| 2678 | break; | 2680 | break; |
| 2679 | } | 2681 | } |
| 2680 | immediate_quit = 0; | 2682 | immediate_quit = 0; |
| 2683 | |||
| 2684 | /* Don't try to reuse the same piece of text twice. */ | ||
| 2685 | overlap = same_at_start - BEGV - (same_at_end + st.st_size - ZV); | ||
| 2686 | if (overlap > 0) | ||
| 2687 | same_at_end += overlap; | ||
| 2688 | |||
| 2681 | /* Arrange to read only the nonmatching middle part of the file. */ | 2689 | /* Arrange to read only the nonmatching middle part of the file. */ |
| 2682 | XFASTINT (beg) = same_at_start - BEGV; | 2690 | XFASTINT (beg) = same_at_start - BEGV; |
| 2683 | XFASTINT (end) = st.st_size - (ZV - same_at_end); | 2691 | XFASTINT (end) = st.st_size - (ZV - same_at_end); |
| 2692 | |||
| 2684 | del_range_1 (same_at_start, same_at_end, 0); | 2693 | del_range_1 (same_at_start, same_at_end, 0); |
| 2685 | /* Insert from the file at the proper position. */ | 2694 | /* Insert from the file at the proper position. */ |
| 2686 | SET_PT (same_at_start); | 2695 | SET_PT (same_at_start); |