From 75a56e3c3ad93e5bdf5a8223b5d5214a260753ce Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Tue, 26 Oct 2010 15:20:01 +0200 Subject: [PATCH] libc/stdtime: Sync localtime.c with tzcode2010n from elsie.nci.nih.gov * Change to set timezone and altzone based on time types with greatest transition times (for the benefit of Asia/Seoul). * Initialize ttinfo structures filled by tzparse (thanks to Ravindra for reporting a valgrind warning). --- lib/libc/stdtime/localtime.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c index ed2a7286a2..156520d33c 100644 --- a/lib/libc/stdtime/localtime.c +++ b/lib/libc/stdtime/localtime.c @@ -2,7 +2,7 @@ ** This file is in the public domain, so clarified as of ** 1996-06-05 by Arthur David Olson. ** -** @(#)localtime.c 8.13 +** @(#)localtime.c 8.15 ** $FreeBSD: src/lib/libc/stdtime/localtime.c,v 1.25.2.2 2002/08/13 16:08:07 bmilekic Exp $ */ @@ -263,16 +263,6 @@ settzname(void) daylight = 0; timezone = 0; - for (i = 0; i < sp->typecnt; ++i) { - const struct ttinfo * const ttisp = &sp->ttis[i]; - - tzname[ttisp->tt_isdst] = - &sp->chars[ttisp->tt_abbrind]; - if (ttisp->tt_isdst) - daylight = 1; - if (i == 0 || !ttisp->tt_isdst) - timezone = -(ttisp->tt_gmtoff); - } /* ** And to get the latest zone names into tzname. . . */ @@ -283,6 +273,10 @@ settzname(void) tzname[ttisp->tt_isdst] = &sp->chars[ttisp->tt_abbrind]; + if (ttisp->tt_isdst) + daylight = 1; + if (!ttisp->tt_isdst) + timezone = -(ttisp->tt_gmtoff); } /* ** Finally, scrub the abbreviations. @@ -888,10 +882,11 @@ tzparse(const char *name, struct state * const sp, const int lastditch) size_t dstlen; long stdoffset; long dstoffset; - time_t * atp; - unsigned char * typep; - char * cp; - int load_result; + time_t * atp; + unsigned char * typep; + char * cp; + int load_result; + static struct ttinfo zttinfo; INITIALIZE(dstname); stdname = name; @@ -964,6 +959,7 @@ tzparse(const char *name, struct state * const sp, const int lastditch) /* ** Two transitions per year, from EPOCH_YEAR forward. */ + sp->ttis[0] = sp->ttis[1] = zttinfo; sp->ttis[0].tt_gmtoff = -dstoffset; sp->ttis[0].tt_isdst = 1; sp->ttis[0].tt_abbrind = stdlen + 1; @@ -1077,8 +1073,8 @@ tzparse(const char *name, struct state * const sp, const int lastditch) } /* ** Finally, fill in ttis. - ** ttisstd and ttisgmt need not be handled. */ + sp->ttis[0] = sp->ttis[1] = zttinfo; sp->ttis[0].tt_gmtoff = -stdoffset; sp->ttis[0].tt_isdst = FALSE; sp->ttis[0].tt_abbrind = 0; @@ -1091,6 +1087,7 @@ tzparse(const char *name, struct state * const sp, const int lastditch) dstlen = 0; sp->typecnt = 1; /* only standard time */ sp->timecnt = 0; + sp->ttis[0] = zttinfo; sp->ttis[0].tt_gmtoff = -stdoffset; sp->ttis[0].tt_isdst = 0; sp->ttis[0].tt_abbrind = 0; -- 2.41.0