4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-28 03:27:46 +08:00

* libc/time/mktime.c (validate_structure): Account for tm_mon possibly

being given as negative.
	(mktime): Set tm_isdst=0 when !daylight.
This commit is contained in:
Corinna Vinschen 2011-08-19 14:14:18 +00:00
parent aeeaae457b
commit 6648762916
2 changed files with 13 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2011-08-19 Craig Howland <howland@LGSInnovations.com>
* libc/time/mktime.c (validate_structure): Account for tm_mon possibly
being given as negative.
(mktime): Set tm_isdst=0 when !daylight.
2011-08-01 Sebastian Huber <sebastian.huber@embedded-brains.de> 2011-08-01 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libc/include/sys/types.h: XML and RTEMS define * libc/include/sys/types.h: XML and RTEMS define

View File

@ -107,7 +107,7 @@ _DEFUN(validate_structure, (tim_p),
} }
} }
if (tim_p->tm_mon > 11) if (tim_p->tm_mon < 0 || tim_p->tm_mon > 11)
{ {
res = div (tim_p->tm_mon, 12); res = div (tim_p->tm_mon, 12);
tim_p->tm_year += res.quot; tim_p->tm_year += res.quot;
@ -159,7 +159,7 @@ _DEFUN(mktime, (tim_p),
{ {
time_t tim = 0; time_t tim = 0;
long days = 0; long days = 0;
int year, isdst, tm_isdst; int year, isdst=0;
__tzinfo_type *tz = __gettzinfo (); __tzinfo_type *tz = __gettzinfo ();
/* validate structure */ /* validate structure */
@ -204,15 +204,16 @@ _DEFUN(mktime, (tim_p),
/* compute total seconds */ /* compute total seconds */
tim += (days * _SEC_IN_DAY); tim += (days * _SEC_IN_DAY);
/* Convert user positive into 1 */
tm_isdst = tim_p->tm_isdst > 0 ? 1 : tim_p->tm_isdst;
isdst = tm_isdst;
TZ_LOCK; TZ_LOCK;
if (_daylight) if (_daylight)
{ {
int tm_isdst;
int y = tim_p->tm_year + YEAR_BASE; int y = tim_p->tm_year + YEAR_BASE;
/* Convert user positive into 1 */
tm_isdst = tim_p->tm_isdst > 0 ? 1 : tim_p->tm_isdst;
isdst = tm_isdst;
if (y == tz->__tzyear || __tzcalc_limits (y)) if (y == tz->__tzyear || __tzcalc_limits (y))
{ {
/* calculate start of dst in dst local time and /* calculate start of dst in dst local time and