From 4222c55da73988a2bf397184e46505fc9a52f8b4 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 30 Sep 2011 13:22:01 -0700 Subject: [PATCH] * buffer.h (struct buffer): Use time_t, not int, for a time stamp. This fixes a Y2038 bug on 64-bit hosts. * buffer.c (reset_buffer): * fileio.c (Fdo_auto_save, Fset_buffer_auto_saved) (Fclear_buffer_auto_save_failure): Use 0, not -1, to represent an unset failure time, since time_t might not be signed. --- src/ChangeLog | 8 ++++++++ src/buffer.c | 2 +- src/buffer.h | 4 ++-- src/fileio.c | 6 +++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 89e705efd73..238e3faae51 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ 2011-09-30 Paul Eggert + * buffer.h (struct buffer): Use time_t, not int, for a time stamp. + This fixes a Y2038 bug on 64-bit hosts. + * buffer.c (reset_buffer): + * fileio.c (Fdo_auto_save, Fset_buffer_auto_saved) + (Fclear_buffer_auto_save_failure): + Use 0, not -1, to represent an unset failure time, since time_t + might not be signed. + Remove dependency on glibc malloc internals. * alloc.c (XMALLOC_OVERRUN_CHECK_OVERHEAD, XMALLOC_OVERRUN_CHECK_SIZE): Move back here from lisp.h, but with their new implementations. diff --git a/src/buffer.c b/src/buffer.c index dffdeb536fc..f38c9a739a6 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -724,7 +724,7 @@ reset_buffer (register struct buffer *b) b->prevent_redisplay_optimizations_p = 1; BVAR (b, backed_up) = Qnil; BUF_AUTOSAVE_MODIFF (b) = 0; - b->auto_save_failure_time = -1; + b->auto_save_failure_time = 0; BVAR (b, auto_save_file_name) = Qnil; BVAR (b, read_only) = Qnil; b->overlays_before = NULL; diff --git a/src/buffer.h b/src/buffer.h index 73628fe6dfc..a6b82abf053 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -566,8 +566,8 @@ struct buffer Redisplay of this buffer is inhibited until it changes again. */ int display_error_modiff; /* The time at which we detected a failure to auto-save, - Or -1 if we didn't have a failure. */ - int auto_save_failure_time; + Or 0 if we didn't have a failure. */ + time_t auto_save_failure_time; /* Position in buffer at which display started the last time this buffer was displayed. */ EMACS_INT last_window_start; diff --git a/src/fileio.c b/src/fileio.c index e335dcf027f..44a85ab1977 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -5344,7 +5344,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) EMACS_GET_TIME (before_time); /* If we had a failure, don't try again for 20 minutes. */ - if (b->auto_save_failure_time >= 0 + if (b->auto_save_failure_time > 0 && EMACS_SECS (before_time) - b->auto_save_failure_time < 1200) continue; @@ -5423,7 +5423,7 @@ No auto-save file will be written until the buffer changes again. */) they're not autosaved. */ BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF; XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG); - current_buffer->auto_save_failure_time = -1; + current_buffer->auto_save_failure_time = 0; return Qnil; } @@ -5432,7 +5432,7 @@ DEFUN ("clear-buffer-auto-save-failure", Fclear_buffer_auto_save_failure, doc: /* Clear any record of a recent auto-save failure in the current buffer. */) (void) { - current_buffer->auto_save_failure_time = -1; + current_buffer->auto_save_failure_time = 0; return Qnil; } -- 2.39.2