]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix set-time-zone-rule on DJGPP
authorPo Lu <luangruo@yahoo.com>
Thu, 20 Feb 2025 11:46:40 +0000 (19:46 +0800)
committerEshel Yaron <me@eshelyaron.com>
Thu, 20 Feb 2025 21:43:47 +0000 (22:43 +0100)
* lisp/loadup.el ("tooltip"): Load even on MS-DOS.

* src/timefns.c (tzvalbuf): Don't define on MS-DOS.
(emacs_getenv_TZ, emacs_setenv_TZ) [MSDOS]: Call getenv and
putenv rather than overwrite existing environment storage to
update DJGPP's environment modification counter.

(cherry picked from commit 1c49cfc711c61e683bda8d5b2546b586e5168706)

lisp/loadup.el
src/timefns.c

index 934e5bf40682574a8506a818d7892c5f7faa26c7..e7f61b4a3c754ca512898188c97cf634c72c4e3a 100644 (file)
   (setq internal-make-interpreted-closure-function
         #'cconv-make-interpreted-closure))
 (load "cus-start") ;Late to reduce customize-rogue (needs loaddefs.el anyway)
-(if (not (eq system-type 'ms-dos))
-    (load "tooltip"))
+;; tooltip.el is now required even on DOS to compile certain Lisp files.
+(load "tooltip")
 (load "international/iso-transl") ; Binds Alt-[ and friends.
 
 ;; Used by `kill-buffer', for instance.
index aab4dbb92069654080d75f35ea7184d4fe47d4ea..69b0393127501db985a957b8cef733b1e0e45405 100644 (file)
@@ -1967,16 +1967,24 @@ former.  */)
   return Qnil;
 }
 
+#ifndef MSDOS
+
 /* A buffer holding a string of the form "TZ=value", intended
    to be part of the environment.  If TZ is supposed to be unset,
    the buffer string is "tZ=".  */
  static char *tzvalbuf;
 
+#endif /* !MSDOS */
+
 /* Get the local time zone rule.  */
 char *
 emacs_getenv_TZ (void)
 {
+#ifndef MSDOS
   return tzvalbuf[0] == 'T' ? tzvalbuf + tzeqlen : 0;
+#else /* MSDOS */
+  return getenv ("TZ");
+#endif /* MSDOS */
 }
 
 /* Set the local time zone rule to TZSTRING, which can be null to
@@ -1990,6 +1998,7 @@ emacs_getenv_TZ (void)
 int
 emacs_setenv_TZ (const char *tzstring)
 {
+#ifndef MSDOS
   static ptrdiff_t tzvalbufsize;
   ptrdiff_t tzstringlen = tzstring ? strlen (tzstring) : 0;
   char *tzval = tzvalbuf;
@@ -2044,6 +2053,21 @@ emacs_setenv_TZ (const char *tzstring)
     xputenv (tzval);
 
   return 0;
+#else /* MSDOS */
+  /* Happily, there are no threads on MS-DOS that might be contending
+     with Emacs for access to TZ.  Call putenv to modify TZ: the code
+     above is not only unnecessary but results in modifications being
+     ommitted in consequence of an internal environment counter
+     remaining unchanged despite DJGPP being all too ready to reuse
+     preexisting environment storage.  */
+  USE_SAFE_ALLOCA;
+  char *buf = SAFE_ALLOCA (tzeqlen + strlen (tzstring) + 1);
+  strcpy (buf, "TZ=");
+  strcpy (buf + tzeqlen, tzstring);
+  xputenv (buf);
+  SAFE_FREE ();
+  return 0;
+#endif /* MSDOS */
 }
 
 #ifdef NEED_ZTRILLION_INIT