]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix insert-file-contents optimization glitch
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 18 Jul 2025 06:00:38 +0000 (23:00 -0700)
committerEshel Yaron <me@eshelyaron.com>
Fri, 25 Jul 2025 08:11:33 +0000 (10:11 +0200)
This improves on recent fixes to Bug#77315.
* src/fileio.c (Finsert_file_contents): When optimizing
do not seek to 0 if the initial file offset is positive,
as that causes the optimized code to behave differently
from the nonoptimized.

(cherry picked from commit 5f4b71b0c4872b6bd9f8b4ced9f4715062db1bad)

src/fileio.c

index 248a369341a91f74bcfe636dac8a80c15c784ebc..fc5d4c27cfbfd1b92098536f70c202f46af09495 100644 (file)
@@ -4291,13 +4291,8 @@ by calling `format-decode', which see.  */)
       else
        {
          /* Don't try looking inside a file for a coding system
-            specification if it is not a regular, seekable file.  */
-         bool look_inside = (regular && seekable
-                             && !NILP (Vset_auto_coding_function));
-         if (look_inside && 0 < initial_offset
-             && emacs_fd_lseek (fd, 0, SEEK_SET) < 0)
-           look_inside = seekable = false;
-         if (look_inside)
+            specification if it is not a regular file.  */
+         if (regular && !NILP (Vset_auto_coding_function))
            {
              /* Find a coding system specified in the heading two
                 lines or in the tailing several lines of the file.