[tz] [PROPOSED PATCH 1/9] zdump: use TM_ZONE if available
Paul Eggert
eggert at cs.ucla.edu
Mon Aug 25 06:59:45 UTC 2014
* zdump.c (abbr): Return pointer-to-const. Use TM_ZONE if
available, as it's simpler, more reliable, and a tad faster.
---
zdump.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/zdump.c b/zdump.c
index a04ba99..9eb434e 100644
--- a/zdump.c
+++ b/zdump.c
@@ -225,7 +225,7 @@ static char * progname;
static bool warned;
static bool errout;
-static char *abbr(struct tm const *);
+static char const *abbr(struct tm const *);
static intmax_t delta(struct tm *, struct tm *) ATTRIBUTE_PURE;
static void dumptime(struct tm const *);
static time_t hunt(char *, time_t, time_t);
@@ -738,16 +738,17 @@ show(char *zone, time_t t, bool v)
abbrok(abbr(tmp), zone);
}
-static char *
+static char const *
abbr(struct tm const *tmp)
{
- register char * result;
- static char nada;
-
- if (tmp->tm_isdst != 0 && tmp->tm_isdst != 1)
- return &nada;
- result = tzname[tmp->tm_isdst];
- return (result == NULL) ? &nada : result;
+#ifdef TM_ZONE
+ return tmp->TM_ZONE;
+#else
+ return ((0 <= tmp->tm_isdst && tmp->tm_isdst <= 1
+ && tzname[tmp->tm_isdst])
+ ? tzname[tmp->tm_isdst]
+ : "");
+#endif
}
/*
--
1.9.1
More information about the tz
mailing list