diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-10 14:10:25 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-10 14:10:25 +0000 |
commit | 094ca0281e1ddbfcd9d7c36363cea2222885527b (patch) | |
tree | 206cbfd6333775ad68344780be7777bc07177f71 /time.c | |
parent | ebda24ccd876257655305d73a9b2b496b381884a (diff) | |
download | ruby-094ca0281e1ddbfcd9d7c36363cea2222885527b.tar.gz |
* 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
Diffstat (limited to 'time.c')
-rw-r--r-- | time.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -870,9 +870,17 @@ rb_localtime_r2(const time_t *t, struct tm *result) result = rb_localtime_r(t, result); #if defined(HAVE_MKTIME) && defined(LOCALTIME_OVERFLOW_PROBLEM) if (result) { - time_t t2 = mktime(result); - if (*t != t2) - result = NULL; + int gmtoff1 = 0; + int gmtoff2 = 0; +# if defined(HAVE_STRUCT_TM_TM_GMTOFF) + gmtoff1 = result->tm_gmtoff; +# endif + time_t t2 = mktime(result); +# if defined(HAVE_STRUCT_TM_TM_GMTOFF) + gmtoff2 = result->tm_gmtoff; +# endif + if (*t + gmtoff1 != t2 + gmtoff2) + result = NULL; } #endif return result; |