delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-0.7 required=5.0 tests=AWL,BAYES_00,SPF_NEUTRAL,T_RP_MATCHES_RCVD |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <4CCC5B87.5070802@cornell.edu> |
Date: | Sat, 30 Oct 2010 13:53:11 -0400 |
From: | Ken Brown <kbrown AT cornell DOT edu> |
User-Agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.11) Gecko/20101013 Thunderbird/3.1.5 |
MIME-Version: | 1.0 |
To: | cygwin AT cygwin DOT com |
Subject: | Re: localtime and TZ |
References: | <4CCB4025 DOT 6070405 AT cornell DOT edu> <4CCB42AF DOT 2090907 AT redhat DOT com> <4CCB439B DOT 7060602 AT redhat DOT com> <4CCB4676 DOT 8080609 AT cornell DOT edu> <4CCB47A6 DOT 9010600 AT redhat DOT com> <4CCB561D DOT 5070304 AT cornell DOT edu> <4CCC12E7 DOT 5060807 AT cornell DOT edu> <4CCC1690 DOT 2030000 AT cornell DOT edu> |
In-Reply-To: | <4CCC1690.2030000@cornell.edu> |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
--------------050304090203060307060309 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 10/30/2010 8:58 AM, Ken Brown wrote: >> I've looked at Cygwin's localtime.cc, and the behavior I'm complaining >> about is caused by the following code at the beginning of tzset: >> >> const char * name = getenv("TZ"); >> >> if (name == NULL) { >> if (!lcl_is_set) >> tzsetwall(); >> goto out; >> } >> >> So getting rid of 'if (!lcl_is_set)' would solve the problem. But this >> would be inefficient, because it would mean that tzsetwall gets called >> every time tzset is called if TZ is never set. To get around that, one >> could have tzsetwall set TZ. >> >> It seems that tzset and tzsetwall used to behave the way I'm proposing >> before the following two changes were made: >> >> 2007-12-11 Corinna Vinschen<corinna AT vinschen DOT de> >> >> * localtime.cc (tzset): Call tzsetwall only if it hasn't been >> called before. >> >> 2007-08-01 Corinna Vinschen<corinna AT vinschen DOT de> >> >> * localtime.cc (tzsetwall): Don't set TZ. > > I've just found the reason for the 2007-08-01 change: > > http://www.cygwin.com/ml/cygwin/2007-08/msg00041.html > > So I don't know what should be done. How's the attached patch? I'm not set up to build cygwin1.dll, so I can't test it right now. I hope the intent is clear in case I got something wrong. Ken --------------050304090203060307060309 Content-Type: text/plain; name="tzset.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="tzset.patch" --- localtime.cc.orig 2009-06-14 05:35:35.000000000 -0400 +++ localtime.cc 2010-10-30 13:28:36.421875000 -0400 @@ -597,6 +597,7 @@ static char lcl_TZname[TZ_STRLEN_MAX + 1]; static int lcl_is_set; static int gmt_is_set; +static int TZ_is_set; #define tzname _tzname #undef _tzname @@ -1479,11 +1480,14 @@ const char * name = getenv("TZ"); if (name == NULL) { - if (!lcl_is_set) + if (!lcl_is_set || TZ_is_set) { + TZ_is_set = 0; tzsetwall(); + } goto out; } + TZ_is_set = 1; if (lcl_is_set > 0 && strcmp(lcl_TZname, name) == 0) goto out; lcl_is_set = (strlen(name) < sizeof (lcl_TZname)); --------------050304090203060307060309 Content-Type: text/plain; charset=us-ascii -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple --------------050304090203060307060309--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |