summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1996-12-16 05:46:37 +0000
committerRichard M. Stallman <rms@gnu.org>1996-12-16 05:46:37 +0000
commit6819716954cb7a0e55ba48db59d85179c6547b77 (patch)
treebb9a23a36a481f8ab9239af3df03b3038f6ff0c3 /src
parent9b55d7eeac69425c2ddbb1a43a91d1c36060ce6a (diff)
downloademacs-6819716954cb7a0e55ba48db59d85179c6547b77.tar.gz
(Finsert_file_contents): Handle BEG and END non-nil
when REPLACE is non-nil.
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 20419fe394a..9b09b0e32c0 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3117,8 +3117,6 @@ and (2) it puts less data in the undo list.")
if (!NILP (replace))
{
replace = Qnil;
- XSETFASTINT (beg, 0);
- XSETFASTINT (end, st.st_size);
del_range_1 (BEGV, ZV, 0);
}
#else /* not DOS_NT */
@@ -3129,6 +3127,13 @@ and (2) it puts less data in the undo list.")
int same_at_end = ZV;
int overlap;
+ if (XINT (beg) != 0)
+ {
+ if (lseek (fd, XINT (beg), 0) < 0)
+ report_file_error ("Setting file position",
+ Fcons (filename, Qnil));
+ }
+
immediate_quit = 1;
QUIT;
/* Count how many chars at the start of the file
@@ -3155,7 +3160,7 @@ and (2) it puts less data in the undo list.")
immediate_quit = 0;
/* If the file matches the buffer completely,
there's no need to replace anything. */
- if (same_at_start - BEGV == st.st_size)
+ if (same_at_start - BEGV == XINT (end))
{
close (fd);
specpdl_ptr--;
@@ -3172,7 +3177,7 @@ and (2) it puts less data in the undo list.")
int total_read, nread, bufpos, curpos, trial;
/* At what file position are we now scanning? */
- curpos = st.st_size - (ZV - same_at_end);
+ curpos = XINT (end) - (ZV - same_at_end);
/* If the entire file matches the buffer tail, stop the scan. */
if (curpos == 0)
break;
@@ -3216,8 +3221,8 @@ and (2) it puts less data in the undo list.")
same_at_end += overlap;
/* Arrange to read only the nonmatching middle part of the file. */
- XSETFASTINT (beg, same_at_start - BEGV);
- XSETFASTINT (end, st.st_size - (ZV - same_at_end));
+ XSETFASTINT (beg, XINT (beg) + (same_at_start - BEGV));
+ XSETFASTINT (end, XINT (end) - (ZV - same_at_end));
del_range_1 (same_at_start, same_at_end, 0);
/* Insert from the file at the proper position. */