From ccc092115172f15c9135771f90d0000f8bf21614 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 13 Feb 2023 08:51:45 -0800 Subject: [PATCH 3/5] =?UTF-8?q?Don=E2=80=99t=20scan=20text=20twice=20to=20?= =?UTF-8?q?guess=20coding=20system?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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). --- src/fileio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@ because (1) it preserves some marker positions (in unchanged portions 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); -- 2.37.2