This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: mktime()


Steve:
     I agree that the month test should include a <0 check to be
consistent with the other tests.
     tm_isdst should indeed be set to 0 when there is no DST and it is
passed as -1.  (The code produces the correct time result in this case,
failing only to change tm_isdst appropriately.)
     I have attached a patch which addresses both of these problems.
     This also raises an interesting question about what to do with no
DST (e.g. with GMT) but the user passes tm_isdst>=1.  It could be
considered to be illegal input.  Neither the C standard nor POSIX
comment
on this case.  The patch as it is chooses to ignore the given tm_isdst
when the current timezone has no DST.
				Craig
 
2011-08-17  Craig Howland <howland@LGSInnovations.com>

	* libc/time/mktime.c:  set tm_isdst=0 when !daylight; account
for
	tm_mon possibly being given as negative.


-----Original Message-----
From: newlib-owner@sourceware.org [mailto:newlib-owner@sourceware.org]
On Behalf Of Steven Abner
Sent: Saturday, August 13, 2011 6:36 AM
To: newlib@sourceware.org
Subject: mktime()

Good day,
  Running some tests and found an omission?
In the mktime.c file, the function "validate_structure", it appears (to
me) that the month test
might be incomplete?
 "if (tim_p->tm_mon > 11)"
should it possibly be:
"if (tim_p->tm_mon > 11 || tim_p->tm_mon < 0)"

And this probably should be second thread?? but I tried using the
environment variable
"TZ=GMT0" and I get tm_isdst = -1 when passing -1 in. Not sure, in this
case, if user
should be setting to 0?.  It could also be that I screwed up on porting
newlib code for testing
purposes?

Cheers
Steve

Attachment: mktime.patch.txt
Description: mktime.patch.txt


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