[前][次][番号順一覧][スレッド一覧]

ruby-changes:31394

From: akr <ko1@a...>
Date: Wed, 30 Oct 2013 12:22:26 +0900 (JST)
Subject: [ruby-changes:31394] akr:r43473 (trunk): * time.c (v2w): Normalize a rational value to an integer if possible.

akr	2013-10-30 12:22:23 +0900 (Wed, 30 Oct 2013)

  New Revision: 43473

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43473

  Log:
    * time.c (v2w): Normalize a rational value to an integer if possible.
      [ruby-core:58070] [Bug #9059] reported by Isaac Schwabacher.

  Modified files:
    trunk/ChangeLog
    trunk/time.c
Index: time.c
===================================================================
--- time.c	(revision 43472)
+++ time.c	(revision 43473)
@@ -320,6 +320,11 @@ v2w_bignum(VALUE v) https://github.com/ruby/ruby/blob/trunk/time.c#L320
 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);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43472)
+++ ChangeLog	(revision 43473)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Oct 30 12:20:32 2013  Tanaka Akira  <akr@f...>
+
+	* 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@g...>
 
 	* array.c (rb_ary_uniq_bang): use rb_ary_modify_check() instead of

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]