emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master b0842671e7 2/5: Improve insert-file-contents on non-regular files


From: Paul Eggert
Subject: master b0842671e7 2/5: Improve insert-file-contents on non-regular files
Date: Mon, 13 Feb 2023 15:33:07 -0500 (EST)

branch: master
commit b0842671e750be08356425e2fc38251e7b08d5d7
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>

    Improve insert-file-contents on non-regular files
    
    * src/fileio.c (Finsert_file_contents):
    If the file is not a regular file, check REPLACE and VISIT
    before doing further syscalls that won’t matter in this case.
---
 src/fileio.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/fileio.c b/src/fileio.c
index 64337abdae..751b8ec573 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4022,7 +4022,6 @@ by calling `format-decode', which see.  */)
   if (!S_ISREG (st.st_mode))
     {
       regular = false;
-      seekable = lseek (fd, 0, SEEK_CUR) < 0;
 
       if (! NILP (visit))
         {
@@ -4030,14 +4029,15 @@ by calling `format-decode', which see.  */)
          goto notfound;
         }
 
+      if (!NILP (replace))
+       xsignal2 (Qfile_error,
+                 build_string ("not a regular file"), orig_filename);
+
+      seekable = lseek (fd, 0, SEEK_CUR) < 0;
       if (!NILP (beg) && !seekable)
        xsignal2 (Qfile_error,
                  build_string ("cannot use a start position in a non-seekable 
file/device"),
                  orig_filename);
-
-      if (!NILP (replace))
-       xsignal2 (Qfile_error,
-                 build_string ("not a regular file"), orig_filename);
     }
 
   if (end_offset < 0)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]