ruby-changes:12964
From: akr <ko1@a...>
Date: Sun, 30 Aug 2009 03:19:04 +0900 (JST)
Subject: [ruby-changes:12964] Ruby:r24706 (trunk): * time.c (init_leap_second_info): use TIMET_MAX.
akr 2009-08-30 03:18:37 +0900 (Sun, 30 Aug 2009) New Revision: 24706 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24706 Log: * time.c (init_leap_second_info): use TIMET_MAX. Modified files: trunk/ChangeLog trunk/time.c Index: time.c =================================================================== --- time.c (revision 24705) +++ time.c (revision 24706) @@ -45,6 +45,9 @@ # error cannot find integer type which size is same as time_t. #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; static VALUE time_utc_offset _((VALUE)); @@ -515,7 +518,7 @@ * So no one knows leap seconds in the future after the next year. */ if (this_year == 0) { - time_t now, max; + time_t now; struct tm *tm, result; struct vtm vtm; VALUE timev; @@ -525,13 +528,8 @@ if (!tm) return; this_year = tm->tm_year; - max = ~(time_t)0; - if (max <= (time_t)0) { - /* time_t is signed */ - max = (~(unsigned_time_t)0) >> 1; - } - if (max - now < (time_t)(366*86400)) - known_leap_seconds_limit = max; + if (TIMET_MAX - now < (time_t)(366*86400)) + known_leap_seconds_limit = TIMET_MAX; else known_leap_seconds_limit = now + (time_t)(366*86400); @@ -879,9 +877,6 @@ 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 * localtime_with_gmtoff(const time_t *t, struct tm *result, long *gmtoff) { Index: ChangeLog =================================================================== --- ChangeLog (revision 24705) +++ ChangeLog (revision 24706) @@ -1,3 +1,7 @@ +Sun Aug 30 03:17:25 2009 Tanaka Akira <akr@f...> + + * time.c (init_leap_second_info): use TIMET_MAX. + Sun Aug 30 01:15:31 2009 NARUSE, Yui <naruse@r...> * ext/zlib/zlib.c (gzfile_read_all): use gzfile_newstr; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/