changeset 9915:ec185bc66071

(Finsert_file_contents): If VISIT, set the buffer components such as the filename even before signaling error for non-regular file.
author Richard M. Stallman <rms@gnu.org>
date Mon, 14 Nov 1994 23:58:19 +0000
parents 486fd2f809f5
children 3014a91ade7a
files src/fileio.c
diffstat 1 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/fileio.c	Mon Nov 14 23:28:44 1994 +0000
+++ b/src/fileio.c	Mon Nov 14 23:58:19 1994 +0000
@@ -2725,6 +2725,7 @@
   Lisp_Object handler, val, insval;
   Lisp_Object p;
   int total;
+  int not_regular;
 
   val = Qnil;
   p = Qnil;
@@ -2764,14 +2765,21 @@
       goto notfound;
     }
 
+  not_regular = 0;
 #ifdef S_IFREG
   /* This code will need to be changed in order to work on named
      pipes, and it's probably just not worth it.  So we should at
      least signal an error.  */
   if (!S_ISREG (st.st_mode))
-    Fsignal (Qfile_error,
-	     Fcons (build_string ("not a regular file"),
-		    Fcons (filename, Qnil)));
+    {
+      if (NILP (visit))
+	Fsignal (Qfile_error,
+		 Fcons (build_string ("not a regular file"),
+			Fcons (filename, Qnil)));
+
+      not_regular = 1;
+      goto notfound;
+    }
 #endif
 
   if (fd < 0)
@@ -3036,6 +3044,11 @@
 	  unlock_file (filename);
 	}
 #endif /* CLASH_DETECTION */
+      if (not_regular)
+	Fsignal (Qfile_error,
+		 Fcons (build_string ("not a regular file"),
+			Fcons (filename, Qnil)));
+
       /* If visiting nonexistent file, return nil.  */
       if (current_buffer->modtime == -1)
 	report_file_error ("Opening input file", Fcons (filename, Qnil));