aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2011-04-18 11:33:58 +0300
committerEli Zaretskii2011-04-18 11:33:58 +0300
commit97a9309556465557781fb95b2bc5a44f7b4520b9 (patch)
treed833c01701ab24492429351fd77b99ef5c83a2ae /src
parent6470c3c6a99ed0d1eae68bbbe1d0a3f6ca8b4983 (diff)
downloademacs-97a9309556465557781fb95b2bc5a44f7b4520b9.tar.gz
emacs-97a9309556465557781fb95b2bc5a44f7b4520b9.zip
Fix a bug in time functions when timezone is changed on Windows.
src/s/ms-w32.h (localtime): Redirect to sys_localtime. src/w32.c: Include <time.h>. (sys_localtime): New function.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/s/ms-w32.h1
-rw-r--r--src/w32.c22
3 files changed, 30 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index cfa9426c882..faf9564a835 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12011-04-18 Eli Zaretskii <eliz@gnu.org>
2
3 * s/ms-w32.h (localtime): Redirect to sys_localtime.
4
5 * w32.c: Include <time.h>.
6 (sys_localtime): New function.
7
12011-04-13 Chong Yidong <cyd@stupidchicken.com> 82011-04-13 Chong Yidong <cyd@stupidchicken.com>
2 9
3 * xdisp.c (init_xdisp): Initialize echo_area_window (Bug#6451). 10 * xdisp.c (init_xdisp): Initialize echo_area_window (Bug#6451).
diff --git a/src/s/ms-w32.h b/src/s/ms-w32.h
index 2b0a60cfab9..b9e57687a09 100644
--- a/src/s/ms-w32.h
+++ b/src/s/ms-w32.h
@@ -236,6 +236,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
236#define dup2 sys_dup2 236#define dup2 sys_dup2
237#define fopen sys_fopen 237#define fopen sys_fopen
238#define link sys_link 238#define link sys_link
239#define localtime sys_localtime
239#define mkdir sys_mkdir 240#define mkdir sys_mkdir
240#undef mktemp 241#undef mktemp
241#define mktemp sys_mktemp 242#define mktemp sys_mktemp
diff --git a/src/w32.c b/src/w32.c
index 8dbf0cf8f19..804d6d0c4bc 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -35,6 +35,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
35#include <mbstring.h> /* for _mbspbrk */ 35#include <mbstring.h> /* for _mbspbrk */
36#include <math.h> 36#include <math.h>
37#include <setjmp.h> 37#include <setjmp.h>
38#include <time.h>
38 39
39/* must include CRT headers *before* config.h */ 40/* must include CRT headers *before* config.h */
40 41
@@ -65,6 +66,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
65 66
66#undef strerror 67#undef strerror
67 68
69#undef localtime
70
68#include "lisp.h" 71#include "lisp.h"
69 72
70#include <pwd.h> 73#include <pwd.h>
@@ -1961,6 +1964,12 @@ gettimeofday (struct timeval *tv, struct timezone *tz)
1961 1964
1962 tv->tv_sec = tb.time; 1965 tv->tv_sec = tb.time;
1963 tv->tv_usec = tb.millitm * 1000L; 1966 tv->tv_usec = tb.millitm * 1000L;
1967 /* Implementation note: _ftime sometimes doesn't update the dstflag
1968 according to the new timezone when the system timezone is
1969 changed. We could fix that by using GetSystemTime and
1970 GetTimeZoneInformation, but that doesn't seem necessary, since
1971 Emacs always calls gettimeofday with the 2nd argument NULL (see
1972 EMACS_GET_TIME). */
1964 if (tz) 1973 if (tz)
1965 { 1974 {
1966 tz->tz_minuteswest = tb.timezone; /* minutes west of Greenwich */ 1975 tz->tz_minuteswest = tb.timezone; /* minutes west of Greenwich */
@@ -5676,6 +5685,19 @@ sys_write (int fd, const void * buffer, unsigned int count)
5676 return nchars; 5685 return nchars;
5677} 5686}
5678 5687
5688/* The Windows CRT functions are "optimized for speed", so they don't
5689 check for timezone and DST changes if they were last called less
5690 than 1 minute ago (see http://support.microsoft.com/kb/821231). So
5691 all Emacs features that repeatedly call time functions (e.g.,
5692 display-time) are in real danger of missing timezone and DST
5693 changes. Calling tzset before each localtime call fixes that. */
5694struct tm *
5695sys_localtime (const time_t *t)
5696{
5697 tzset ();
5698 return localtime (t);
5699}
5700
5679static void 5701static void
5680check_windows_init_file () 5702check_windows_init_file ()
5681{ 5703{