2005-02-23 Jeff Johnston <jjohnstn@redhat.com>
* 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.
This commit is contained in:
parent
3a021c19f4
commit
6b9a74f9e6
@ -1,3 +1,21 @@
|
|||||||
|
2005-02-23 Jeff Johnston <jjohnstn@redhat.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2005-02-23 Corinna Vinschen <corinna@vinschen.de>
|
2005-02-23 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* libc/include/sys/unistd.h: Define getpeereid for Cygwin.
|
* libc/include/sys/unistd.h: Define getpeereid for Cygwin.
|
||||||
|
@ -71,6 +71,26 @@ char *_EXFUN(strptime, (const char *, const char *, struct tm *));
|
|||||||
_VOID _EXFUN(tzset, (_VOID));
|
_VOID _EXFUN(tzset, (_VOID));
|
||||||
_VOID _EXFUN(_tzset_r, (struct _reent *));
|
_VOID _EXFUN(_tzset_r, (struct _reent *));
|
||||||
|
|
||||||
|
typedef struct __tzrule_struct
|
||||||
|
{
|
||||||
|
char ch;
|
||||||
|
int m;
|
||||||
|
int n;
|
||||||
|
int d;
|
||||||
|
int s;
|
||||||
|
time_t change;
|
||||||
|
int offset;
|
||||||
|
} __tzrule_type;
|
||||||
|
|
||||||
|
typedef struct __tzinfo_struct
|
||||||
|
{
|
||||||
|
int __tznorth;
|
||||||
|
int __tzyear;
|
||||||
|
__tzrule_type __tzrule[2];
|
||||||
|
} __tzinfo_type;
|
||||||
|
|
||||||
|
__tzinfo_type *_EXFUN (__gettzinfo, (_VOID));
|
||||||
|
|
||||||
/* getdate functions */
|
/* getdate functions */
|
||||||
|
|
||||||
#ifdef HAVE_GETDATE
|
#ifdef HAVE_GETDATE
|
||||||
@ -95,7 +115,11 @@ int _EXFUN(getdate_r, (const char *, struct tm *));
|
|||||||
#endif /* HAVE_GETDATE */
|
#endif /* HAVE_GETDATE */
|
||||||
|
|
||||||
/* defines for the opengroup specifications Derived from Issue 1 of the SVID. */
|
/* defines for the opengroup specifications Derived from Issue 1 of the SVID. */
|
||||||
|
#ifdef __CYGWIN__
|
||||||
extern __IMPORT time_t _timezone;
|
extern __IMPORT time_t _timezone;
|
||||||
|
#else
|
||||||
|
extern __IMPORT long _timezone;
|
||||||
|
#endif
|
||||||
extern __IMPORT int _daylight;
|
extern __IMPORT int _daylight;
|
||||||
extern __IMPORT char *_tzname[2];
|
extern __IMPORT char *_tzname[2];
|
||||||
|
|
||||||
|
@ -84,6 +84,26 @@ char *_EXFUN(strptime, (const char *, const char *, struct tm *));
|
|||||||
_VOID _EXFUN(tzset, (_VOID));
|
_VOID _EXFUN(tzset, (_VOID));
|
||||||
_VOID _EXFUN(_tzset_r, (struct _reent *));
|
_VOID _EXFUN(_tzset_r, (struct _reent *));
|
||||||
|
|
||||||
|
typedef struct __tzrule_struct
|
||||||
|
{
|
||||||
|
char ch;
|
||||||
|
int m;
|
||||||
|
int n;
|
||||||
|
int d;
|
||||||
|
int s;
|
||||||
|
time_t change;
|
||||||
|
int offset;
|
||||||
|
} __tzrule_type;
|
||||||
|
|
||||||
|
typedef struct __tzinfo_struct
|
||||||
|
{
|
||||||
|
int __tznorth;
|
||||||
|
int __tzyear;
|
||||||
|
__tzrule_type __tzrule[2];
|
||||||
|
} __tzinfo_type;
|
||||||
|
|
||||||
|
__tzinfo_type *_EXFUN (__gettzinfo, (_VOID));
|
||||||
|
|
||||||
/* getdate functions */
|
/* getdate functions */
|
||||||
|
|
||||||
#ifndef _REENT_ONLY
|
#ifndef _REENT_ONLY
|
||||||
@ -106,7 +126,7 @@ struct tm * _EXFUN(getdate, (const char *));
|
|||||||
int _EXFUN(getdate_r, (const char *, struct tm *));
|
int _EXFUN(getdate_r, (const char *, struct tm *));
|
||||||
|
|
||||||
/* defines for the opengroup specifications Derived from Issue 1 of the SVID. */
|
/* defines for the opengroup specifications Derived from Issue 1 of the SVID. */
|
||||||
extern __IMPORT time_t _timezone;
|
extern __IMPORT long _timezone;
|
||||||
extern __IMPORT int _daylight;
|
extern __IMPORT int _daylight;
|
||||||
extern __IMPORT char *_tzname[2];
|
extern __IMPORT char *_tzname[2];
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ LIB_SOURCES = \
|
|||||||
ctime.c \
|
ctime.c \
|
||||||
ctime_r.c \
|
ctime_r.c \
|
||||||
difftime.c \
|
difftime.c \
|
||||||
|
gettzinfo.c \
|
||||||
gmtime.c \
|
gmtime.c \
|
||||||
gmtime_r.c \
|
gmtime_r.c \
|
||||||
lcltime.c \
|
lcltime.c \
|
||||||
|
@ -110,7 +110,7 @@ AUTOMAKE_OPTIONS = cygnus
|
|||||||
|
|
||||||
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
|
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
|
||||||
|
|
||||||
LIB_SOURCES = asctime.c asctime_r.c clock.c ctime.c ctime_r.c difftime.c gmtime.c gmtime_r.c lcltime.c lcltime_r.c mktime.c mktm_r.c strftime.c strptime.c time.c tzlock.c tzset.c tzset_r.c
|
LIB_SOURCES = asctime.c asctime_r.c clock.c ctime.c ctime_r.c difftime.c gettzinfo.c gmtime.c gmtime_r.c lcltime.c lcltime_r.c mktime.c mktm_r.c strftime.c strptime.c time.c tzlock.c tzset.c tzset_r.c
|
||||||
|
|
||||||
|
|
||||||
libtime_la_LDFLAGS = -Xcompiler -nostdlib
|
libtime_la_LDFLAGS = -Xcompiler -nostdlib
|
||||||
@ -144,19 +144,20 @@ lib_a_LIBADD =
|
|||||||
@USE_LIBTOOL_FALSE@lib_a_OBJECTS = asctime.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@lib_a_OBJECTS = asctime.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@asctime_r.$(OBJEXT) clock.$(OBJEXT) ctime.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@asctime_r.$(OBJEXT) clock.$(OBJEXT) ctime.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@ctime_r.$(OBJEXT) difftime.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@ctime_r.$(OBJEXT) difftime.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@gmtime.$(OBJEXT) gmtime_r.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@gettzinfo.$(OBJEXT) gmtime.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@lcltime.$(OBJEXT) lcltime_r.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@gmtime_r.$(OBJEXT) lcltime.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@mktime.$(OBJEXT) mktm_r.$(OBJEXT) strftime.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@lcltime_r.$(OBJEXT) mktime.$(OBJEXT) \
|
||||||
|
@USE_LIBTOOL_FALSE@mktm_r.$(OBJEXT) strftime.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@strptime.$(OBJEXT) time.$(OBJEXT) tzlock.$(OBJEXT) \
|
@USE_LIBTOOL_FALSE@strptime.$(OBJEXT) time.$(OBJEXT) tzlock.$(OBJEXT) \
|
||||||
@USE_LIBTOOL_FALSE@tzset.$(OBJEXT) tzset_r.$(OBJEXT)
|
@USE_LIBTOOL_FALSE@tzset.$(OBJEXT) tzset_r.$(OBJEXT)
|
||||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||||
|
|
||||||
libtime_la_LIBADD =
|
libtime_la_LIBADD =
|
||||||
@USE_LIBTOOL_TRUE@libtime_la_OBJECTS = asctime.lo asctime_r.lo clock.lo \
|
@USE_LIBTOOL_TRUE@libtime_la_OBJECTS = asctime.lo asctime_r.lo clock.lo \
|
||||||
@USE_LIBTOOL_TRUE@ctime.lo ctime_r.lo difftime.lo gmtime.lo gmtime_r.lo \
|
@USE_LIBTOOL_TRUE@ctime.lo ctime_r.lo difftime.lo gettzinfo.lo \
|
||||||
@USE_LIBTOOL_TRUE@lcltime.lo lcltime_r.lo mktime.lo mktm_r.lo \
|
@USE_LIBTOOL_TRUE@gmtime.lo gmtime_r.lo lcltime.lo lcltime_r.lo \
|
||||||
@USE_LIBTOOL_TRUE@strftime.lo strptime.lo time.lo tzlock.lo tzset.lo \
|
@USE_LIBTOOL_TRUE@mktime.lo mktm_r.lo strftime.lo strptime.lo time.lo \
|
||||||
@USE_LIBTOOL_TRUE@tzset_r.lo
|
@USE_LIBTOOL_TRUE@tzlock.lo tzset.lo tzset_r.lo
|
||||||
CFLAGS = @CFLAGS@
|
CFLAGS = @CFLAGS@
|
||||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
|
15
newlib/libc/time/gettzinfo.c
Normal file
15
newlib/libc/time/gettzinfo.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include <sys/types.h>
|
||||||
|
#include <local.h>
|
||||||
|
|
||||||
|
/* Shared timezone information for libc/time functions. */
|
||||||
|
static __tzinfo_type tzinfo = {1, 0,
|
||||||
|
{ {'J', 0, 0, 0, 0, (time_t)0, 0 },
|
||||||
|
{'J', 0, 0, 0, 0, (time_t)0, 0 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
__tzinfo_type *
|
||||||
|
__gettzinfo (void)
|
||||||
|
{
|
||||||
|
return &tzinfo;
|
||||||
|
}
|
@ -19,24 +19,6 @@
|
|||||||
|
|
||||||
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
|
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
|
||||||
|
|
||||||
extern time_t __tzstart_std;
|
|
||||||
extern time_t __tzstart_dst;
|
|
||||||
extern int __tznorth;
|
|
||||||
extern int __tzyear;
|
|
||||||
|
|
||||||
typedef struct __tzrule_struct
|
|
||||||
{
|
|
||||||
char ch;
|
|
||||||
int m;
|
|
||||||
int n;
|
|
||||||
int d;
|
|
||||||
int s;
|
|
||||||
time_t change;
|
|
||||||
int offset;
|
|
||||||
} __tzrule_type;
|
|
||||||
|
|
||||||
extern __tzrule_type __tzrule[2];
|
|
||||||
|
|
||||||
struct tm * _EXFUN (_mktm_r, (_CONST time_t *, struct tm *, int __is_gmtime));
|
struct tm * _EXFUN (_mktm_r, (_CONST time_t *, struct tm *, int __is_gmtime));
|
||||||
int _EXFUN (__tzcalc_limits, (int __year));
|
int _EXFUN (__tzcalc_limits, (int __year));
|
||||||
|
|
||||||
|
@ -158,6 +158,7 @@ mktime (tim_p)
|
|||||||
time_t tim = 0;
|
time_t tim = 0;
|
||||||
long days = 0;
|
long days = 0;
|
||||||
int year, isdst;
|
int year, isdst;
|
||||||
|
__tzinfo_type *tz = __gettzinfo ();
|
||||||
|
|
||||||
/* validate structure */
|
/* validate structure */
|
||||||
validate_structure (tim_p);
|
validate_structure (tim_p);
|
||||||
@ -206,19 +207,19 @@ mktime (tim_p)
|
|||||||
if (_daylight)
|
if (_daylight)
|
||||||
{
|
{
|
||||||
int y = tim_p->tm_year + YEAR_BASE;
|
int y = tim_p->tm_year + YEAR_BASE;
|
||||||
if (y == __tzyear || __tzcalc_limits (y))
|
if (y == tz->__tzyear || __tzcalc_limits (y))
|
||||||
{
|
{
|
||||||
/* calculate start of dst in dst local time and
|
/* calculate start of dst in dst local time and
|
||||||
start of std in both std local time and dst local time */
|
start of std in both std local time and dst local time */
|
||||||
time_t startdst_dst = __tzrule[0].change - __tzrule[1].offset;
|
time_t startdst_dst = tz->__tzrule[0].change - tz->__tzrule[1].offset;
|
||||||
time_t startstd_dst = __tzrule[1].change - __tzrule[1].offset;
|
time_t startstd_dst = tz->__tzrule[1].change - tz->__tzrule[1].offset;
|
||||||
time_t startstd_std = __tzrule[1].change - __tzrule[0].offset;
|
time_t startstd_std = tz->__tzrule[1].change - tz->__tzrule[0].offset;
|
||||||
/* if the time is in the overlap between dst and std local times */
|
/* if the time is in the overlap between dst and std local times */
|
||||||
if (tim >= startstd_std && tim < startstd_dst)
|
if (tim >= startstd_std && tim < startstd_dst)
|
||||||
; /* we let user decide or leave as -1 */
|
; /* we let user decide or leave as -1 */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
isdst = (__tznorth
|
isdst = (tz->__tznorth
|
||||||
? (tim >= startdst_dst && tim < startstd_std)
|
? (tim >= startdst_dst && tim < startstd_std)
|
||||||
: (tim >= startdst_dst || tim < startstd_std));
|
: (tim >= startdst_dst || tim < startstd_std));
|
||||||
/* if user committed and was wrong, perform correction */
|
/* if user committed and was wrong, perform correction */
|
||||||
@ -226,7 +227,7 @@ mktime (tim_p)
|
|||||||
{
|
{
|
||||||
/* we either subtract or add the difference between
|
/* we either subtract or add the difference between
|
||||||
time zone offsets, depending on which way the user got it wrong */
|
time zone offsets, depending on which way the user got it wrong */
|
||||||
int diff = __tzrule[0].offset - __tzrule[1].offset;
|
int diff = tz->__tzrule[0].offset - tz->__tzrule[1].offset;
|
||||||
if (!isdst)
|
if (!isdst)
|
||||||
diff = -diff;
|
diff = -diff;
|
||||||
tim_p->tm_sec += diff;
|
tim_p->tm_sec += diff;
|
||||||
@ -239,9 +240,9 @@ mktime (tim_p)
|
|||||||
|
|
||||||
/* add appropriate offset to put time in gmt format */
|
/* add appropriate offset to put time in gmt format */
|
||||||
if (isdst == 1)
|
if (isdst == 1)
|
||||||
tim += __tzrule[1].offset;
|
tim += tz->__tzrule[1].offset;
|
||||||
else /* otherwise assume std time */
|
else /* otherwise assume std time */
|
||||||
tim += __tzrule[0].offset;
|
tim += tz->__tzrule[0].offset;
|
||||||
|
|
||||||
/* reset isdst flag to what we have calculated */
|
/* reset isdst flag to what we have calculated */
|
||||||
tim_p->tm_isdst = isdst;
|
tim_p->tm_isdst = isdst;
|
||||||
|
@ -32,10 +32,10 @@ _DEFUN (_mktm_r, (tim_p, res, is_gmtime),
|
|||||||
{
|
{
|
||||||
long days, rem;
|
long days, rem;
|
||||||
time_t lcltime;
|
time_t lcltime;
|
||||||
int i;
|
|
||||||
int y;
|
int y;
|
||||||
int yleap;
|
int yleap;
|
||||||
_CONST int *ip;
|
_CONST int *ip;
|
||||||
|
__tzinfo_type *tz = __gettzinfo ();
|
||||||
|
|
||||||
/* base decision about std/dst time on current time */
|
/* base decision about std/dst time on current time */
|
||||||
lcltime = *tim_p;
|
lcltime = *tim_p;
|
||||||
@ -101,17 +101,21 @@ _DEFUN (_mktm_r, (tim_p, res, is_gmtime),
|
|||||||
TZ_LOCK;
|
TZ_LOCK;
|
||||||
if (_daylight)
|
if (_daylight)
|
||||||
{
|
{
|
||||||
if (y == __tzyear || __tzcalc_limits (y))
|
if (y == tz->__tzyear || __tzcalc_limits (y))
|
||||||
res->tm_isdst = (__tznorth
|
res->tm_isdst = (tz->__tznorth
|
||||||
? (*tim_p >= __tzrule[0].change && *tim_p < __tzrule[1].change)
|
? (*tim_p >= tz->__tzrule[0].change
|
||||||
: (*tim_p >= __tzrule[0].change || *tim_p < __tzrule[1].change));
|
&& *tim_p < tz->__tzrule[1].change)
|
||||||
|
: (*tim_p >= tz->__tzrule[0].change
|
||||||
|
|| *tim_p < tz->__tzrule[1].change));
|
||||||
else
|
else
|
||||||
res->tm_isdst = -1;
|
res->tm_isdst = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
res->tm_isdst = 0;
|
res->tm_isdst = 0;
|
||||||
|
|
||||||
offset = (res->tm_isdst == 1 ? __tzrule[1].offset : __tzrule[0].offset);
|
offset = (res->tm_isdst == 1
|
||||||
|
? tz->__tzrule[1].offset
|
||||||
|
: tz->__tzrule[0].offset);
|
||||||
|
|
||||||
hours = offset / SECSPERHOUR;
|
hours = offset / SECSPERHOUR;
|
||||||
offset = offset % SECSPERHOUR;
|
offset = offset % SECSPERHOUR;
|
||||||
@ -197,11 +201,12 @@ _DEFUN (__tzcalc_limits, (year),
|
|||||||
{
|
{
|
||||||
int days, year_days, years;
|
int days, year_days, years;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
__tzinfo_type *tz = __gettzinfo ();
|
||||||
|
|
||||||
if (year < EPOCH_YEAR)
|
if (year < EPOCH_YEAR)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
__tzyear = year;
|
tz->__tzyear = year;
|
||||||
|
|
||||||
years = (year - EPOCH_YEAR);
|
years = (year - EPOCH_YEAR);
|
||||||
|
|
||||||
@ -211,10 +216,11 @@ _DEFUN (__tzcalc_limits, (year),
|
|||||||
|
|
||||||
for (i = 0; i < 2; ++i)
|
for (i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
if (__tzrule[i].ch == 'J')
|
if (tz->__tzrule[i].ch == 'J')
|
||||||
days = year_days + __tzrule[i].d + (isleap(year) && __tzrule[i].d >= 60);
|
days = year_days + tz->__tzrule[i].d +
|
||||||
else if (__tzrule[i].ch == 'D')
|
(isleap(year) && tz->__tzrule[i].d >= 60);
|
||||||
days = year_days + __tzrule[i].d;
|
else if (tz->__tzrule[i].ch == 'D')
|
||||||
|
days = year_days + tz->__tzrule[i].d;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int yleap = isleap(year);
|
int yleap = isleap(year);
|
||||||
@ -223,15 +229,15 @@ _DEFUN (__tzcalc_limits, (year),
|
|||||||
|
|
||||||
days = year_days;
|
days = year_days;
|
||||||
|
|
||||||
for (j = 1; j < __tzrule[i].m; ++j)
|
for (j = 1; j < tz->__tzrule[i].m; ++j)
|
||||||
days += ip[j-1];
|
days += ip[j-1];
|
||||||
|
|
||||||
m_wday = (EPOCH_WDAY + days) % DAYSPERWEEK;
|
m_wday = (EPOCH_WDAY + days) % DAYSPERWEEK;
|
||||||
|
|
||||||
wday_diff = __tzrule[i].d - m_wday;
|
wday_diff = tz->__tzrule[i].d - m_wday;
|
||||||
if (wday_diff < 0)
|
if (wday_diff < 0)
|
||||||
wday_diff += DAYSPERWEEK;
|
wday_diff += DAYSPERWEEK;
|
||||||
m_day = (__tzrule[i].n - 1) * DAYSPERWEEK + wday_diff;
|
m_day = (tz->__tzrule[i].n - 1) * DAYSPERWEEK + wday_diff;
|
||||||
|
|
||||||
while (m_day >= ip[j-1])
|
while (m_day >= ip[j-1])
|
||||||
m_day -= DAYSPERWEEK;
|
m_day -= DAYSPERWEEK;
|
||||||
@ -240,10 +246,11 @@ _DEFUN (__tzcalc_limits, (year),
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* store the change-over time in GMT form by adding offset */
|
/* store the change-over time in GMT form by adding offset */
|
||||||
__tzrule[i].change = days * SECSPERDAY + __tzrule[i].s + __tzrule[i].offset;
|
tz->__tzrule[i].change = days * SECSPERDAY +
|
||||||
|
tz->__tzrule[i].s + tz->__tzrule[i].offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
__tznorth = (__tzrule[0].change < __tzrule[1].change);
|
tz->__tznorth = (tz->__tzrule[0].change < tz->__tzrule[1].change);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -757,11 +757,12 @@ _DEFUN (strftime, (s, maxsize, format, tim_p),
|
|||||||
if (count < maxsize - 5)
|
if (count < maxsize - 5)
|
||||||
{
|
{
|
||||||
int offset;
|
int offset;
|
||||||
|
__tzinfo_type *tz = __gettzinfo ();
|
||||||
TZ_LOCK;
|
TZ_LOCK;
|
||||||
/* The sign of this is exactly opposite the envvar TZ. We
|
/* The sign of this is exactly opposite the envvar TZ. We
|
||||||
could directly use the global _timezone for tm_isdst==0,
|
could directly use the global _timezone for tm_isdst==0,
|
||||||
but have to use __tzrule for daylight savings. */
|
but have to use __tzrule for daylight savings. */
|
||||||
offset = -__tzrule[tim_p->tm_isdst > 0].offset;
|
offset = -tz->__tzrule[tim_p->tm_isdst > 0].offset;
|
||||||
TZ_UNLOCK;
|
TZ_UNLOCK;
|
||||||
sprintf (&s[count], "%+03ld%.2d", offset / SECSPERHOUR,
|
sprintf (&s[count], "%+03ld%.2d", offset / SECSPERHOUR,
|
||||||
abs (offset / SECSPERMIN) % 60);
|
abs (offset / SECSPERMIN) % 60);
|
||||||
|
@ -14,14 +14,7 @@ static char *prev_tzenv = NULL;
|
|||||||
/* default to GMT */
|
/* default to GMT */
|
||||||
char *_tzname[2] = {"GMT", "GMT"};
|
char *_tzname[2] = {"GMT", "GMT"};
|
||||||
int _daylight = 0;
|
int _daylight = 0;
|
||||||
time_t _timezone = (time_t)0;
|
long _timezone = 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 } };
|
|
||||||
|
|
||||||
_VOID
|
_VOID
|
||||||
_DEFUN (_tzset_r, (reent_ptr),
|
_DEFUN (_tzset_r, (reent_ptr),
|
||||||
@ -31,11 +24,12 @@ _DEFUN (_tzset_r, (reent_ptr),
|
|||||||
unsigned short hh, mm, ss, m, w, d;
|
unsigned short hh, mm, ss, m, w, d;
|
||||||
int sign, n;
|
int sign, n;
|
||||||
int i, ch;
|
int i, ch;
|
||||||
|
__tzinfo_type *tz = __gettzinfo ();
|
||||||
|
|
||||||
if ((tzenv = _getenv_r (reent_ptr, "TZ")) == NULL)
|
if ((tzenv = _getenv_r (reent_ptr, "TZ")) == NULL)
|
||||||
{
|
{
|
||||||
TZ_LOCK;
|
TZ_LOCK;
|
||||||
_timezone = (time_t)0;
|
_timezone = 0;
|
||||||
_daylight = 0;
|
_daylight = 0;
|
||||||
_tzname[0] = "GMT";
|
_tzname[0] = "GMT";
|
||||||
_tzname[1] = "GMT";
|
_tzname[1] = "GMT";
|
||||||
@ -86,7 +80,7 @@ _DEFUN (_tzset_r, (reent_ptr),
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
__tzrule[0].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh);
|
tz->__tzrule[0].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh);
|
||||||
_tzname[0] = __tzname_std;
|
_tzname[0] = __tzname_std;
|
||||||
tzenv += n;
|
tzenv += n;
|
||||||
|
|
||||||
@ -116,9 +110,9 @@ _DEFUN (_tzset_r, (reent_ptr),
|
|||||||
ss = 0;
|
ss = 0;
|
||||||
|
|
||||||
if (sscanf (tzenv, "%hu%n:%hu%n:%hu%n", &hh, &n, &mm, &n, &ss, &n) <= 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
|
else
|
||||||
__tzrule[1].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh);
|
tz->__tzrule[1].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh);
|
||||||
|
|
||||||
tzenv += n;
|
tzenv += n;
|
||||||
|
|
||||||
@ -136,10 +130,10 @@ _DEFUN (_tzset_r, (reent_ptr),
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
__tzrule[i].ch = 'M';
|
tz->__tzrule[i].ch = 'M';
|
||||||
__tzrule[i].m = m;
|
tz->__tzrule[i].m = m;
|
||||||
__tzrule[i].n = w;
|
tz->__tzrule[i].n = w;
|
||||||
__tzrule[i].d = d;
|
tz->__tzrule[i].d = d;
|
||||||
|
|
||||||
tzenv += n;
|
tzenv += n;
|
||||||
}
|
}
|
||||||
@ -161,23 +155,23 @@ _DEFUN (_tzset_r, (reent_ptr),
|
|||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
__tzrule[0].ch = 'M';
|
tz->__tzrule[0].ch = 'M';
|
||||||
__tzrule[0].m = 4;
|
tz->__tzrule[0].m = 4;
|
||||||
__tzrule[0].n = 1;
|
tz->__tzrule[0].n = 1;
|
||||||
__tzrule[0].d = 0;
|
tz->__tzrule[0].d = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
__tzrule[1].ch = 'M';
|
tz->__tzrule[1].ch = 'M';
|
||||||
__tzrule[1].m = 10;
|
tz->__tzrule[1].m = 10;
|
||||||
__tzrule[1].n = 5;
|
tz->__tzrule[1].n = 5;
|
||||||
__tzrule[1].d = 0;
|
tz->__tzrule[1].d = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
__tzrule[i].ch = ch;
|
tz->__tzrule[i].ch = ch;
|
||||||
__tzrule[i].d = d;
|
tz->__tzrule[i].d = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
tzenv = end;
|
tzenv = end;
|
||||||
@ -192,14 +186,14 @@ _DEFUN (_tzset_r, (reent_ptr),
|
|||||||
if (*tzenv == '/')
|
if (*tzenv == '/')
|
||||||
sscanf (tzenv, "/%hu%n:%hu%n:%hu%n", &hh, &n, &mm, &n, &ss, &n);
|
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;
|
tzenv += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
__tzcalc_limits (__tzyear);
|
__tzcalc_limits (tz->__tzyear);
|
||||||
_timezone = (time_t)(__tzrule[0].offset);
|
_timezone = tz->__tzrule[0].offset;
|
||||||
_daylight = __tzrule[0].offset != __tzrule[1].offset;
|
_daylight = tz->__tzrule[0].offset != tz->__tzrule[1].offset;
|
||||||
|
|
||||||
TZ_UNLOCK;
|
TZ_UNLOCK;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user