[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/emacs-23 r100556: Fix a bug in time functio
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/emacs-23 r100556: Fix a bug in time functions when timezone is changed on Windows. |
Date: |
Mon, 18 Apr 2011 11:33:58 +0300 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 100556
committer: Eli Zaretskii <address@hidden>
branch nick: emacs-23
timestamp: Mon 2011-04-18 11:33:58 +0300
message:
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.
modified:
src/ChangeLog
src/s/ms-w32.h
src/w32.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2011-04-13 18:19:23 +0000
+++ b/src/ChangeLog 2011-04-18 08:33:58 +0000
@@ -1,3 +1,10 @@
+2011-04-18 Eli Zaretskii <address@hidden>
+
+ * s/ms-w32.h (localtime): Redirect to sys_localtime.
+
+ * w32.c: Include <time.h>.
+ (sys_localtime): New function.
+
2011-04-13 Chong Yidong <address@hidden>
* xdisp.c (init_xdisp): Initialize echo_area_window (Bug#6451).
=== modified file 'src/s/ms-w32.h'
--- a/src/s/ms-w32.h 2011-01-02 23:50:46 +0000
+++ b/src/s/ms-w32.h 2011-04-18 08:33:58 +0000
@@ -236,6 +236,7 @@
#define dup2 sys_dup2
#define fopen sys_fopen
#define link sys_link
+#define localtime sys_localtime
#define mkdir sys_mkdir
#undef mktemp
#define mktemp sys_mktemp
=== modified file 'src/w32.c'
--- a/src/w32.c 2011-01-02 23:50:46 +0000
+++ b/src/w32.c 2011-04-18 08:33:58 +0000
@@ -35,6 +35,7 @@
#include <mbstring.h> /* for _mbspbrk */
#include <math.h>
#include <setjmp.h>
+#include <time.h>
/* must include CRT headers *before* config.h */
@@ -65,6 +66,8 @@
#undef strerror
+#undef localtime
+
#include "lisp.h"
#include <pwd.h>
@@ -1961,6 +1964,12 @@
tv->tv_sec = tb.time;
tv->tv_usec = tb.millitm * 1000L;
+ /* Implementation note: _ftime sometimes doesn't update the dstflag
+ according to the new timezone when the system timezone is
+ changed. We could fix that by using GetSystemTime and
+ GetTimeZoneInformation, but that doesn't seem necessary, since
+ Emacs always calls gettimeofday with the 2nd argument NULL (see
+ EMACS_GET_TIME). */
if (tz)
{
tz->tz_minuteswest = tb.timezone; /* minutes west of Greenwich */
@@ -5676,6 +5685,19 @@
return nchars;
}
+/* The Windows CRT functions are "optimized for speed", so they don't
+ check for timezone and DST changes if they were last called less
+ than 1 minute ago (see http://support.microsoft.com/kb/821231). So
+ all Emacs features that repeatedly call time functions (e.g.,
+ display-time) are in real danger of missing timezone and DST
+ changes. Calling tzset before each localtime call fixes that. */
+struct tm *
+sys_localtime (const time_t *t)
+{
+ tzset ();
+ return localtime (t);
+}
+
static void
check_windows_init_file ()
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/emacs-23 r100556: Fix a bug in time functions when timezone is changed on Windows.,
Eli Zaretskii <=