diff options
author | Daniel Stenberg <daniel@haxx.se> | 2008-10-09 21:57:51 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2008-10-09 21:57:51 +0000 |
commit | ba9963b8fa22707dbf49e4fa253208467b2cb732 (patch) | |
tree | af71645abdd0d3fee57b1dbd8a3b862e1870f880 | |
parent | 6887106ff7e9be173f7cabe15da96a60194e1931 (diff) |
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.
-rw-r--r-- | lib/parsedate.c | 18 |
1 files changed, 13 insertions, 5 deletions
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'. |