aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2025-07-12 18:14:26 -0700
committerPaul Eggert2025-07-13 21:09:38 -0700
commit490311f86a97fd8d6633e28143a26e7618f15e79 (patch)
treec96de2af42dff5058b9aa5d16000c53df682d534 /src
parent3998242664604e9e91830b10529cc2da6bd82d8e (diff)
downloademacs-490311f86a97fd8d6633e28143a26e7618f15e79.tar.gz
emacs-490311f86a97fd8d6633e28143a26e7618f15e79.zip
insert-file-contents errno confusion
* src/fileio.c (read_non_regular): Return negation of errno on failure, instead of -1. (Finsert_file_contents): Signal with correct errno when a read fails.
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 748e8aadc0c..7aa2113454b 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3924,7 +3924,7 @@ read_non_regular (Lisp_Object state)
3924 ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE 3924 ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE
3925 + data->s.inserted), 3925 + data->s.inserted),
3926 data->s.trytry); 3926 data->s.trytry);
3927 return make_int (nbytes); 3927 return make_int (nbytes < 0 ? -errno : nbytes);
3928} 3928}
3929 3929
3930 3930
@@ -4094,8 +4094,8 @@ by calling `format-decode', which see. */)
4094 bool replace_handled = false; 4094 bool replace_handled = false;
4095 bool set_coding_system = false; 4095 bool set_coding_system = false;
4096 Lisp_Object coding_system; 4096 Lisp_Object coding_system;
4097 /* Negative if read error, 0 if OK so far, positive if quit. */ 4097 /* errno if read error, 0 if OK so far, negative if quit. */
4098 ptrdiff_t read_quit = 0; 4098 int read_quit = 0;
4099 /* If the undo log only contains the insertion, there's no point 4099 /* If the undo log only contains the insertion, there's no point
4100 keeping it. It's typically when we first fill a file-buffer. */ 4100 keeping it. It's typically when we first fill a file-buffer. */
4101 bool empty_undo_list_p 4101 bool empty_undo_list_p
@@ -4843,7 +4843,7 @@ by calling `format-decode', which see. */)
4843 4843
4844 if (NILP (nbytes)) 4844 if (NILP (nbytes))
4845 { 4845 {
4846 read_quit = 1; 4846 read_quit = -1;
4847 break; 4847 break;
4848 } 4848 }
4849 4849
@@ -4857,14 +4857,18 @@ by calling `format-decode', which see. */)
4857 /* Allow quitting out of the actual I/O. We don't make text 4857 /* Allow quitting out of the actual I/O. We don't make text
4858 part of the buffer until all the reading is done, so a 4858 part of the buffer until all the reading is done, so a
4859 C-g here doesn't do any harm. */ 4859 C-g here doesn't do any harm. */
4860 this = emacs_fd_read (fd, 4860 {
4861 ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE 4861 this = emacs_fd_read (fd,
4862 + inserted), 4862 ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE
4863 trytry); 4863 + inserted),
4864 trytry);
4865 if (this < 0)
4866 this = -errno;
4867 }
4864 4868
4865 if (this <= 0) 4869 if (this <= 0)
4866 { 4870 {
4867 read_quit = this; 4871 read_quit = -this;
4868 break; 4872 break;
4869 } 4873 }
4870 4874
@@ -4889,8 +4893,8 @@ by calling `format-decode', which see. */)
4889 emacs_fd_close (fd); 4893 emacs_fd_close (fd);
4890 clear_unwind_protect (fd_index); 4894 clear_unwind_protect (fd_index);
4891 4895
4892 if (read_quit < 0) 4896 if (0 < read_quit)
4893 report_file_error ("Read error", orig_filename); 4897 report_file_errno ("Read error", orig_filename, read_quit);
4894 4898
4895 notfound: 4899 notfound:
4896 4900