On 2026-10-11 03:56, Eli Zaretskii wrote:
Let me rephrase: I don't want to ask Paul to do this, and I'd like to
avoid the need to run gnulib-tool myself. Would you (or someone else
on the Gnulib team) please kindly tell how to produce the effect of
"--avoid=localtime" without actually running the script?
Yes: install the attached patch. Quite possibly it will work as-is; perhaps
we'll need to fiddle with it a bit. Either way, it's heading in the right
direction.
This patch follows Bruno's suggestion of avoiding the Gnulib localtime module
because Emacs doesn't need it. It goes further by also avoiding Gnulib's
tzsanitize module, as I assume Emacs doesn't need that either. If my assumption
is incorrect I can create another patch that avoids localtime but not
tzsanitize.
Although one can incorporate Gnulib code without running gnulib-tool, it's such
an error-prone process that I don't recommend it. I generated the attached
patch by running Emacs's admin/merge-gnulib script, which ran gnulib-tool for
me.
From 1c40185a2229f1a0cad13d00acd764658b156828 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sun, 11 Oct 2026 11:03:22 -0700
Subject: [PATCH] =?UTF-8?q?Avoid=20Gnulib=E2=80=99s=20localtime=20and=20tz?=
=?UTF-8?q?sanitize=20modules?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* admin/merge-gnulib (AVOIDED_MODULES): Avoid localtime, tzsanitize.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
The following simply reverts recently-introduced changes:
* lib/localtime.c, lib/tzsanitize.c, lib/tzsanitize.h, m4/localtime.m4:
Remove.
* lib-src/ntlib.c, src/w32.c:
Don’t include tzsanitize.h or call tzsanitize or #undef localtime.
(rpl_localtime): Remove.
* nt/gnulib-cfg.mk (OMIT_GNULIB_MODULE_localtime): Remove.
* src/timefns.c [WINDOWSNT]: Do not include tzsanitize.h or call
tzsanitize.
---
admin/merge-gnulib | 4 +--
lib-src/ntlib.c | 12 -------
lib/gnulib.mk.in | 32 ++----------------
lib/localtime.c | 34 -------------------
lib/tzsanitize.c | 83 ----------------------------------------------
lib/tzsanitize.h | 83 ----------------------------------------------
m4/gnulib-comp.m4 | 37 ---------------------
m4/localtime.m4 | 16 ---------
nt/gnulib-cfg.mk | 1 -
src/timefns.c | 7 +---
src/w32.c | 12 -------
11 files changed, 5 insertions(+), 316 deletions(-)
delete mode 100644 lib/localtime.c
delete mode 100644 lib/tzsanitize.c
delete mode 100644 lib/tzsanitize.h
delete mode 100644 m4/localtime.m4
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index eca94e12d9a..35e004a077a 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -63,12 +63,12 @@ AVOIDED_MODULES=
c32isalnum c32rtomb c32tolower c32toupper
chmod close dup fchdir fstat gnulib-i18n
langinfo-h libgmp-mpq
- localcharset localeinfo localename-unsafe-limited lock
+ localcharset localeinfo localename-unsafe-limited localtime lock
mbrtoc32-regular mbsinit memchr mkdir
msvc-inval msvc-nothrow nl_langinfo
openat-die opendir pthread-h
save-cwd select setenv sigprocmask stat std-gnu11 strncpy
- threadlib tzset unsetenv utime utime-h
+ threadlib tzsanitize tzset unsetenv utime utime-h
wchar-h uchar-h
'
diff --git a/lib-src/ntlib.c b/lib-src/ntlib.c
index 89ce3b00fd0..9d866f0bc34 100644
--- a/lib-src/ntlib.c
+++ b/lib-src/ntlib.c
@@ -40,10 +40,6 @@ #define DEFER_MS_W32_H
#include <nl_types.h>
#include <langinfo.h>
-#include <tzsanitize.h>
-#ifdef localtime
-# undef localtime
-#endif
#include "ntlib.h"
@@ -603,11 +599,3 @@ nl_langinfo (nl_item item)
return (char *) "";
}
}
-
-/* Gnulib forcibly redirects 'localtime' to this. */
-struct tm *
-rpl_localtime (const time_t *tp)
-{
- tzsanitize ();
- return localtime (tp);
-}
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 0f90b5628c1..47da7d5de14 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -53,6 +53,7 @@
# --avoid=localcharset \
# --avoid=localeinfo \
# --avoid=localename-unsafe-limited \
+# --avoid=localtime \
# --avoid=lock \
# --avoid=mbrtoc32-regular \
# --avoid=mbsinit \
@@ -72,6 +73,7 @@
# --avoid=std-gnu11 \
# --avoid=strncpy \
# --avoid=threadlib \
+# --avoid=tzsanitize \
# --avoid=tzset \
# --avoid=unsetenv \
# --avoid=utime \
@@ -329,7 +331,6 @@ GL_COND_OBJ_GETRANDOM_CONDITION = @GL_COND_OBJ_GETRANDOM_CONDITION@
GL_COND_OBJ_GETTIMEOFDAY_CONDITION = @GL_COND_OBJ_GETTIMEOFDAY_CONDITION@
GL_COND_OBJ_GROUP_MEMBER_CONDITION = @GL_COND_OBJ_GROUP_MEMBER_CONDITION@
GL_COND_OBJ_LCHMOD_CONDITION = @GL_COND_OBJ_LCHMOD_CONDITION@
-GL_COND_OBJ_LOCALTIME_CONDITION = @GL_COND_OBJ_LOCALTIME_CONDITION@
GL_COND_OBJ_LSTAT_CONDITION = @GL_COND_OBJ_LSTAT_CONDITION@
GL_COND_OBJ_MEMPCPY_CONDITION = @GL_COND_OBJ_MEMPCPY_CONDITION@
GL_COND_OBJ_MEMRCHR_CONDITION = @GL_COND_OBJ_MEMRCHR_CONDITION@
@@ -357,7 +358,6 @@ GL_COND_OBJ_STRTOLL_CONDITION = @GL_COND_OBJ_STRTOLL_CONDITION@
GL_COND_OBJ_SYMLINK_CONDITION = @GL_COND_OBJ_SYMLINK_CONDITION@
GL_COND_OBJ_TIMEGM_CONDITION = @GL_COND_OBJ_TIMEGM_CONDITION@
GL_COND_OBJ_TIME_R_CONDITION = @GL_COND_OBJ_TIME_R_CONDITION@
-GL_COND_OBJ_TZSANITIZE_CONDITION = @GL_COND_OBJ_TZSANITIZE_CONDITION@
GL_COND_OBJ_UTIMENSAT_CONDITION = @GL_COND_OBJ_UTIMENSAT_CONDITION@
GL_GENERATE_ALLOCA_H_CONDITION = @GL_GENERATE_ALLOCA_H_CONDITION@
GL_GENERATE_ASSERT_H_CONDITION = @GL_GENERATE_ASSERT_H_CONDITION@
@@ -1534,12 +1534,10 @@ gl_GNULIB_ENABLED_getgroups_CONDITION = @gl_GNULIB_ENABLED_getgroups_CONDITION@
gl_GNULIB_ENABLED_issymlink_CONDITION = @gl_GNULIB_ENABLED_issymlink_CONDITION@
gl_GNULIB_ENABLED_issymlinkat_CONDITION = @gl_GNULIB_ENABLED_issymlinkat_CONDITION@
gl_GNULIB_ENABLED_lchmod_CONDITION = @gl_GNULIB_ENABLED_lchmod_CONDITION@
-gl_GNULIB_ENABLED_localtime_CONDITION = @gl_GNULIB_ENABLED_localtime_CONDITION@
gl_GNULIB_ENABLED_open_CONDITION = @gl_GNULIB_ENABLED_open_CONDITION@
gl_GNULIB_ENABLED_rawmemchr_CONDITION = @gl_GNULIB_ENABLED_rawmemchr_CONDITION@
gl_GNULIB_ENABLED_stdc_memreverse8u_CONDITION = @gl_GNULIB_ENABLED_stdc_memreverse8u_CONDITION@
gl_GNULIB_ENABLED_strtoll_CONDITION = @gl_GNULIB_ENABLED_strtoll_CONDITION@
-gl_GNULIB_ENABLED_tzsanitize_CONDITION = @gl_GNULIB_ENABLED_tzsanitize_CONDITION@
gl_GNULIB_ENABLED_utimens_CONDITION = @gl_GNULIB_ENABLED_utimens_CONDITION@
gl_GNULIB_ENABLED_verify_CONDITION = @gl_GNULIB_ENABLED_verify_CONDITION@
gl_LIBOBJDEPS = @gl_LIBOBJDEPS@
@@ -2783,18 +2781,6 @@ EXTRA_DIST += limits.in.h
endif
## end gnulib module limits-h
-## begin gnulib module localtime
-ifeq (,$(OMIT_GNULIB_MODULE_localtime))
-
-ifneq (,$(gl_GNULIB_ENABLED_localtime_CONDITION))
-ifneq (,$(GL_COND_OBJ_LOCALTIME_CONDITION))
-libgnu_a_SOURCES += localtime.c
-endif
-
-endif
-endif
-## end gnulib module localtime
-
## begin gnulib module lstat
ifeq (,$(OMIT_GNULIB_MODULE_lstat))
@@ -4375,20 +4361,6 @@ libgnu_a_SOURCES += timespec-sub.c
endif
## end gnulib module timespec-sub
-## begin gnulib module tzsanitize
-ifeq (,$(OMIT_GNULIB_MODULE_tzsanitize))
-
-ifneq (,$(gl_GNULIB_ENABLED_tzsanitize_CONDITION))
-ifneq (,$(GL_COND_OBJ_TZSANITIZE_CONDITION))
-libgnu_a_SOURCES += tzsanitize.c
-endif
-
-endif
-EXTRA_DIST += tzsanitize.h
-
-endif
-## end gnulib module tzsanitize
-
## begin gnulib module u64
ifeq (,$(OMIT_GNULIB_MODULE_u64))
diff --git a/lib/localtime.c b/lib/localtime.c
deleted file mode 100644
index 1af75963bde..00000000000
--- a/lib/localtime.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Work around platform bugs in localtime.
- Copyright (C) 2017-2026 Free Software Foundation, Inc.
-
- This file is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- This file is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include <time.h>
-
-#include "tzsanitize.h"
-
-#undef localtime
-
-struct tm *
-rpl_localtime (const time_t *tp)
-{
-#if defined _WIN32 && ! defined __CYGWIN__
- tzsanitize ();
-#endif
-
- return localtime (tp);
-}
diff --git a/lib/tzsanitize.c b/lib/tzsanitize.c
deleted file mode 100644
index 1963dfbeb4b..00000000000
--- a/lib/tzsanitize.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Sanitizing the TZ environment variable on native Windows.
- Copyright (C) 2017-2026 Free Software Foundation, Inc.
-
- This file is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- This file is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible. */
-
-#include <config.h>
-
-/* Specification. */
-#include "tzsanitize.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <wchar.h>
-
-#if !defined __MINGW32__ || defined _UCRT
-# define WIN32_LEAN_AND_MEAN /* avoid including junk */
-# include <windows.h>
-#endif
-
-void
-tzsanitize (void)
-{
- const char *tz = getenv ("TZ");
- if (tz != NULL && strchr (tz, '/') != NULL)
- {
- /* Neutralize it, in a way that is thread-safe.
- (If we were to use _putenv ("TZ="), it would free the memory allocated
- for the environment variable "TZ", and thus other threads that are
- using the previously fetched value of getenv ("TZ") could crash.) */
- char **env = _environ;
- wchar_t **wenv = _wenviron;
- if (env != NULL)
- for (char **ep = env; *ep != NULL; ep++)
- {
- char *s = *ep;
- if (s[0] == 'T' && s[1] == 'Z' && s[2] == '=')
- s[0] = '$';
- }
- if (wenv != NULL)
- for (wchar_t **wep = wenv; *wep != NULL; wep++)
- {
- wchar_t *ws = *wep;
- if (ws[0] == L'T' && ws[1] == L'Z' && ws[2] == L'=')
- ws[0] = L'$';
- }
-#if !defined __MINGW32__ || defined _UCRT
- SetEnvironmentVariable ("TZ", NULL);
-#endif
- }
-#if !defined __MINGW32__ || defined _UCRT
- /* On MSVC, we also need to sanitize the environment variables stored in the
- process's environment block.
- We don't lose much by assuming that the environment variable's value
- is not too large. */
- else
- {
- /* Documentation:
- <https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getenvironmentvariable> */
- char tz_buf[256];
- DWORD tz_len = GetEnvironmentVariable ("TZ", tz_buf, sizeof (tz_buf));
- if (tz_len > 0 && tz_len < sizeof (tz_buf)
- && strchr (tz_buf, '/') != NULL)
- {
- /* Documentation:
- <https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setenvironmentvariable> */
- SetEnvironmentVariable ("TZ", NULL);
- }
- }
-#endif
-}
diff --git a/lib/tzsanitize.h b/lib/tzsanitize.h
deleted file mode 100644
index 61ae7cdc9a8..00000000000
--- a/lib/tzsanitize.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Sanitizing the TZ environment variable on native Windows.
- Copyright (C) 2017-2026 Free Software Foundation, Inc.
-
- This file is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- This file is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible. */
-
-#ifndef _TZSANITIZE_H
-#define _TZSANITIZE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined _WIN32 && !defined __CYGWIN__
-
-/* Rectify the value of the environment variable TZ.
- There are four possible kinds of such values:
- - Traditional US time zone names, e.g. "PST8PDT". Syntax: see
- <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/tzset>
- - Time zone names based on geography, that contain one or more
- slashes, e.g. "Europe/Moscow".
- - Time zone names based on geography, without slashes, e.g.
- "Singapore".
- - Time zone names that contain explicit DST rules. Syntax: see
- <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03>
- The Microsoft CRT understands only the first kind. It produces incorrect
- results if the value of TZ is of the other kinds.
- But in a Cygwin environment, /etc/profile.d/tzset.sh sets TZ to a value
- of the second kind for most geographies, or of the first kind in a few
- other geographies. If it is of the second kind, neutralize it. For the
- Microsoft CRT, an absent or empty TZ means the time zone that the user
- has set in the Windows Control Panel.
- If the value of TZ is of the third or fourth kind -- Cygwin programs
- understand these syntaxes as well --, it does not matter whether we
- neutralize it or not, since these values occur only when a Cygwin user
- has set TZ explicitly; this case is 1. rare and 2. under the user's
- responsibility. */
-
-/* Applications need to make sure that tzsanitize() gets invoked (at least
- once) *before* the first invocation of __tzset() in the Microsoft runtime
- library. This is because
- - __tzset looks at the value of the environment variable "TZ".
- - The first invocation of __tzset sets some cached variables.
- Further invocations of __tzset do nothing.
-
- The gnulib overrides of
- localtime, mktime, tzset, strftime, wcsftime, ctime
- do call tzsanitize(); therefore no explicit tzsanitize() invocations are
- needed in simple programs. But some other functions do call __tzset()
- implicitly:
- - In the Microsoft runtime library:
- stat = _stat64, fstat = _fstat64.
- MSVCRT: _stat64, _fstat64 -> __loctotime64_t -> __tzset.
- UCRT: _fstat64 -> common_fstat -> common_stat_handle_file_opened
- -> convert_large_integer_time_to_time_t
- -> loctotime -> common_loctotime_t -> __tzset.
- - In GNU libintl:
- [d]gettext -> dcigettext -> _nl_find_domain -> _nl_load_domain -> fstat.
-
- Therefore programs that are linked to such libraries need to call
- tzsanitize() early during their initialization. */
-
-extern void tzsanitize (void);
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _TZSANITIZE_H */
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 9ddcae9b821..7ead972916c 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -142,7 +142,6 @@ AC_DEFUN
# Code from module libgmp:
# Code from module libgmp-mpz:
# Code from module limits-h:
- # Code from module localtime:
# Code from module lstat:
# Code from module malloc-gnu:
# Code from module malloc-posix:
@@ -222,7 +221,6 @@ AC_DEFUN
# Code from module timespec:
# Code from module timespec-add:
# Code from module timespec-sub:
- # Code from module tzsanitize:
# Code from module u64:
# Code from module unistd-h:
# Code from module unlocked-io:
@@ -728,7 +726,6 @@ AC_DEFUN
gl_gnulib_enabled_issymlink=false
gl_gnulib_enabled_issymlinkat=false
gl_gnulib_enabled_lchmod=false
- gl_gnulib_enabled_localtime=false
gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false
gl_gnulib_enabled_open=false
gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false
@@ -736,7 +733,6 @@ AC_DEFUN
gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false
gl_gnulib_enabled_stdc_memreverse8u=false
gl_gnulib_enabled_strtoll=false
- gl_gnulib_enabled_tzsanitize=false
gl_gnulib_enabled_utimens=false
gl_gnulib_enabled_verify=false
func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b ()
@@ -904,18 +900,6 @@ AC_DEFUN
fi
fi
}
- func_gl_gnulib_m4code_localtime ()
- {
- if $gl_gnulib_enabled_localtime; then :; else
- gl_FUNC_LOCALTIME
- gl_CONDITIONAL([GL_COND_OBJ_LOCALTIME], [test $REPLACE_LOCALTIME = 1])
- gl_TIME_MODULE_INDICATOR([localtime])
- gl_gnulib_enabled_localtime=true
- if test $REPLACE_LOCALTIME = 1; then
- func_gl_gnulib_m4code_tzsanitize
- fi
- fi
- }
func_gl_gnulib_m4code_5264294aa0a5557541b53c8c741f7f31 ()
{
if $gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31; then :; else
@@ -987,15 +971,6 @@ AC_DEFUN
gl_gnulib_enabled_strtoll=true
fi
}
- func_gl_gnulib_m4code_tzsanitize ()
- {
- if $gl_gnulib_enabled_tzsanitize; then :; else
- AC_REQUIRE([AC_CANONICAL_HOST])
- gl_CONDITIONAL([GL_COND_OBJ_TZSANITIZE],
- [case "$host_os" in mingw* | windows*) true;; *) false;; esac])
- gl_gnulib_enabled_tzsanitize=true
- fi
- }
func_gl_gnulib_m4code_utimens ()
{
if $gl_gnulib_enabled_utimens; then :; else
@@ -1076,9 +1051,6 @@ AC_DEFUN
if $GL_GENERATE_IEEE754_H; then
func_gl_gnulib_m4code_endian
fi
- if test $REPLACE_MKTIME = 1; then
- func_gl_gnulib_m4code_tzsanitize
- fi
if test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1; then
func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
fi
@@ -1097,9 +1069,6 @@ AC_DEFUN
if test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; then
func_gl_gnulib_m4code_strtoll
fi
- if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then
- func_gl_gnulib_m4code_localtime
- fi
if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then
func_gl_gnulib_m4code_5264294aa0a5557541b53c8c741f7f31
fi
@@ -1129,7 +1098,6 @@ AC_DEFUN
AM_CONDITIONAL([gl_GNULIB_ENABLED_issymlink], [$gl_gnulib_enabled_issymlink])
AM_CONDITIONAL([gl_GNULIB_ENABLED_issymlinkat], [$gl_gnulib_enabled_issymlinkat])
AM_CONDITIONAL([gl_GNULIB_ENABLED_lchmod], [$gl_gnulib_enabled_lchmod])
- AM_CONDITIONAL([gl_GNULIB_ENABLED_localtime], [$gl_gnulib_enabled_localtime])
AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31])
AM_CONDITIONAL([gl_GNULIB_ENABLED_open], [$gl_gnulib_enabled_open])
AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [$gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7])
@@ -1137,7 +1105,6 @@ AC_DEFUN
AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [$gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c])
AM_CONDITIONAL([gl_GNULIB_ENABLED_stdc_memreverse8u], [$gl_gnulib_enabled_stdc_memreverse8u])
AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll])
- AM_CONDITIONAL([gl_GNULIB_ENABLED_tzsanitize], [$gl_gnulib_enabled_tzsanitize])
AM_CONDITIONAL([gl_GNULIB_ENABLED_utimens], [$gl_gnulib_enabled_utimens])
AM_CONDITIONAL([gl_GNULIB_ENABLED_verify], [$gl_gnulib_enabled_verify])
# End of code from modules
@@ -1442,7 +1409,6 @@ AC_DEFUN
lib/lchmod.c
lib/libc-config.h
lib/limits.in.h
- lib/localtime.c
lib/lstat.c
lib/malloc.c
lib/malloc/dynarray-skeleton.c
@@ -1560,8 +1526,6 @@ AC_DEFUN
lib/timespec-sub.c
lib/timespec.c
lib/timespec.h
- lib/tzsanitize.c
- lib/tzsanitize.h
lib/u64.c
lib/u64.h
lib/unistd.c
@@ -1635,7 +1599,6 @@ AC_DEFUN
m4/libgmp.m4
m4/limits-h.m4
m4/locale-en.m4
- m4/localtime.m4
m4/lstat.m4
m4/malloc.m4
m4/manywarnings-c++.m4
diff --git a/m4/localtime.m4 b/m4/localtime.m4
deleted file mode 100644
index 5b96cf960c3..00000000000
--- a/m4/localtime.m4
+++ /dev/null
@@ -1,16 +0,0 @@
-# localtime.m4
-# serial 3
-dnl Copyright (C) 2017-2026 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-dnl This file is offered as-is, without any warranty.
-
-AC_DEFUN([gl_FUNC_LOCALTIME],
-[
- AC_REQUIRE([gl_TIME_H_DEFAULTS])
- AC_REQUIRE([AC_CANONICAL_HOST])
- case "$host_os" in
- mingw* | windows*) REPLACE_LOCALTIME=1 ;;
- esac
-])
diff --git a/nt/gnulib-cfg.mk b/nt/gnulib-cfg.mk
index fd551fb88c4..288c9b11209 100644
--- a/nt/gnulib-cfg.mk
+++ b/nt/gnulib-cfg.mk
@@ -60,7 +60,6 @@ OMIT_GNULIB_MODULE_futimens =
OMIT_GNULIB_MODULE_issymlink = true
OMIT_GNULIB_MODULE_issymlinkat = true
OMIT_GNULIB_MODULE_lchmod = true
-OMIT_GNULIB_MODULE_localtime = true
OMIT_GNULIB_MODULE_malloc-gnu = true
OMIT_GNULIB_MODULE_malloc-posix = true
OMIT_GNULIB_MODULE_nanosleep = true
diff --git a/src/timefns.c b/src/timefns.c
index 674cb3622d8..f3471a3ce1a 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -41,7 +41,6 @@ Copyright (C) 1985-1987, 1989, 1993-2026 Free Software Foundation, Inc.
#include <stdlib.h>
#ifdef WINDOWSNT
-# include <tzsanitize.h>
extern clock_t sys_clock (void);
#endif
@@ -201,7 +200,6 @@ tm_diff (struct tm *a, struct tm *b)
emacs_localtime_rz (timezone_t tz, time_t const *t, struct tm *tm)
{
#ifdef WINDOWSNT
- tzsanitize ();
/* 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).
@@ -326,11 +324,8 @@ tzlookup (Lisp_Object zone, bool settz)
{
block_input ();
emacs_setenv_TZ (zone_string);
-#ifndef WINDOWSNT
- tzset ();
-#else /* WINDOWSNT */
- tzsanitize ();
tzset ();
+#ifdef WINDOWSNT
w32_fix_tzset ();
#endif
timezone_t old_tz = local_tz;
diff --git a/src/w32.c b/src/w32.c
index 7f378c1f4d1..7914f025d3e 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -37,9 +37,6 @@ #define DEFER_MS_W32_H
#include <sys/file.h>
#include <sys/types.h> /* must be before <time.h>, for MinGW64 */
#include <time.h> /* must be before nt/inc/sys/time.h, for MinGW64 */
-#ifdef localtime /* Gnulib's time.h redirects to rpl_localtime */
-# undef localtime
-#endif
#include <sys/time.h>
#include <sys/utime.h>
#include <math.h>
@@ -269,8 +266,6 @@ #define FSCTL_GET_REPARSE_POINT \
#include <c-strcase.h>
#include <utimens.h> /* for fdutimens */
-#include <tzsanitize.h>
-
#include "w32.h"
#include <dirent.h>
#include "w32common.h"
@@ -10347,18 +10342,11 @@ w32_fix_tzset (void)
struct tm *
sys_localtime (const time_t *t)
{
- tzsanitize ();
tzset ();
w32_fix_tzset ();
return localtime (t);
}
-struct tm *
-rpl_localtime (const time_t *t)
-{
- return sys_localtime (t);
-}
-
/* The Windows CRT implementation of 'clock' doesn't really return CPU
time of the process (it returns the elapsed time since the process
started), so we provide a better emulation here, if possible. */
--
2.56.0