aboutsummaryrefslogtreecommitdiffstats
path: root/src/fileio.c
diff options
context:
space:
mode:
authorPaul Eggert2025-07-16 23:21:23 -0700
committerPaul Eggert2025-07-16 23:21:23 -0700
commit15570b7b95da3461feb51cf1bfe3b6337f5a67cd (patch)
tree091c3838b467eab178b0b7fca6426def2c82c3ff /src/fileio.c
parent9326784b785c110468c1804b969eefb8d8119fd8 (diff)
downloademacs-15570b7b95da3461feb51cf1bfe3b6337f5a67cd.tar.gz
emacs-15570b7b95da3461feb51cf1bfe3b6337f5a67cd.zip
Don’t optimize insert-file-contents for GNU
* src/fileio.c (Finsert_file_contents): Remove a microoptimization for GNU/Linux and Android.
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/fileio.c b/src/fileio.c
index e33ac4afabf..a9e5975a2eb 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4187,16 +4187,14 @@ by calling `format-decode', which see. */)
4187 if (emacs_fd_fstat (fd, &st) < 0) 4187 if (emacs_fd_fstat (fd, &st) < 0)
4188 report_file_error ("Input file status", orig_filename); 4188 report_file_error ("Input file status", orig_filename);
4189 4189
4190 /* For backwards compatibility to traditional Unix, 4190 /* Normally there is no need for an S_ISDIR test here,
4191 POSIX allows the 'read' syscall to succeed on directories. 4191 as the first 'read' syscall will fail with EISDIR.
4192 However, we want to fail, to be consistent across platforms 4192 However, for backwards compatibility to traditional Unix,
4193 and to let callers rely on this function failing on directories. 4193 POSIX allows 'read' to succeed on directories.
4194 There is no need to check on platforms where it is known that the 4194 So do an explicit S_ISDIR test now, so that callers can rely on
4195 'read' syscall always fails on a directory. */ 4195 this function rejecting directories on all platforms. */
4196#if ! (defined GNU_LINUX || defined __ANDROID__)
4197 if (S_ISDIR (st.st_mode)) 4196 if (S_ISDIR (st.st_mode))
4198 report_file_errno ("Read error", orig_filename, EISDIR); 4197 report_file_errno ("Read error", orig_filename, EISDIR);
4199#endif
4200 4198
4201 regular = S_ISREG (st.st_mode) != 0; 4199 regular = S_ISREG (st.st_mode) != 0;
4202 bool memory_object = S_TYPEISSHM (&st) || S_TYPEISTMO (&st); 4200 bool memory_object = S_TYPEISSHM (&st) || S_TYPEISTMO (&st);