Skip to content
Browse files

* 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
  • Loading branch information...
1 parent 752027c commit 4a9bca2496f66b44b9fff0377443715a03c6ddc7 @akr akr committed Aug 29, 2009
Showing with 10 additions and 11 deletions.
  1. +4 −0 ChangeLog
  2. +6 −11 time.c
View
4 ChangeLog
@@ -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>
* ext/zlib/zlib.c (gzfile_read_all): use gzfile_newstr;
View
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.
#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 @@ init_leap_second_info()
* 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 @@ init_leap_second_info()
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 @@ timelocalv(struct vtm *vtm)
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)
{

0 comments on commit 4a9bca2

Please sign in to comment.
Something went wrong with that request. Please try again.