From: Po Lu Date: Thu, 20 Feb 2025 11:46:40 +0000 (+0800) Subject: Fix set-time-zone-rule on DJGPP X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f03be12a8de4a38da82e804631100ae753060640;p=emacs.git Fix set-time-zone-rule on DJGPP * 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) --- diff --git a/lisp/loadup.el b/lisp/loadup.el index 934e5bf4068..e7f61b4a3c7 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el @@ -392,8 +392,8 @@ (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. diff --git a/src/timefns.c b/src/timefns.c index aab4dbb9206..69b03931275 100644 --- a/src/timefns.c +++ b/src/timefns.c @@ -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