[tz] [PROPOSED PATCH] Declare timezone, daylight, altzone in private.h
Paul Eggert
eggert at cs.ucla.edu
Tue Sep 15 06:37:59 UTC 2015
* NEWS: Document this.
* private.h (timezone, daylight) [USG_COMPAT]:
(altzone) [ALTZONE]:
Declare as extern if not defined as a macro.
This may avoid problems in environments where these variables
are not declared by the system <time.h>.
>From a suggestion by Kees Dekker in:
http://mm.icann.org/pipermail/tz/2015-August/022627.html
---
NEWS | 5 ++++-
private.h | 13 +++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 37f461f..2bbb967 100644
--- a/NEWS
+++ b/NEWS
@@ -13,10 +13,13 @@ Unreleased, experimental changes
(Thanks to Bradley White for reporting the bug.)
The localtime module allows the variables 'timezone', 'daylight',
- and 'altzone' to be in common storage shared with other modules.
+ and 'altzone' to be in common storage shared with other modules,
+ and declares them in case the system <time.h> does not.
+ (Problems reported by Kees Dekker.)
On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
+ (Problem reported by Christos Zoulas.)
Changes affecting documentation
diff --git a/private.h b/private.h
index 184da8f..1c176e6 100644
--- a/private.h
+++ b/private.h
@@ -383,12 +383,25 @@ void tzset(void);
** Some time.h implementations don't declare asctime_r.
** Others might define it as a macro.
** Fix the former without affecting the latter.
+** Similarly for timezone, daylight, and altzone.
*/
#ifndef asctime_r
extern char * asctime_r(struct tm const *restrict, char *restrict);
#endif
+#ifdef USG_COMPAT
+# ifndef timezone
+extern long timezone;
+# endif
+# ifndef daylight
+extern int daylight;
+# endif
+#endif
+#if defined ALTZONE && !defined altzone
+extern long altzone;
+#endif
+
/*
** The STD_INSPIRED functions are similar, but most also need
** declarations if time_tz is defined.
--
2.1.4
More information about the tz
mailing list