* time.c (init_leap_second_info): use TIMET_MAX.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
752027c174
commit
4a9bca2496
@ -1,3 +1,7 @@
|
|||||||
|
Sun Aug 30 03:17:25 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* time.c (init_leap_second_info): use TIMET_MAX.
|
||||||
|
|
||||||
Sun Aug 30 01:15:31 2009 NARUSE, Yui <naruse@ruby-lang.org>
|
Sun Aug 30 01:15:31 2009 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* ext/zlib/zlib.c (gzfile_read_all): use gzfile_newstr;
|
* ext/zlib/zlib.c (gzfile_read_all): use gzfile_newstr;
|
||||||
|
17
time.c
17
time.c
@ -45,6 +45,9 @@ typedef unsigned LONG_LONG unsigned_time_t;
|
|||||||
# error cannot find integer type which size is same as time_t.
|
# error cannot find integer type which size is same as time_t.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TIMET_MAX (~(time_t)0 <= 0 ? (time_t)((~(unsigned_time_t)0) >> 1) : (~(unsigned_time_t)0))
|
||||||
|
#define TIMET_MIN (~(time_t)0 <= 0 ? (time_t)(((unsigned_time_t)1) << (sizeof(time_t) * CHAR_BIT - 1)) : (time_t)0)
|
||||||
|
|
||||||
VALUE rb_cTime;
|
VALUE rb_cTime;
|
||||||
static VALUE time_utc_offset _((VALUE));
|
static VALUE time_utc_offset _((VALUE));
|
||||||
|
|
||||||
@ -515,7 +518,7 @@ init_leap_second_info()
|
|||||||
* So no one knows leap seconds in the future after the next year.
|
* So no one knows leap seconds in the future after the next year.
|
||||||
*/
|
*/
|
||||||
if (this_year == 0) {
|
if (this_year == 0) {
|
||||||
time_t now, max;
|
time_t now;
|
||||||
struct tm *tm, result;
|
struct tm *tm, result;
|
||||||
struct vtm vtm;
|
struct vtm vtm;
|
||||||
VALUE timev;
|
VALUE timev;
|
||||||
@ -525,13 +528,8 @@ init_leap_second_info()
|
|||||||
if (!tm) return;
|
if (!tm) return;
|
||||||
this_year = tm->tm_year;
|
this_year = tm->tm_year;
|
||||||
|
|
||||||
max = ~(time_t)0;
|
if (TIMET_MAX - now < (time_t)(366*86400))
|
||||||
if (max <= (time_t)0) {
|
known_leap_seconds_limit = TIMET_MAX;
|
||||||
/* time_t is signed */
|
|
||||||
max = (~(unsigned_time_t)0) >> 1;
|
|
||||||
}
|
|
||||||
if (max - now < (time_t)(366*86400))
|
|
||||||
known_leap_seconds_limit = max;
|
|
||||||
else
|
else
|
||||||
known_leap_seconds_limit = now + (time_t)(366*86400);
|
known_leap_seconds_limit = now + (time_t)(366*86400);
|
||||||
|
|
||||||
@ -879,9 +877,6 @@ timelocalv(struct vtm *vtm)
|
|||||||
return lt(vtm1.utc_offset, vtm2.utc_offset) ? timev1 : timev2;
|
return lt(vtm1.utc_offset, vtm2.utc_offset) ? timev1 : timev2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TIMET_MAX (~(time_t)0 <= 0 ? (time_t)((~(unsigned_time_t)0) >> 1) : (~(unsigned_time_t)0))
|
|
||||||
#define TIMET_MIN (~(time_t)0 <= 0 ? (time_t)(((unsigned_time_t)1) << (sizeof(time_t) * CHAR_BIT - 1)) : (time_t)0)
|
|
||||||
|
|
||||||
static struct tm *
|
static struct tm *
|
||||||
localtime_with_gmtoff(const time_t *t, struct tm *result, long *gmtoff)
|
localtime_with_gmtoff(const time_t *t, struct tm *result, long *gmtoff)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user