From 4c95c9a594ade5a642e32be77ff58b60a89b7a7a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 13 Dec 2012 11:35:10 -0800 Subject: [PATCH] * fileio.c (Finsert_file_contents): Don't put tail into head area, as that confuses set-auto-coding, so insist on the head-read returning the full 1024 bytes. Let lseek compute the tail offset; less work for us. Do not ignore I/O errors when reading the tail. --- src/ChangeLog | 5 +++++ src/fileio.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 939fd61c87f..c64416a6454 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2012-12-13 Paul Eggert + * fileio.c (Finsert_file_contents): Don't put tail into head area, + as that confuses set-auto-coding, so insist on the head-read + returning the full 1024 bytes. Let lseek compute the tail offset; + less work for us. Do not ignore I/O errors when reading the tail. + * xdisp.c: Minor style fixes. (init_iterator): Hoist assignment out of if-expression. (markpos_of_region): Callers now test for sign, not for -1. diff --git a/src/fileio.c b/src/fileio.c index 874162c5bb6..c7df87bcdda 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -3487,12 +3487,14 @@ variable `last-coding-system-used' to the coding system actually used. */) else { nread = emacs_read (fd, read_buf, 1024); - if (nread >= 0) + if (nread == 1024) { - if (lseek (fd, st.st_size - (1024 * 3), SEEK_SET) < 0) + int ntail; + if (lseek (fd, - (1024 * 3), SEEK_END) < 0) report_file_error ("Setting file position", Fcons (orig_filename, Qnil)); - nread += emacs_read (fd, read_buf + nread, 1024 * 3); + ntail = emacs_read (fd, read_buf + nread, 1024 * 3); + nread = ntail < 0 ? ntail : nread + ntail; } } -- 2.39.5