delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/06/24/15:42:40

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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
Message-Id: <200506241942.j5OJgPuQ016437@smtp.hispeed.ch>
From: "Luca Wullschleger" <luca DOT wullschleger AT epfl DOT ch>
To: <brian AT dessent DOT net>, <cygwin AT cygwin DOT com>
Subject: RE: strptime error when setting a different TimeZone with export TZ=UTC
Date: Fri, 24 Jun 2005 21:42:23 +0200
MIME-Version: 1.0
In-reply-to: <42BC60E5.1DA7215B@dessent.net>
X-Virus-Status: Clean
X-DCC-spamcheck-02.tornado.cablecom.ch-Metrics: smtp-05.tornado.cablecom.ch 32701; Body=2 Fuz1=2 Fuz2=2
X-IsSubscribed: yes

Hi Brian, thanks a lot for your answer. In fact it works initializing the
try struct to {0}.

As you said, I was lucky that until now I never found the problem.
Remain the question why setting the TZ variable make this problem coming
out.

By the way, thanks a lot for the support !!!!!!!

Luca 



> -----Original Message-----
> From: cygwin-owner AT cygwin DOT com 
> [mailto:cygwin-owner AT cygwin DOT com] On Behalf Of Brian Dessent
> Sent: vendredi, 24. juin 2005 21:37
> To: cygwin AT cygwin DOT com
> Subject: Re: strptime error when setting a different TimeZone 
> with export TZ=UTC
> 
> Luca Wullschleger wrote:
> 
> > Hi everybody. I have a very specific problem and I'm looking for 
> > someone giving me a solution.
> 
> I'm afriad this is operator error on your part.
> 
> >         struct tm try;
> 
> Here 'try' starts out as a regular automatic variable, with 
> all of its fields set to arbitrary (undefined) values.
> 
> >         if ((char *)strptime(date,"%d/%b/%Y:%T",&try) == NULL) {
> 
> Here you call strptime() to fill in the values of 'try', 
> however the strptime function has the semantics that it will 
> only fill in the members of struct tm that it is asked to 
> parse.  This means that after the call, some of the members 
> still have undefined values. 
> Specifically, the members tm_wday, tm_yday, and tm_isdst will 
> contain garbage.
> 
> >         ts2 = mktime(&try) - atoi(timezone)*3600;
> 
> And here you pass this value of 'try' that still has 
> uninitialized values to mktime(), the result of which will be 
> undefined as well.  I think you were just lucky that it 
> worked in the case where TZ was not set, but in general once 
> you encounter the situation where you pass uninitialized data 
> to a function, all bets are off because your program is invalid C.
> 
> If you change the line above to "struct tm try = { 0 };" or 
> otherwise initialize it somehow, then I think you will get 
> the desired functionality.
> 
> Brian
> 
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Problem reports:       http://cygwin.com/problems.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
> 
> 


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019