[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r108849: * fileio.c: Improve handling
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r108849: * fileio.c: Improve handling of file time marker. (Bug#11852) |
Date: |
Tue, 03 Jul 2012 16:51:32 -0700 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 108849
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Tue 2012-07-03 16:51:32 -0700
message:
* fileio.c: Improve handling of file time marker. (Bug#11852)
(special_mtime): New function.
(Finsert_file_contents, Fverify_visited_file_modtime):
Use it to set special mtime values consistently.
modified:
src/ChangeLog
src/fileio.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2012-07-03 22:03:37 +0000
+++ b/src/ChangeLog 2012-07-03 23:51:32 +0000
@@ -1,3 +1,10 @@
+2012-07-03 Paul Eggert <address@hidden>
+
+ * fileio.c: Improve handling of file time marker. (Bug#11852)
+ (special_mtime): New function.
+ (Finsert_file_contents, Fverify_visited_file_modtime):
+ Use it to set special mtime values consistently.
+
2012-07-03 Andreas Schwab <address@hidden>
* fileio.c (Finsert_file_contents): Properly handle st_mtime
=== modified file 'src/fileio.c'
--- a/src/fileio.c 2012-07-03 22:03:37 +0000
+++ b/src/fileio.c 2012-07-03 23:51:32 +0000
@@ -3215,6 +3215,17 @@
return lseek (fd, offset, whence);
}
+/* Return a special mtime value indicating the error number ERRNUM. */
+static EMACS_TIME
+special_mtime (int errnum)
+{
+ EMACS_TIME t;
+ int ns = (errno == ENOENT || errno == EACCES || errno == ENOTDIR
+ ? NONEXISTENT_MODTIME_NSECS
+ : UNKNOWN_MODTIME_NSECS);
+ EMACS_SET_SECS_NSECS (t, 0, ns);
+ return t;
+}
DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents,
1, 5, 0,
@@ -3242,6 +3253,8 @@
(Lisp_Object filename, Lisp_Object visit, Lisp_Object beg, Lisp_Object end,
Lisp_Object replace)
{
struct stat st;
+ int file_status;
+ EMACS_TIME mtime;
register int fd;
ptrdiff_t inserted = 0;
int nochange = 0;
@@ -3310,19 +3323,22 @@
/* Tell stat to use expensive method to get accurate info. */
Vw32_get_true_file_attributes = Qt;
- total = stat (SSDATA (filename), &st);
+ file_status = stat (SSDATA (filename), &st);
Vw32_get_true_file_attributes = tem;
}
- if (total < 0)
#else
- if (stat (SSDATA (filename), &st) < 0)
+ file_status = stat (SSDATA (filename), &st);
#endif /* WINDOWSNT */
+
+ if (file_status == 0)
+ mtime = get_stat_mtime (&st);
+ else
{
badopen:
save_errno = errno;
if (NILP (visit))
report_file_error ("Opening input file", Fcons (orig_filename, Qnil));
- st.st_mtime = -1;
+ mtime = special_mtime (save_errno);
st.st_size = -1;
how_much = 0;
if (!NILP (Vcoding_system_for_read))
@@ -4193,10 +4209,7 @@
if (NILP (handler))
{
- if (st.st_mtime == -1)
- EMACS_SET_INVALID_TIME (current_buffer->modtime);
- else
- current_buffer->modtime = get_stat_mtime (&st);
+ current_buffer->modtime = mtime;
current_buffer->modtime_size = st.st_size;
BVAR (current_buffer, filename) = orig_filename;
}
@@ -5093,17 +5106,9 @@
filename = ENCODE_FILE (BVAR (b, filename));
- if (stat (SSDATA (filename), &st) == 0)
- mtime = get_stat_mtime (&st);
- else
- {
- /* If the file doesn't exist now and didn't exist before,
- we say that it isn't modified, provided the error is a tame one. */
- int ns = (errno == ENOENT || errno == EACCES || errno == ENOTDIR
- ? NONEXISTENT_MODTIME_NSECS
- : UNKNOWN_MODTIME_NSECS);
- EMACS_SET_SECS_NSECS (mtime, 0, ns);
- }
+ mtime = (stat (SSDATA (filename), &st) == 0
+ ? get_stat_mtime (&st)
+ : special_mtime (errno));
if ((EMACS_TIME_EQ (mtime, b->modtime)
/* If both exist, accept them if they are off by one second. */
|| (EMACS_TIME_VALID_P (mtime) && EMACS_TIME_VALID_P (b->modtime)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r108849: * fileio.c: Improve handling of file time marker. (Bug#11852),
Paul Eggert <=