From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 3 Jul 2016 10:59:54 +0000 (+0200)
Subject: mktime: call tzset as per POSIX
X-Git-Tag: v1.0~6719
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=97173b26d27d9f31de1789e994dfe014e3a40162;p=gnulib.git

mktime: call tzset as per POSIX

Problem reported by Ludovic Courtès in:
http://lists.gnu.org/archive/html/bug-gnulib/2016-06/msg00068.html
* lib/mktime.c (mktime) [!_LIBC && HAVE_TZSET]: Call tzset.
* m4/mktime.m4 (gl_FUNC_MKTIME): Check for tzset.
---

diff --git a/ChangeLog b/ChangeLog
index 34b651f242..ef332683bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-07-03  Paul Eggert  <eggert@cs.ucla.edu>
+
+	mktime: call tzset as per POSIX
+	Problem reported by Ludovic Courtès in:
+	http://lists.gnu.org/archive/html/bug-gnulib/2016-06/msg00068.html
+	* lib/mktime.c (mktime) [!_LIBC && HAVE_TZSET]: Call tzset.
+	* m4/mktime.m4 (gl_FUNC_MKTIME): Check for tzset.
+
 2016-06-26  Pádraig Brady  <P@draigBrady.com>
 
 	fts: handle readdir() errors
diff --git a/lib/mktime.c b/lib/mktime.c
index 87ab633a13..9eb3e76524 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -470,6 +470,8 @@ mktime (struct tm *tp)
      time zone names contained in the external variable 'tzname' shall
      be set as if the tzset() function had been called.  */
   __tzset ();
+#elif HAVE_TZSET
+  tzset ();
 #endif
 
   return __mktime_internal (tp, __localtime_r, &localtime_offset);
diff --git a/m4/mktime.m4 b/m4/mktime.m4
index 5a0f2d88ab..23cad732ff 100644
--- a/m4/mktime.m4
+++ b/m4/mktime.m4
@@ -1,4 +1,4 @@
-# serial 26
+# serial 27
 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2016 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -30,6 +30,7 @@ AC_DEFUN([gl_FUNC_MKTIME],
   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])
   if test $APPLE_UNIVERSAL_BUILD = 1; then
     # A universal build on Apple Mac OS X platforms.