summaryrefslogtreecommitdiff
path: root/src/fileio.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-09-18 01:34:09 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-09-18 01:34:09 -0700
commite5e9d610c9b435b9053bec512957c872b8fc031c (patch)
tree8a09d838c6027d13dbe4132d38ddb12091705c1a /src/fileio.c
parent5d5ac8ec033a741c6931ef874ac4c4caa0a9359c (diff)
downloademacs-e5e9d610c9b435b9053bec512957c872b8fc031c.tar.gz
emacs-e5e9d610c9b435b9053bec512957c872b8fc031c.tar.bz2
emacs-e5e9d610c9b435b9053bec512957c872b8fc031c.zip
* fileio.c: Report proper errno when syscall falls.
(Finsert_file_contents): Save and restore errno, so that report_file_error outputs the correct diagnostic. (Fwrite_region) [CLASH_DETECTION]: Likewise.
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 08be41f9fe4..e335dcf027f 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3187,6 +3187,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
Lisp_Object p;
EMACS_INT total = 0;
int not_regular = 0;
+ int save_errno = 0;
char read_buf[READ_BUF_SIZE];
struct coding_system coding;
char buffer[1 << 14];
@@ -3250,6 +3251,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
#endif /* WINDOWSNT */
{
badopen:
+ save_errno = errno;
if (NILP (visit))
report_file_error ("Opening input file", Fcons (orig_filename, Qnil));
st.st_mtime = -1;
@@ -4281,6 +4283,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
&& current_buffer->modtime == -1)
{
/* If visiting nonexistent file, return nil. */
+ errno = save_errno;
report_file_error ("Opening input file", Fcons (orig_filename, Qnil));
}
@@ -4618,7 +4621,9 @@ This calls `write-region-annotate-functions' at the start, and
if (ret < 0)
{
#ifdef CLASH_DETECTION
+ save_errno = errno;
if (!auto_saving) unlock_file (lockname);
+ errno = save_errno;
#endif /* CLASH_DETECTION */
UNGCPRO;
report_file_error ("Lseek error", Fcons (filename, Qnil));