[tz] zdump broken with -DUSE_LTZ=0
Paul Eggert
eggert at cs.ucla.edu
Wed Dec 21 17:21:08 UTC 2016
Thanks for reporting that. I installed the attached proposed patch into
the development repository.
-------------- next part --------------
From ad67d5828c6e28d7ad2ae0c9232ec614d953cc1d Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert at cs.ucla.edu>
Date: Wed, 21 Dec 2016 09:18:06 -0800
Subject: [PROPOSED] Port zdump to -DUSE_LTZ=0 etc.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Problem reported by Joseph Myers in:
http://mm.icann.org/pipermail/tz/2016-December/024721.html
* NEWS: Document this.
* Makefile (GCC_DEBUG_FLAGS): Add -Wundef.
* localtime.c (THREAD_SAFE): Don’t assume it’s defined.
* zdump.c (HAVE_POSIX_DECLS, HAVE_UNISTD_H, INITIALIZE):
Add default definitions, in case USE_LTZ is zero.
Include <unistd.h> if HAVE_UNISTD_H.
---
Makefile | 2 +-
NEWS | 3 +++
localtime.c | 2 +-
zdump.c | 28 ++++++++++++++++++++++++----
4 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index a8e52ee..8067ba0 100644
--- a/Makefile
+++ b/Makefile
@@ -168,7 +168,7 @@ GCC_DEBUG_FLAGS = -Dlint -g3 -O3 -fno-common -fstrict-aliasing \
-Wshadow -Wstrict-prototypes -Wsuggest-attribute=const \
-Wsuggest-attribute=format -Wsuggest-attribute=noreturn \
-Wsuggest-attribute=pure -Wtrampolines \
- -Wunused -Wwrite-strings \
+ -Wundef -Wunused -Wwrite-strings \
-Wno-address -Wno-format-nonliteral -Wno-sign-compare \
-Wno-type-limits -Wno-unused-parameter
#
diff --git a/NEWS b/NEWS
index 42421e7..1b9fa5a 100644
--- a/NEWS
+++ b/NEWS
@@ -67,6 +67,9 @@ Unreleased, experimental changes
with zic %z and with common practice, and simplifies auditing of
zdump output.
+ zdump is now buildable again with -DUSE_LTZ=0.
+ (Problem reported bny Joseph Myers.)
+
Changes to documentation and commentary
tz-link.htm now covers leap smearing, which is popular in clouds.
diff --git a/localtime.c b/localtime.c
index 385b6bb..3edd1b3 100644
--- a/localtime.c
+++ b/localtime.c
@@ -16,7 +16,7 @@
#include "tzfile.h"
#include "fcntl.h"
-#if THREAD_SAFE
+#if defined THREAD_SAFE && THREAD_SAFE
# include <pthread.h>
static pthread_mutex_t locallock = PTHREAD_MUTEX_INITIALIZER;
static int lock(void) { return pthread_mutex_lock(&locallock); }
diff --git a/zdump.c b/zdump.c
index bfef419..1ddc6c6 100644
--- a/zdump.c
+++ b/zdump.c
@@ -23,6 +23,11 @@
# include "private.h"
#endif
+/*
+** Substitutes for pre-C99 and pre-POSIX platforms.
+** Much of this section of code is stolen from private.h.
+*/
+
/* Enable tm_gmtoff and tm_zone on GNUish systems. */
#define _GNU_SOURCE 1
/* Enable strtoimax on Solaris 10. */
@@ -36,10 +41,17 @@
#include "limits.h" /* for CHAR_BIT, LLONG_MAX */
#include <errno.h>
-/*
-** Substitutes for pre-C99 compilers.
-** Much of this section of code is stolen from private.h.
-*/
+#ifndef HAVE_POSIX_DECLS
+# define HAVE_POSIX_DECLS 1
+#endif
+
+#ifndef HAVE_UNISTD_H
+# define HAVE_UNISTD_H 1
+#endif
+
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#ifndef HAVE_STDINT_H
# define HAVE_STDINT_H \
@@ -159,6 +171,14 @@ typedef long intmax_t;
1 + TYPE_SIGNED(type))
#endif /* !defined INT_STRLEN_MAXIMUM */
+#ifndef INITIALIZE
+# ifdef lint
+# define INITIALIZE(x) ((x) = 0)
+# else
+# define INITIALIZE(x)
+# endif
+#endif
+
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif /* !defined EXIT_SUCCESS */
--
2.7.4
More information about the tz
mailing list