diff options
| author | Paul Eggert | 2012-07-03 17:04:46 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-07-03 17:04:46 -0700 |
| commit | 39adff0d6323578236a6bd9022c42460e8628629 (patch) | |
| tree | 6f51ae7a3debe203b0f6462dc260c0417df5efd9 /src | |
| parent | dbeed9a6816f011bbf29ff9e991f38b0d0d7e5ea (diff) | |
| download | emacs-39adff0d6323578236a6bd9022c42460e8628629.tar.gz emacs-39adff0d6323578236a6bd9022c42460e8628629.zip | |
Fix bugs in file timestamp newness comparisons.
* fileio.c (Ffile_newer_than_file_p):
* lread.c (Fload): Use full timestamp resolution of files,
not just the 1-second resolution, so that files that are only
slightly newer still count as newer.
* fileio.c (Ffile_newer_than_file_p): Don't assume file
timestamps fit in 'int'; this fixes a Y2038 bug on most hosts.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/fileio.c | 12 | ||||
| -rw-r--r-- | src/lread.c | 4 |
3 files changed, 19 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 87e92170261..5433c2ff831 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,16 @@ | |||
| 1 | 2012-07-04 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Fix bugs in file timestamp newness comparisons. | ||
| 4 | * fileio.c (Ffile_newer_than_file_p): | ||
| 5 | * lread.c (Fload): Use full timestamp resolution of files, | ||
| 6 | not just the 1-second resolution, so that files that are only | ||
| 7 | slightly newer still count as newer. | ||
| 8 | * fileio.c (Ffile_newer_than_file_p): Don't assume file | ||
| 9 | timestamps fit in 'int'; this fixes a Y2038 bug on most hosts. | ||
| 10 | |||
| 1 | 2012-07-03 Paul Eggert <eggert@cs.ucla.edu> | 11 | 2012-07-03 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 12 | ||
| 13 | |||
| 3 | * fileio.c: Improve handling of file time marker. (Bug#11852) | 14 | * fileio.c: Improve handling of file time marker. (Bug#11852) |
| 4 | (special_mtime): New function. | 15 | (special_mtime): New function. |
| 5 | (Finsert_file_contents, Fverify_visited_file_modtime): | 16 | (Finsert_file_contents, Fverify_visited_file_modtime): |
diff --git a/src/fileio.c b/src/fileio.c index 6c3a3b206e8..1dadd06c283 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -3079,8 +3079,7 @@ otherwise, if FILE2 does not exist, the answer is t. */) | |||
| 3079 | (Lisp_Object file1, Lisp_Object file2) | 3079 | (Lisp_Object file1, Lisp_Object file2) |
| 3080 | { | 3080 | { |
| 3081 | Lisp_Object absname1, absname2; | 3081 | Lisp_Object absname1, absname2; |
| 3082 | struct stat st; | 3082 | struct stat st1, st2; |
| 3083 | int mtime1; | ||
| 3084 | Lisp_Object handler; | 3083 | Lisp_Object handler; |
| 3085 | struct gcpro gcpro1, gcpro2; | 3084 | struct gcpro gcpro1, gcpro2; |
| 3086 | 3085 | ||
| @@ -3106,15 +3105,14 @@ otherwise, if FILE2 does not exist, the answer is t. */) | |||
| 3106 | absname2 = ENCODE_FILE (absname2); | 3105 | absname2 = ENCODE_FILE (absname2); |
| 3107 | UNGCPRO; | 3106 | UNGCPRO; |
| 3108 | 3107 | ||
| 3109 | if (stat (SSDATA (absname1), &st) < 0) | 3108 | if (stat (SSDATA (absname1), &st1) < 0) |
| 3110 | return Qnil; | 3109 | return Qnil; |
| 3111 | 3110 | ||
| 3112 | mtime1 = st.st_mtime; | 3111 | if (stat (SSDATA (absname2), &st2) < 0) |
| 3113 | |||
| 3114 | if (stat (SSDATA (absname2), &st) < 0) | ||
| 3115 | return Qt; | 3112 | return Qt; |
| 3116 | 3113 | ||
| 3117 | return (mtime1 > st.st_mtime) ? Qt : Qnil; | 3114 | return (EMACS_TIME_GT (get_stat_mtime (&st1), get_stat_mtime (&st2)) |
| 3115 | ? Qt : Qnil); | ||
| 3118 | } | 3116 | } |
| 3119 | 3117 | ||
| 3120 | #ifndef READ_BUF_SIZE | 3118 | #ifndef READ_BUF_SIZE |
diff --git a/src/lread.c b/src/lread.c index 7a0b20880e9..1e496bf9742 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -26,6 +26,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 26 | #include <errno.h> | 26 | #include <errno.h> |
| 27 | #include <limits.h> /* For CHAR_BIT. */ | 27 | #include <limits.h> /* For CHAR_BIT. */ |
| 28 | #include <setjmp.h> | 28 | #include <setjmp.h> |
| 29 | #include <stat-time.h> | ||
| 29 | #include "lisp.h" | 30 | #include "lisp.h" |
| 30 | #include "intervals.h" | 31 | #include "intervals.h" |
| 31 | #include "character.h" | 32 | #include "character.h" |
| @@ -1214,7 +1215,8 @@ Return t if the file exists and loads successfully. */) | |||
| 1214 | SSET (efound, SBYTES (efound) - 1, 'c'); | 1215 | SSET (efound, SBYTES (efound) - 1, 'c'); |
| 1215 | } | 1216 | } |
| 1216 | 1217 | ||
| 1217 | if (result == 0 && s1.st_mtime < s2.st_mtime) | 1218 | if (result == 0 |
| 1219 | && EMACS_TIME_LT (get_stat_mtime (&s1), get_stat_mtime (&s2))) | ||
| 1218 | { | 1220 | { |
| 1219 | /* Make the progress messages mention that source is newer. */ | 1221 | /* Make the progress messages mention that source is newer. */ |
| 1220 | newer = 1; | 1222 | newer = 1; |