From: Paul Eggert Date: Mon, 13 Feb 2023 16:51:45 +0000 (-0800) Subject: Don’t scan text twice to guess coding system X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ccc092115172f15c9135771f90d0000f8bf21614;p=emacs.git 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). --- 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);