summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-06-07 16:30:02 +0000
committerJim Meyering <jim@meyering.net>2003-06-07 16:30:02 +0000
commit6a9dbd3e338322a22045500bd4885b8247e3bfbe (patch)
tree0e6fcfa6f5bb0eaab35861371050eb376c5d308d /m4
parent98a799ac0aed93679bdee10ca2005e6080c8c4be (diff)
downloadcoreutils-6a9dbd3e338322a22045500bd4885b8247e3bfbe.tar.xz
New file. Used by strftime.m4.
Diffstat (limited to 'm4')
-rw-r--r--m4/tzset.m458
1 files changed, 58 insertions, 0 deletions
diff --git a/m4/tzset.m4 b/m4/tzset.m4
new file mode 100644
index 000000000..dbe38c9db
--- /dev/null
+++ b/m4/tzset.m4
@@ -0,0 +1,58 @@
+#serial 1
+# 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([AC_HEADER_TIME])
+ AC_CACHE_CHECK([whether tzset works],
+ gl_cv_func_tzset_vs_localtime,
+ [
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+#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 ();
+ exit (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_vs_localtime=yes],
+ [gl_cv_func_tzset_vs_localtime=no],
+ [gl_cv_func_tzset_vs_localtime=no])])
+
+ AC_DEFINE(HAVE_RUN_TZSET_TEST, 1,
+ [Define to 1 if you have run the test for working tzset.])
+ if test $gl_cv_func_tzset_vs_localtime = yes; then
+ AC_LIBOBJ(tzset)
+ AC_DEFINE(tzset, rpl_tzset,
+ [Define to rpl_tzset if the wrapper function should be used.])
+ fi
+])