From ba9963b8fa22707dbf49e4fa253208467b2cb732 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 9 Oct 2008 21:57:51 +0000 Subject: I replaced the use of 'struct tm' with a private clone of that struct simply because the struct is declared on the stack and not all members are used so we could just as well make struct with only struct members we actually need. --- lib/parsedate.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/parsedate.c b/lib/parsedate.c index d30286ef5..fc6f9216f 100644 --- a/lib/parsedate.c +++ b/lib/parsedate.c @@ -222,12 +222,23 @@ enum assume { DATE_TIME }; +/* this is a clone of 'struct tm' but with all fields we don't need or use + cut out */ +struct my_tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; +}; + /* struct tm to time since epoch in GMT time zone. * This is similar to the standard mktime function but for GMT only, and * doesn't suffer from the various bugs and portability problems that * some systems' implementations have. */ -static time_t my_timegm(struct tm * tm) +static time_t my_timegm(struct my_tm *tm) { static const int month_days_cumulative [12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; @@ -269,7 +280,7 @@ static time_t parsedate(const char *date) int secnum=-1; int yearnum=-1; int tzoff=-1; - struct tm tm; + struct my_tm tm; enum assume dignext = DATE_MDAY; const char *indate = date; /* save the original pointer */ int part = 0; /* max 6 parts */ @@ -407,9 +418,6 @@ static time_t parsedate(const char *date) tm.tm_mday = mdaynum; tm.tm_mon = monnum; tm.tm_year = yearnum - 1900; - tm.tm_wday = 0; - tm.tm_yday = 0; - tm.tm_isdst = 0; /* my_timegm() returns a time_t. time_t is often 32 bits, even on many architectures that feature 64 bit 'long'. -- cgit v1.2.1