aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2016-06-13 14:50:08 -0700
committerPaul Eggert2016-06-13 14:51:18 -0700
commit981624453913a802c2493741ae73b7e57830aedc (patch)
treef708869104013fd96b02024099d2c21478460f6d /src
parent37887dd0f078ca02487251ec71ff04e21c7c3ab0 (diff)
downloademacs-981624453913a802c2493741ae73b7e57830aedc.tar.gz
emacs-981624453913a802c2493741ae73b7e57830aedc.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/editfns.c b/src/editfns.c
index a6d13545711..0c01c748d22 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -216,6 +216,7 @@ tzlookup (Lisp_Object zone, bool settz)
216 { 216 {
217 block_input (); 217 block_input ();
218 emacs_setenv_TZ (zone_string); 218 emacs_setenv_TZ (zone_string);
219 tzset ();
219 timezone_t old_tz = local_tz; 220 timezone_t old_tz = local_tz;
220 local_tz = new_tz; 221 local_tz = new_tz;
221 tzfree (old_tz); 222 tzfree (old_tz);
@@ -2458,23 +2459,24 @@ emacs_setenv_TZ (const char *tzstring)
2458 tzval[tzeqlen] = 0; 2459 tzval[tzeqlen] = 0;
2459 } 2460 }
2460 2461
2461 if (new_tzvalbuf 2462
2462#ifdef WINDOWSNT 2463#ifndef WINDOWSNT
2463 /* MS-Windows implementation of 'putenv' copies the argument 2464 /* Modifying *TZVAL merely requires calling tzset (which is the
2464 string into a block it allocates, so modifying tzval string 2465 caller's responsibility). However, modifying TZVAL requires
2465 does not change the environment. OTOH, the other threads run 2466 calling putenv; although this is not thread-safe, in practice this
2466 by Emacs on MS-Windows never call 'xputenv' or 'putenv' or 2467 runs only on startup when there is only one thread. */
2467 'unsetenv', so the original cause for the dicey in-place 2468 bool need_putenv = new_tzvalbuf;
2468 modification technique doesn't exist there in the first 2469#else
2469 place. */ 2470 /* MS-Windows 'putenv' copies the argument string into a block it
2470 || 1 2471 allocates, so modifying *TZVAL will not change the environment.
2472 However, the other threads run by Emacs on MS-Windows never call
2473 'xputenv' or 'putenv' or 'unsetenv', so the original cause for the
2474 dicey in-place modification technique doesn't exist there in the
2475 first place. */
2476 bool need_putenv = true;
2471#endif 2477#endif
2472 ) 2478 if (need_putenv)
2473 { 2479 xputenv (tzval);
2474 /* Although this is not thread-safe, in practice this runs only
2475 on startup when there is only one thread. */
2476 xputenv (tzval);
2477 }
2478 2480
2479 return 0; 2481 return 0;
2480} 2482}