* time.c (rb_localtime_r2): refine localtime overflow check for
FreeBSD 6.4. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ebda24ccd8
commit
094ca0281e
@ -1,3 +1,8 @@
|
|||||||
|
Thu Jun 10 23:05:44 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* time.c (rb_localtime_r2): refine localtime overflow check for
|
||||||
|
FreeBSD 6.4.
|
||||||
|
|
||||||
Thu Jun 10 09:10:08 2010 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Thu Jun 10 09:10:08 2010 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* io.c (rb_io_putc): documentation updated to mention putc would
|
* io.c (rb_io_putc): documentation updated to mention putc would
|
||||||
|
@ -153,8 +153,10 @@ class TestTimeTZ < Test::Unit::TestCase
|
|||||||
sample.each {|tz, u, l, gmtoff|
|
sample.each {|tz, u, l, gmtoff|
|
||||||
with_tz(tz) {
|
with_tz(tz) {
|
||||||
expected = "%04d-%02d-%02d %02d:%02d:%02d %s" % (l+[format_gmtoff(gmtoff)])
|
expected = "%04d-%02d-%02d %02d:%02d:%02d %s" % (l+[format_gmtoff(gmtoff)])
|
||||||
t = Time.utc(*u).localtime
|
mesg = "TZ=#{tz} Time.utc(#{u.map(&:inspect).join(', ')}).localtime"
|
||||||
assert_equal(expected, time_to_s(t), "TZ=#{tz} Time.utc(#{u.map(&:inspect).join(', ')}).localtime")
|
t = nil
|
||||||
|
assert_nothing_raised(mesg) { t = Time.utc(*u).localtime }
|
||||||
|
assert_equal(expected, time_to_s(t), mesg)
|
||||||
assert_equal(gmtoff, t.gmtoff)
|
assert_equal(gmtoff, t.gmtoff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
time.c
10
time.c
@ -870,8 +870,16 @@ rb_localtime_r2(const time_t *t, struct tm *result)
|
|||||||
result = rb_localtime_r(t, result);
|
result = rb_localtime_r(t, result);
|
||||||
#if defined(HAVE_MKTIME) && defined(LOCALTIME_OVERFLOW_PROBLEM)
|
#if defined(HAVE_MKTIME) && defined(LOCALTIME_OVERFLOW_PROBLEM)
|
||||||
if (result) {
|
if (result) {
|
||||||
|
int gmtoff1 = 0;
|
||||||
|
int gmtoff2 = 0;
|
||||||
|
# if defined(HAVE_STRUCT_TM_TM_GMTOFF)
|
||||||
|
gmtoff1 = result->tm_gmtoff;
|
||||||
|
# endif
|
||||||
time_t t2 = mktime(result);
|
time_t t2 = mktime(result);
|
||||||
if (*t != t2)
|
# if defined(HAVE_STRUCT_TM_TM_GMTOFF)
|
||||||
|
gmtoff2 = result->tm_gmtoff;
|
||||||
|
# endif
|
||||||
|
if (*t + gmtoff1 != t2 + gmtoff2)
|
||||||
result = NULL;
|
result = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user