From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 34629383F87F; Mon, 4 May 2020 09:20:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34629383F87F Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] localtime 1.73 X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: f2e06d8af5f390d81b64375a69ca834ca19d6029 X-Git-Newrev: 76d4d40b8b23d046473a5946cf6b83faa36ae7be Message-Id: <20200504092026.34629383F87F@sourceware.org> Date: Mon, 4 May 2020 09:20:26 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2020 09:20:26 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=76d4d40b8b23d046473a5946cf6b83faa36ae7be commit 76d4d40b8b23d046473a5946cf6b83faa36ae7be Author: Corinna Vinschen Date: Mon Apr 27 11:21:00 2020 +0200 localtime 1.73 Diff: --- winsup/cygwin/localtime.cc | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/winsup/cygwin/localtime.cc b/winsup/cygwin/localtime.cc index 40054e332..da446f101 100644 --- a/winsup/cygwin/localtime.cc +++ b/winsup/cygwin/localtime.cc @@ -1,4 +1,4 @@ -/* $NetBSD: localtime.c,v 1.72 2012/10/28 19:02:29 christos Exp $ */ +/* $NetBSD: localtime.c,v 1.73 2013/03/02 21:24:28 christos Exp $ */ /* ** This file is in the public domain, so clarified as of @@ -607,8 +607,7 @@ settzname (void) for (i = 0; i < sp->typecnt; ++i) { const struct ttinfo * const ttisp = &sp->ttis[i]; - tzname[ttisp->tt_isdst] = - &sp->chars[ttisp->tt_abbrind]; + tzname[ttisp->tt_isdst] = &sp->chars[ttisp->tt_abbrind]; #ifdef USG_COMPAT if (ttisp->tt_isdst) daylight = 1; @@ -816,20 +815,31 @@ tzload(timezone_t sp, const char *name, const int doextend) ** signed time_t system but using a data file with ** unsigned values (or vice versa). */ - for (i = 0; i < sp->timecnt - 2; ++i) - if (sp->ats[i] > sp->ats[i + 1]) { - ++i; + for (i = 0; i < sp->timecnt; ++i) + if ((i < sp->timecnt - 1 && + sp->ats[i] > sp->ats[i + 1]) || + (i == sp->timecnt - 1 && !TYPE_SIGNED(time_t) && + sp->ats[i] > + ((stored == 4) ? INT32_MAX : INT64_MAX))) { if (TYPE_SIGNED(time_t)) { /* ** Ignore the end (easy). */ - sp->timecnt = i; + sp->timecnt = i + 1; } else { /* ** Ignore the beginning (harder). */ int j; + /* + ** Keep the record right before the + ** epoch boundary, + ** but tweak it so that it starts + ** right with the epoch + ** (thanks to Doug Bailey). + */ + sp->ats[i] = 0; for (j = 0; j + i < sp->timecnt; ++j) { sp->ats[j] = sp->ats[j + i]; sp->types[j] = sp->types[j + i];