mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* time.c (make_time_t): verify mktime and timegm result.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
727d85c0e3
commit
48af602e38
2 changed files with 17 additions and 16 deletions
|
@ -1,3 +1,7 @@
|
|||
Fri Dec 28 17:33:44 2007 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* time.c (make_time_t): verify mktime and timegm result.
|
||||
|
||||
Fri Dec 28 16:36:33 2007 NARUSE, Yui <naruse@airemix.com>
|
||||
|
||||
* lib/resolv.rb (Resolv::DNS#each_address): now returns IPv6 address.
|
||||
|
|
29
time.c
29
time.c
|
@ -826,40 +826,37 @@ make_time_t(struct tm *tptr, int utc_p)
|
|||
buf = *tptr;
|
||||
if (utc_p) {
|
||||
#if defined(HAVE_TIMEGM)
|
||||
if ((t = timegm(&buf)) != -1)
|
||||
return t;
|
||||
#ifdef NEGATIVE_TIME_T
|
||||
t = timegm(&buf);
|
||||
if (t == (time_t)-1)
|
||||
#endif
|
||||
t = search_time_t(&buf, utc_p);
|
||||
if ((tmp = gmtime(&t)) &&
|
||||
tptr->tm_year == tmp->tm_year &&
|
||||
tptr->tm_mon == tmp->tm_mon &&
|
||||
tptr->tm_mday == tmp->tm_mday &&
|
||||
tptr->tm_hour == tmp->tm_hour &&
|
||||
tptr->tm_min == tmp->tm_min &&
|
||||
tptr->tm_sec == tmp->tm_sec
|
||||
)
|
||||
tptr->tm_sec == tmp->tm_sec) {
|
||||
return t;
|
||||
#endif
|
||||
#endif
|
||||
return search_time_t(&buf, utc_p);
|
||||
}
|
||||
}
|
||||
else {
|
||||
#if defined(HAVE_MKTIME)
|
||||
if ((t = mktime(&buf)) != -1)
|
||||
return t;
|
||||
#ifdef NEGATIVE_TIME_T
|
||||
t = mktime(&buf);
|
||||
if (t == (time_t)-1)
|
||||
#endif
|
||||
t = search_time_t(&buf, utc_p);
|
||||
if ((tmp = localtime(&t)) &&
|
||||
tptr->tm_year == tmp->tm_year &&
|
||||
tptr->tm_mon == tmp->tm_mon &&
|
||||
tptr->tm_mday == tmp->tm_mday &&
|
||||
tptr->tm_hour == tmp->tm_hour &&
|
||||
tptr->tm_min == tmp->tm_min &&
|
||||
tptr->tm_sec == tmp->tm_sec
|
||||
)
|
||||
tptr->tm_sec == tmp->tm_sec) {
|
||||
return t;
|
||||
#endif
|
||||
#endif
|
||||
return search_time_t(&buf, utc_p);
|
||||
}
|
||||
}
|
||||
rb_raise(rb_eArgError, "couldn't generate a time");
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
Loading…
Add table
Reference in a new issue