tzset: Remove workaround for Solaris 2.6.
authorBruno Haible <bruno@clisp.org>
Sun, 26 Jul 2020 11:17:18 +0000 (13:17 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 26 Jul 2020 11:39:46 +0000 (13:39 +0200)
* m4/tzset.m4 (gl_FUNC_TZSET_CLOBBER): Remove macro.
(gl_FUNC_TZSET): Don't invoke it. Don't define TZSET_CLOBBERS_LOCALTIME.
Don't require gl_LOCALTIME_BUFFER_DEFAULTS.
* lib/localtime-buffer.h: Don't test TZSET_CLOBBERS_LOCALTIME.
* lib/localtime-buffer.c: Likewise.
* lib/localtime.c: Likewise.
* lib/tzset.c: Don't include localtime-buffer.h.
(tzset): Don't test TZSET_CLOBBERS_LOCALTIME.
* lib/nstrftime.c (__strftime_internal): Assume HAVE_RUN_TZSET_TEST
is 1.
* modules/tzset (Depends-on): Remove localtime-buffer.

ChangeLog
lib/localtime-buffer.c
lib/localtime-buffer.h
lib/localtime.c
lib/nstrftime.c
lib/tzset.c
m4/tzset.m4
modules/tzset

index fc4b46ebe9ae809513c85cc24190d702984a6b72..a62ab5bee8eff449288e970130810a527fe7caf4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2020-07-26  Bruno Haible  <bruno@clisp.org>
+
+       tzset: Remove workaround for Solaris 2.6.
+       * m4/tzset.m4 (gl_FUNC_TZSET_CLOBBER): Remove macro.
+       (gl_FUNC_TZSET): Don't invoke it. Don't define TZSET_CLOBBERS_LOCALTIME.
+       Don't require gl_LOCALTIME_BUFFER_DEFAULTS.
+       * lib/localtime-buffer.h: Don't test TZSET_CLOBBERS_LOCALTIME.
+       * lib/localtime-buffer.c: Likewise.
+       * lib/localtime.c: Likewise.
+       * lib/tzset.c: Don't include localtime-buffer.h.
+       (tzset): Don't test TZSET_CLOBBERS_LOCALTIME.
+       * lib/nstrftime.c (__strftime_internal): Assume HAVE_RUN_TZSET_TEST
+       is 1.
+       * modules/tzset (Depends-on): Remove localtime-buffer.
+
 2020-07-26  Bruno Haible  <bruno@clisp.org>
 
        expl: Simplify autoconf test.
index d38627158f98f5f9557fea5907beeddab50602e7..91b073edd52f8e4658d9183e3b53e90b59c70a0c 100644 (file)
@@ -22,7 +22,7 @@
 /* Specification.  */
 #include "localtime-buffer.h"
 
-#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME
+#if GETTIMEOFDAY_CLOBBERS_LOCALTIME
 
 static struct tm tm_zero_buffer;
 struct tm *localtime_buffer_addr = &tm_zero_buffer;
index 43d249def64c59b01a4f883b60f9c8e4959b4cda..9939d81cf6e9c54a6439c3fea5d44b0a523fa7c6 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <time.h>
 
-#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME
+#if GETTIMEOFDAY_CLOBBERS_LOCALTIME
 
 /* The address of the last buffer returned by localtime() or gmtime().  */
 extern struct tm *localtime_buffer_addr;
index dde6b754bb6be49f7424b73dc4f5c0c6f9ded3a6..90709939415cf8a440094031e5125c3e9431b765 100644 (file)
@@ -20,7 +20,7 @@
 #include <time.h>
 
 /* Keep consistent with localtime-buffer.c!  */
-#if !(GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME)
+#if !GETTIMEOFDAY_CLOBBERS_LOCALTIME
 
 # include <stdlib.h>
 # include <string.h>
index fa7ac538dadf25469555386db7a7c8ec00899585..791fbff7fdb06754cdfa0cafdce4c401b4e7bc88 100644 (file)
@@ -495,15 +495,6 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
   const char *format_end = NULL;
 #endif
 
-#if ! defined _LIBC && ! HAVE_RUN_TZSET_TEST
-  /* Solaris 2.5.x and 2.6 tzset sometimes modify the storage returned
-     by localtime.  On such systems, we must either use the tzset and
-     localtime wrappers to work around the bug (which sets
-     HAVE_RUN_TZSET_TEST) or make a copy of the structure.  */
-  struct tm copy = *tp;
-  tp = &copy;
-#endif
-
   zone = NULL;
 #if HAVE_TM_ZONE
   /* The POSIX test suite assumes that setting
index e3543ba607388875790cefb1aa9ebf8e88370b18..cd209e19491333d66fbb5f8e17a15e3a5e31d1b6 100644 (file)
@@ -25,8 +25,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "localtime-buffer.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
@@ -37,12 +35,6 @@ void
 tzset (void)
 #undef tzset
 {
-#if TZSET_CLOBBERS_LOCALTIME
-  /* Save and restore the contents of the buffer used for localtime's
-     result around the call to tzset.  */
-  struct tm save = *localtime_buffer_addr;
-#endif
-
 #if defined _WIN32 && ! defined __CYGWIN__
   /* Rectify the value of the environment variable TZ.
      There are four possible kinds of such values:
@@ -79,8 +71,4 @@ tzset (void)
 #else
   /* Do nothing.  Avoid infinite recursion.  */
 #endif
-
-#if TZSET_CLOBBERS_LOCALTIME
-  *localtime_buffer_addr = save;
-#endif
 }
index 7d987d8860332d74845a0f46ca8799e8f5a3bff1..31ef601a049a3a61e4277cd238b5256ffe323cec 100644 (file)
@@ -1,85 +1,22 @@
-# serial 13
+# serial 14
 
 # Copyright (C) 2003, 2007, 2009-2020 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# See if we have a working tzset function.
-# If so, arrange to compile the wrapper function.
-# For at least Solaris 2.5.1 and 2.6, this is necessary
-# because tzset can clobber the contents of the buffer
-# used by localtime.
-
 # Written by Paul Eggert and Jim Meyering.
 
 AC_DEFUN([gl_FUNC_TZSET],
 [
   AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
-  AC_REQUIRE([gl_LOCALTIME_BUFFER_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST])
   AC_CHECK_FUNCS_ONCE([tzset])
   if test $ac_cv_func_tzset = no; then
     HAVE_TZSET=0
   fi
-  gl_FUNC_TZSET_CLOBBER
   REPLACE_TZSET=0
-  case "$gl_cv_func_tzset_clobber" in
-    *yes)
-      REPLACE_TZSET=1
-      AC_DEFINE([TZSET_CLOBBERS_LOCALTIME], [1],
-        [Define if tzset clobbers localtime's static buffer.])
-      gl_LOCALTIME_BUFFER_NEEDED
-      ;;
-  esac
   case "$host_os" in
     mingw*) REPLACE_TZSET=1 ;;
   esac
 ])
-
-# Set gl_cv_func_tzset_clobber.
-AC_DEFUN([gl_FUNC_TZSET_CLOBBER],
-[
-  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-  AC_CACHE_CHECK([whether tzset clobbers localtime buffer],
-                 [gl_cv_func_tzset_clobber],
-    [AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <time.h>
-#include <stdlib.h>
-
-int
-main ()
-{
-  time_t t1 = 853958121;
-  struct tm *p, s;
-  putenv ("TZ=GMT0");
-  p = localtime (&t1);
-  s = *p;
-  putenv ("TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00");
-  tzset ();
-  return (p->tm_year != s.tm_year
-          || p->tm_mon != s.tm_mon
-          || p->tm_mday != s.tm_mday
-          || p->tm_hour != s.tm_hour
-          || p->tm_min != s.tm_min
-          || p->tm_sec != s.tm_sec);
-}
-  ]])],
-       [gl_cv_func_tzset_clobber=no],
-       [gl_cv_func_tzset_clobber=yes],
-       [case "$host_os" in
-                         # Guess all is fine on glibc systems.
-          *-gnu* | gnu*) gl_cv_func_tzset_clobber="guessing no" ;;
-                         # Guess all is fine on musl systems.
-          *-musl*)       gl_cv_func_tzset_clobber="guessing no" ;;
-                         # Guess no on native Windows.
-          mingw*)        gl_cv_func_tzset_clobber="guessing no" ;;
-                         # If we don't know, obey --enable-cross-guesses.
-          *)             gl_cv_func_tzset_clobber="$gl_cross_guess_inverted" ;;
-        esac
-       ])
-    ])
-
-  AC_DEFINE([HAVE_RUN_TZSET_TEST], [1],
-    [Define to 1 if you have run the test for working tzset.])
-])
index 5f036b07a68375ecad2b5c553d17189b6c074023..ff7e60b22f61fe8237f4bef471ce073cbb9d5f10 100644 (file)
@@ -7,7 +7,6 @@ m4/tzset.m4
 
 Depends-on:
 time
-localtime-buffer [test $NEED_LOCALTIME_BUFFER = 1]
 
 configure.ac:
 gl_FUNC_TZSET