[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 9816244: Call tzset after setting TZ
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master 9816244: Call tzset after setting TZ |
Date: |
Mon, 13 Jun 2016 21:51:21 +0000 (UTC) |
branch: master
commit 981624453913a802c2493741ae73b7e57830aedc
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
Call tzset after setting TZ
* src/editfns.c (tzlookup): Call tzset after setting TZ, so that
the setting change propagates into Emacs local time (Bug#23600).
(emacs_setenv_TZ): Clarify comments.
---
src/editfns.c | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/src/editfns.c b/src/editfns.c
index a6d1354..0c01c74 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -216,6 +216,7 @@ tzlookup (Lisp_Object zone, bool settz)
{
block_input ();
emacs_setenv_TZ (zone_string);
+ tzset ();
timezone_t old_tz = local_tz;
local_tz = new_tz;
tzfree (old_tz);
@@ -2458,23 +2459,24 @@ emacs_setenv_TZ (const char *tzstring)
tzval[tzeqlen] = 0;
}
- if (new_tzvalbuf
-#ifdef WINDOWSNT
- /* MS-Windows implementation of 'putenv' copies the argument
- string into a block it allocates, so modifying tzval string
- does not change the environment. OTOH, the other threads run
- by Emacs on MS-Windows never call 'xputenv' or 'putenv' or
- 'unsetenv', so the original cause for the dicey in-place
- modification technique doesn't exist there in the first
- place. */
- || 1
+
+#ifndef WINDOWSNT
+ /* Modifying *TZVAL merely requires calling tzset (which is the
+ caller's responsibility). However, modifying TZVAL requires
+ calling putenv; although this is not thread-safe, in practice this
+ runs only on startup when there is only one thread. */
+ bool need_putenv = new_tzvalbuf;
+#else
+ /* MS-Windows 'putenv' copies the argument string into a block it
+ allocates, so modifying *TZVAL will not change the environment.
+ However, the other threads run by Emacs on MS-Windows never call
+ 'xputenv' or 'putenv' or 'unsetenv', so the original cause for the
+ dicey in-place modification technique doesn't exist there in the
+ first place. */
+ bool need_putenv = true;
#endif
- )
- {
- /* Although this is not thread-safe, in practice this runs only
- on startup when there is only one thread. */
- xputenv (tzval);
- }
+ if (need_putenv)
+ xputenv (tzval);
return 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 9816244: Call tzset after setting TZ,
Paul Eggert <=