From 6b9a74f9e625e8e4d96e325b959ebead48e4a192 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Wed, 23 Feb 2005 19:08:58 +0000 Subject: 2005-02-23 Jeff Johnston * libc/include/time.h [!CYGWIN](_timezone): Change to long. (__tzrule_type, __tzinfo_type): New types. (__gettzinfo): New function. * libc/sys/linux/include/time.h: Ditto. * libc/time/Makefile.am: Add gettzinfo.c. * libc/time/Makefile.in: Regenerated. * libc/time/local.h: Moved __tzrule_type to time.h. * libc/time/mktime.c: Call __gettzinfo to reference __tznorth, __tzyear, and __tzrule array. * libc/time/mktm_r.c: Ditto. * libc/time/strftime.c: Ditto. * libc/time/tzset_r.c: Ditto. Also remove definition of __tzrule which is now in gettzinfo.c. Change _timezone references to not cast to time_t. * libc/time/gettzinfo.c: New file. --- newlib/libc/time/tzset_r.c | 54 +++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 30 deletions(-) (limited to 'newlib/libc/time/tzset_r.c') diff --git a/newlib/libc/time/tzset_r.c b/newlib/libc/time/tzset_r.c index d6894410f..49e519de5 100644 --- a/newlib/libc/time/tzset_r.c +++ b/newlib/libc/time/tzset_r.c @@ -14,14 +14,7 @@ static char *prev_tzenv = NULL; /* default to GMT */ char *_tzname[2] = {"GMT", "GMT"}; int _daylight = 0; -time_t _timezone = (time_t)0; - -int __tzyear = 0; - -int __tznorth = 1; - -__tzrule_type __tzrule[2] = { {'J', 0, 0, 0, 0, (time_t)0, 0 }, - {'J', 0, 0, 0, 0, (time_t)0, 0 } }; +long _timezone = 0; _VOID _DEFUN (_tzset_r, (reent_ptr), @@ -31,11 +24,12 @@ _DEFUN (_tzset_r, (reent_ptr), unsigned short hh, mm, ss, m, w, d; int sign, n; int i, ch; + __tzinfo_type *tz = __gettzinfo (); if ((tzenv = _getenv_r (reent_ptr, "TZ")) == NULL) { TZ_LOCK; - _timezone = (time_t)0; + _timezone = 0; _daylight = 0; _tzname[0] = "GMT"; _tzname[1] = "GMT"; @@ -86,7 +80,7 @@ _DEFUN (_tzset_r, (reent_ptr), return; } - __tzrule[0].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh); + tz->__tzrule[0].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh); _tzname[0] = __tzname_std; tzenv += n; @@ -116,9 +110,9 @@ _DEFUN (_tzset_r, (reent_ptr), ss = 0; if (sscanf (tzenv, "%hu%n:%hu%n:%hu%n", &hh, &n, &mm, &n, &ss, &n) <= 0) - __tzrule[1].offset = __tzrule[0].offset - 3600; + tz->__tzrule[1].offset = tz->__tzrule[0].offset - 3600; else - __tzrule[1].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh); + tz->__tzrule[1].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh); tzenv += n; @@ -136,10 +130,10 @@ _DEFUN (_tzset_r, (reent_ptr), return; } - __tzrule[i].ch = 'M'; - __tzrule[i].m = m; - __tzrule[i].n = w; - __tzrule[i].d = d; + tz->__tzrule[i].ch = 'M'; + tz->__tzrule[i].m = m; + tz->__tzrule[i].n = w; + tz->__tzrule[i].d = d; tzenv += n; } @@ -161,23 +155,23 @@ _DEFUN (_tzset_r, (reent_ptr), { if (i == 0) { - __tzrule[0].ch = 'M'; - __tzrule[0].m = 4; - __tzrule[0].n = 1; - __tzrule[0].d = 0; + tz->__tzrule[0].ch = 'M'; + tz->__tzrule[0].m = 4; + tz->__tzrule[0].n = 1; + tz->__tzrule[0].d = 0; } else { - __tzrule[1].ch = 'M'; - __tzrule[1].m = 10; - __tzrule[1].n = 5; - __tzrule[1].d = 0; + tz->__tzrule[1].ch = 'M'; + tz->__tzrule[1].m = 10; + tz->__tzrule[1].n = 5; + tz->__tzrule[1].d = 0; } } else { - __tzrule[i].ch = ch; - __tzrule[i].d = d; + tz->__tzrule[i].ch = ch; + tz->__tzrule[i].d = d; } tzenv = end; @@ -192,14 +186,14 @@ _DEFUN (_tzset_r, (reent_ptr), if (*tzenv == '/') sscanf (tzenv, "/%hu%n:%hu%n:%hu%n", &hh, &n, &mm, &n, &ss, &n); - __tzrule[i].s = ss + SECSPERMIN * mm + SECSPERHOUR * hh; + tz->__tzrule[i].s = ss + SECSPERMIN * mm + SECSPERHOUR * hh; tzenv += n; } - __tzcalc_limits (__tzyear); - _timezone = (time_t)(__tzrule[0].offset); - _daylight = __tzrule[0].offset != __tzrule[1].offset; + __tzcalc_limits (tz->__tzyear); + _timezone = tz->__tzrule[0].offset; + _daylight = tz->__tzrule[0].offset != tz->__tzrule[1].offset; TZ_UNLOCK; } -- cgit v1.2.3