summaryrefslogtreecommitdiff
path: root/src/fileio.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2023-02-13 08:51:45 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2023-02-13 12:32:59 -0800
commitccc092115172f15c9135771f90d0000f8bf21614 (patch)
treecf5ebbd018a434dfb289a708ecc623d35e107c5a /src/fileio.c
parentb0842671e750be08356425e2fc38251e7b08d5d7 (diff)
downloademacs-ccc092115172f15c9135771f90d0000f8bf21614.tar.gz
Don’t scan text twice to guess coding system
* src/fileio.c (Finsert_file_contents): If the file shrank below 4 KiB, don’t read duplicate text into READ_BUF. This also removes a use of SEEK_END, which Linux /proc file systems do not support (not that we should get here with /proc).
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 751b8ec573c..47177be0f4d 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4119,7 +4119,7 @@ by calling `format-decode', which see. */)
if (nread == 1024)
{
int ntail;
- if (lseek (fd, - (1024 * 3), SEEK_END) < 0)
+ if (lseek (fd, st.st_size - 1024 * 3, SEEK_CUR) < 0)
report_file_error ("Setting file position",
orig_filename);
ntail = emacs_read_quit (fd, read_buf + nread, 1024 * 3);