This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Fix getdate (was Re: problem with getdate)


On Tue, Jul 17, 2001 at 10:40:17AM +0200, Andreas Jaeger wrote:
> As Hendrik reported, we seem to have a bug in getdate.  Calling
> getdate twice gives different results for the value of tm_hour:
...
> The change from 5 to 6 in tm_hour occurs in the mktime call in getdate_r.
> 
> I'm appending the test files.  Has anybody an idea what's broken?

getdate does not initialize the whole struct tm but mktime uses it.
Should be fixed by:

2001-07-17  Jakub Jelinek  <jakub@redhat.com>

	* time/getdate.c (__getdate_r): Initialize tm_isdst, tm_gmtoff and
	tm_zone before calling strptime.

--- libc/time/getdate.c.jj	Fri Sep  1 11:38:27 2000
+++ libc/time/getdate.c	Tue Jul 17 11:20:01 2001
@@ -147,6 +147,9 @@ __getdate_r (const char *string, struct 
       /* Do the conversion.  */
       tp->tm_year = tp->tm_mon = tp->tm_mday = tp->tm_wday = INT_MIN;
       tp->tm_hour = tp->tm_sec = tp->tm_min = INT_MIN;
+      tp->tm_isdst = 0;
+      tp->tm_gmtoff = 0;
+      tp->tm_zone = NULL;
       result = strptime (string, line, tp);
       if (result && *result == '\0')
 	break;


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]