Commit e5e9d610 authored by Paul Eggert's avatar Paul Eggert
Browse files

* 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.
parent 5d5ac8ec
2011-09-18 Paul Eggert <eggert@cs.ucla.edu>
* 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.
2011-09-18 Eli Zaretskii <eliz@gnu.org> 2011-09-18 Eli Zaretskii <eliz@gnu.org>
* .gdbinit (pgx): Fix references to fields of `struct glyph'. * .gdbinit (pgx): Fix references to fields of `struct glyph'.
......
...@@ -3187,6 +3187,7 @@ variable `last-coding-system-used' to the coding system actually used. */) ...@@ -3187,6 +3187,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
Lisp_Object p; Lisp_Object p;
EMACS_INT total = 0; EMACS_INT total = 0;
int not_regular = 0; int not_regular = 0;
int save_errno = 0;
char read_buf[READ_BUF_SIZE]; char read_buf[READ_BUF_SIZE];
struct coding_system coding; struct coding_system coding;
char buffer[1 << 14]; char buffer[1 << 14];
...@@ -3250,6 +3251,7 @@ variable `last-coding-system-used' to the coding system actually used. */) ...@@ -3250,6 +3251,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
#endif /* WINDOWSNT */ #endif /* WINDOWSNT */
{ {
badopen: badopen:
save_errno = errno;
if (NILP (visit)) if (NILP (visit))
report_file_error ("Opening input file", Fcons (orig_filename, Qnil)); report_file_error ("Opening input file", Fcons (orig_filename, Qnil));
st.st_mtime = -1; st.st_mtime = -1;
...@@ -4281,6 +4283,7 @@ variable `last-coding-system-used' to the coding system actually used. */) ...@@ -4281,6 +4283,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
&& current_buffer->modtime == -1) && current_buffer->modtime == -1)
{ {
/* If visiting nonexistent file, return nil. */ /* If visiting nonexistent file, return nil. */
errno = save_errno;
report_file_error ("Opening input file", Fcons (orig_filename, Qnil)); report_file_error ("Opening input file", Fcons (orig_filename, Qnil));
} }
...@@ -4618,7 +4621,9 @@ This calls `write-region-annotate-functions' at the start, and ...@@ -4618,7 +4621,9 @@ This calls `write-region-annotate-functions' at the start, and
if (ret < 0) if (ret < 0)
{ {
#ifdef CLASH_DETECTION #ifdef CLASH_DETECTION
save_errno = errno;
if (!auto_saving) unlock_file (lockname); if (!auto_saving) unlock_file (lockname);
errno = save_errno;
#endif /* CLASH_DETECTION */ #endif /* CLASH_DETECTION */
UNGCPRO; UNGCPRO;
report_file_error ("Lseek error", Fcons (filename, Qnil)); report_file_error ("Lseek error", Fcons (filename, Qnil));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment