Nowadays, all platforms have tzset - or, on native Windows, _tzset - in libc.
Testing for it at configure time is therefore obselete. This test is
complicating the support for native Windows, so I'm removing it.


2020-08-14  Bruno Haible  <br...@clisp.org>

        tzset: Assume the function exists.
        * lib/time.in.h (tzset): Assume HAVE_TZSET is 1.
        * lib/tzset.c: Define rpl_tzset, not tzset. Assume HAVE_TZSET is 1.
        * modules/tzset (configure.ac): Don't test HAVE_TZSET.
        * m4/tzset.m4 (gl_FUNC_TZSET): Don't test for tzset. Don't set
        HAVE_TZSET.
        * m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Don't initialize HAVE_TZSET.
        * modules/time (Makefile.am): Don't substitute HAVE_TZSET.

        nstrftime: Assume tzset exists.
        * lib/nstrftime.c (HAVE_TZSET): Remove macro.
        (__strftime_internal): Test my_strftime, not HAVE_TZSET.
        * m4/nstrftime.m4 (gl_FUNC_GNU_STRFTIME): Don't test for tzset.

        mktime, mktime-internal: Assume tzset exists.
        * lib/mktime.c (my_tzset): Assume HAVE_TZSET is 1.
        * m4/mktime.m4 (gl_FUNC_MKTIME_WORKS): Don't test for tzset.

>From 424bb97793e96c63c090e9dbf2d442a38e367c94 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Fri, 14 Aug 2020 20:02:07 +0200
Subject: [PATCH 1/3] mktime, mktime-internal: Assume tzset exists.

* lib/mktime.c (my_tzset): Assume HAVE_TZSET is 1.
* m4/mktime.m4 (gl_FUNC_MKTIME_WORKS): Don't test for tzset.
---
 ChangeLog    | 6 ++++++
 lib/mktime.c | 2 +-
 m4/mktime.m4 | 3 +--
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8b0f287..65070d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2020-08-14  Bruno Haible  <br...@clisp.org>
 
+	mktime, mktime-internal: Assume tzset exists.
+	* lib/mktime.c (my_tzset): Assume HAVE_TZSET is 1.
+	* m4/mktime.m4 (gl_FUNC_MKTIME_WORKS): Don't test for tzset.
+
+2020-08-14  Bruno Haible  <br...@clisp.org>
+
 	strdup: Assume the function exists.
 	* m4/strdup.m4 (gl_FUNC_STRDUP, gl_FUNC_STRDUP_POSIX): Don't test
 	whether strdup exists.
diff --git a/lib/mktime.c b/lib/mktime.c
index c873516..6001487 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -94,7 +94,7 @@ my_tzset (void)
   const char *tz = getenv ("TZ");
   if (tz != NULL && strchr (tz, '/') != NULL)
     _putenv ("TZ=");
-# elif HAVE_TZSET
+# else
   tzset ();
 # endif
 }
diff --git a/m4/mktime.m4 b/m4/mktime.m4
index 8d9b827..afc8a87 100644
--- a/m4/mktime.m4
+++ b/m4/mktime.m4
@@ -1,4 +1,4 @@
-# serial 32
+# serial 33
 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2020 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -31,7 +31,6 @@ AC_DEFUN([gl_FUNC_MKTIME_WORKS],
   dnl in Autoconf and because it invokes AC_LIBOBJ.
   AC_CHECK_HEADERS_ONCE([unistd.h])
   AC_CHECK_DECLS_ONCE([alarm])
-  AC_CHECK_FUNCS_ONCE([tzset])
   AC_REQUIRE([gl_MULTIARCH])
   AC_CACHE_CHECK([for working mktime], [gl_cv_func_working_mktime],
     [if test $APPLE_UNIVERSAL_BUILD = 1; then
-- 
2.7.4

>From 5afb29f59a6f1764eb3059cc0485fb50202afea1 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Fri, 14 Aug 2020 20:03:33 +0200
Subject: [PATCH 2/3] nstrftime: Assume tzset exists.

* lib/nstrftime.c (HAVE_TZSET): Remove macro.
(__strftime_internal): Test my_strftime, not HAVE_TZSET.
* m4/nstrftime.m4 (gl_FUNC_GNU_STRFTIME): Don't test for tzset.
---
 ChangeLog       | 5 +++++
 lib/nstrftime.c | 6 ++----
 m4/nstrftime.m4 | 4 +---
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 65070d7..803c67d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2020-08-14  Bruno Haible  <br...@clisp.org>
 
+	nstrftime: Assume tzset exists.
+	* lib/nstrftime.c (HAVE_TZSET): Remove macro.
+	(__strftime_internal): Test my_strftime, not HAVE_TZSET.
+	* m4/nstrftime.m4 (gl_FUNC_GNU_STRFTIME): Don't test for tzset.
+
 	mktime, mktime-internal: Assume tzset exists.
 	* lib/mktime.c (my_tzset): Assume HAVE_TZSET is 1.
 	* m4/mktime.m4 (gl_FUNC_MKTIME_WORKS): Don't test for tzset.
diff --git a/lib/nstrftime.c b/lib/nstrftime.c
index 791fbff..35b65bb 100644
--- a/lib/nstrftime.c
+++ b/lib/nstrftime.c
@@ -21,7 +21,6 @@
 # define HAVE_TM_GMTOFF 1
 # define HAVE_TM_ZONE 1
 # define HAVE_TZNAME 1
-# define HAVE_TZSET 1
 # include "../locale/localeinfo.h"
 #else
 # include <config.h>
@@ -389,7 +388,6 @@ iso_week_days (int yday, int wday)
 #endif
 
 #ifdef my_strftime
-# undef HAVE_TZSET
 # define extra_args , tz, ns
 # define extra_args_spec , timezone_t tz, int ns
 #else
@@ -523,7 +521,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
     {
       /* POSIX.1 requires that local time zone information be used as
          though strftime called tzset.  */
-# if HAVE_TZSET
+# ifndef my_strftime
       if (!*tzset_called)
         {
           tzset ();
@@ -1417,7 +1415,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
 
                 /* POSIX.1 requires that local time zone information be used as
                    though strftime called tzset.  */
-# if HAVE_TZSET
+# ifndef my_strftime
                 if (!*tzset_called)
                   {
                     tzset ();
diff --git a/m4/nstrftime.m4 b/m4/nstrftime.m4
index 6f2762a..e4eb87d 100644
--- a/m4/nstrftime.m4
+++ b/m4/nstrftime.m4
@@ -1,4 +1,4 @@
-# serial 35
+# serial 36
 
 # Copyright (C) 1996-1997, 1999-2007, 2009-2020 Free Software Foundation, Inc.
 #
@@ -17,8 +17,6 @@ AC_DEFUN([gl_FUNC_GNU_STRFTIME],
 
  AC_REQUIRE([gl_TM_GMTOFF])
 
- AC_CHECK_FUNCS_ONCE([tzset])
-
  AC_DEFINE([my_strftime], [nstrftime],
    [Define to the name of the strftime replacement function.])
 ])
-- 
2.7.4

>From 05486abf0559efa3764ae3fbe8f6fbe5f6322df8 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Fri, 14 Aug 2020 20:06:32 +0200
Subject: [PATCH 3/3] tzset: Assume the function exists.

* lib/time.in.h (tzset): Assume HAVE_TZSET is 1.
* lib/tzset.c: Define rpl_tzset, not tzset. Assume HAVE_TZSET is 1.
* modules/tzset (configure.ac): Don't test HAVE_TZSET.
* m4/tzset.m4 (gl_FUNC_TZSET): Don't test for tzset. Don't set
HAVE_TZSET.
* m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Don't initialize HAVE_TZSET.
* modules/time (Makefile.am): Don't substitute HAVE_TZSET.
---
 ChangeLog     |  9 +++++++++
 lib/time.in.h |  3 ---
 lib/tzset.c   | 12 ++----------
 m4/time_h.m4  |  1 -
 m4/tzset.m4   |  6 +-----
 modules/time  |  1 -
 modules/tzset |  2 +-
 7 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 803c67d..85e1258 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2020-08-14  Bruno Haible  <br...@clisp.org>
 
+	tzset: Assume the function exists.
+	* lib/time.in.h (tzset): Assume HAVE_TZSET is 1.
+	* lib/tzset.c: Define rpl_tzset, not tzset. Assume HAVE_TZSET is 1.
+	* modules/tzset (configure.ac): Don't test HAVE_TZSET.
+	* m4/tzset.m4 (gl_FUNC_TZSET): Don't test for tzset. Don't set
+	HAVE_TZSET.
+	* m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Don't initialize HAVE_TZSET.
+	* modules/time (Makefile.am): Don't substitute HAVE_TZSET.
+
 	nstrftime: Assume tzset exists.
 	* lib/nstrftime.c (HAVE_TZSET): Remove macro.
 	(__strftime_internal): Test my_strftime, not HAVE_TZSET.
diff --git a/lib/time.in.h b/lib/time.in.h
index e10e90c..7ad7d00 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -136,9 +136,6 @@ _GL_CXXALIASWARN (nanosleep);
 _GL_FUNCDECL_RPL (tzset, void, (void));
 _GL_CXXALIAS_RPL (tzset, void, (void));
 #  else
-#   if ! @HAVE_TZSET@
-_GL_FUNCDECL_SYS (tzset, void, (void));
-#   endif
 _GL_CXXALIAS_SYS (tzset, void, (void));
 #  endif
 _GL_CXXALIASWARN (tzset);
diff --git a/lib/tzset.c b/lib/tzset.c
index cd209e1..681f073 100644
--- a/lib/tzset.c
+++ b/lib/tzset.c
@@ -25,14 +25,8 @@
 #include <stdlib.h>
 #include <string.h>
 
-/* This is a wrapper for tzset, for systems on which tzset may clobber
-   the static buffer used for localtime's result.
-   Work around the bug in some systems whereby tzset clobbers the
-   static buffer that localtime uses for its return value.  The
-   tzset function from Solaris 2.5, 2.5.1, and 2.6 has this problem.  */
-
 void
-tzset (void)
+rpl_tzset (void)
 #undef tzset
 {
 #if defined _WIN32 && ! defined __CYGWIN__
@@ -66,9 +60,7 @@ tzset (void)
      <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/posix-tzset>
      <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/tzset>  */
   _tzset ();
-#elif HAVE_TZSET
-  tzset ();
 #else
-  /* Do nothing.  Avoid infinite recursion.  */
+  tzset ();
 #endif
 }
diff --git a/m4/time_h.m4 b/m4/time_h.m4
index d0f8932..a15c09d 100644
--- a/m4/time_h.m4
+++ b/m4/time_h.m4
@@ -121,7 +121,6 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
   HAVE_NANOSLEEP=1;                      AC_SUBST([HAVE_NANOSLEEP])
   HAVE_STRPTIME=1;                       AC_SUBST([HAVE_STRPTIME])
   HAVE_TIMEGM=1;                         AC_SUBST([HAVE_TIMEGM])
-  HAVE_TZSET=1;                          AC_SUBST([HAVE_TZSET])
   dnl Even GNU libc does not have timezone_t yet.
   HAVE_TIMEZONE_T=0;                     AC_SUBST([HAVE_TIMEZONE_T])
   dnl If another module says to replace or to not replace, do that.
diff --git a/m4/tzset.m4 b/m4/tzset.m4
index 31ef601..a504d5e 100644
--- a/m4/tzset.m4
+++ b/m4/tzset.m4
@@ -1,4 +1,4 @@
-# serial 14
+# serial 15
 
 # Copyright (C) 2003, 2007, 2009-2020 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -11,10 +11,6 @@ AC_DEFUN([gl_FUNC_TZSET],
 [
   AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST])
-  AC_CHECK_FUNCS_ONCE([tzset])
-  if test $ac_cv_func_tzset = no; then
-    HAVE_TZSET=0
-  fi
   REPLACE_TZSET=0
   case "$host_os" in
     mingw*) REPLACE_TZSET=1 ;;
diff --git a/modules/time b/modules/time
index c235ac8..3daa751 100644
--- a/modules/time
+++ b/modules/time
@@ -44,7 +44,6 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
 	      -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
 	      -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
 	      -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
-	      -e 's|@''HAVE_TZSET''@|$(HAVE_TZSET)|g' \
 	      -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \
 	      -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
 	      -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \
diff --git a/modules/tzset b/modules/tzset
index ff7e60b..5423f3a 100644
--- a/modules/tzset
+++ b/modules/tzset
@@ -10,7 +10,7 @@ time
 
 configure.ac:
 gl_FUNC_TZSET
-if test $HAVE_TZSET = 0 || test $REPLACE_TZSET = 1; then
+if test $REPLACE_TZSET = 1; then
   AC_LIBOBJ([tzset])
 fi
 gl_TIME_MODULE_INDICATOR([tzset])
-- 
2.7.4

Reply via email to