diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-30 03:22:23 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-30 03:22:23 +0000 |
commit | caa3c880400e48ff22099f3c003e6ba5290f9b61 (patch) | |
tree | 8ea6753ed959e208591a98766cd517736b05cdc7 | |
parent | adcab6c1bb711ba5f5b53073bdcb571ce28d26a2 (diff) | |
download | ruby-caa3c880400e48ff22099f3c003e6ba5290f9b61.tar.gz |
* time.c (v2w): Normalize a rational value to an integer if possible.
[ruby-core:58070] [Bug #9059] reported by Isaac Schwabacher.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | time.c | 5 |
2 files changed, 10 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Wed Oct 30 12:20:32 2013 Tanaka Akira <akr@fsij.org> + + * time.c (v2w): Normalize a rational value to an integer if possible. + [ruby-core:58070] [Bug #9059] reported by Isaac Schwabacher. + Wed Oct 30 12:08:41 2013 Masaki Matsushita <glass.saga@gmail.com> * array.c (rb_ary_uniq_bang): use rb_ary_modify_check() instead of @@ -320,6 +320,11 @@ v2w_bignum(VALUE v) static inline wideval_t v2w(VALUE v) { + if (RB_TYPE_P(v, T_RATIONAL)) { + if (RRATIONAL(v)->den != LONG2FIX(1)) + return v; + v = RRATIONAL(v)->num; + } #if WIDEVALUE_IS_WIDER if (FIXNUM_P(v)) { return WIDEVAL_WRAP((WIDEVALUE)(SIGNED_WIDEVALUE)(long)v); |