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

ruby-changes:14591

From: mame <ko1@a...>
Date: Wed, 27 Jan 2010 00:25:24 +0900 (JST)
Subject: [ruby-changes:14591] Ruby:r26434 (trunk): * ext/bigdecimal/bigdecimal.c (BigDecimal_DoDivmod, BigDecimal_mod,

mame	2010-01-27 00:25:04 +0900 (Wed, 27 Jan 2010)

  New Revision: 26434

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

  Log:
    * ext/bigdecimal/bigdecimal.c (BigDecimal_DoDivmod, BigDecimal_mod,
      BigDecimal_divmod, BigDecimal_div2): BigDecimal#% and #div returned
      an array itself that was returned by #divmod.

  Modified files:
    trunk/ChangeLog
    trunk/ext/bigdecimal/bigdecimal.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26433)
+++ ChangeLog	(revision 26434)
@@ -1,3 +1,9 @@
+Wed Jan 27 00:22:20 2010  Yusuke Endoh  <mame@t...>
+
+	* ext/bigdecimal/bigdecimal.c (BigDecimal_DoDivmod, BigDecimal_mod,
+	  BigDecimal_divmod, BigDecimal_div2): BigDecimal#% and #div returned
+	  an array itself that was returned by #divmod.
+
 Wed Jan 27 00:19:30 2010  Yusuke Endoh  <mame@t...>
 
 	* ext/bigdecimal/bigdecimal.c (VpCtoV): do not raise infinity
Index: ext/bigdecimal/bigdecimal.c
===================================================================
--- ext/bigdecimal/bigdecimal.c	(revision 26433)
+++ ext/bigdecimal/bigdecimal.c	(revision 26434)
@@ -947,7 +947,7 @@
 
     GUARD_OBJ(a,GetVpValue(self,1));
     b = GetVpValue(r,0);
-    if(!b) return DoSomeOne(self,r,rb_intern("divmod"));
+    if(!b) return Qfalse;
     SAVE(b);
 
     if(VpIsNaN(a) || VpIsNaN(b)) goto NaN;
@@ -960,7 +960,7 @@
        GUARD_OBJ(d,VpCreateRbObject(1, "0"));
        *div = d;
        *mod = c;
-       return (VALUE)0;
+       return Qtrue;
     }
 
     mx = a->Prec;
@@ -983,14 +983,14 @@
         *div = d;
         *mod = c;
     }
-    return (VALUE)0;
+    return Qtrue;
 
 NaN:
     GUARD_OBJ(c,VpCreateRbObject(1, "NaN"));
     GUARD_OBJ(d,VpCreateRbObject(1, "NaN"));
     *div = d;
     *mod = c;
-    return (VALUE)0;
+    return Qtrue;
 }
 
 /* call-seq:
@@ -1006,10 +1006,11 @@
     VALUE obj;
     Real *div=NULL, *mod=NULL;
 
-    obj = BigDecimal_DoDivmod(self,r,&div,&mod);
-    if(obj!=(VALUE)0) return obj;
-    SAVE(div);SAVE(mod);
-    return ToValue(mod);
+    if(BigDecimal_DoDivmod(self,r,&div,&mod)) {
+	SAVE(div); SAVE(mod);
+	return ToValue(mod);
+    }
+    return DoSomeOne(self,r,'%');
 }
 
 static VALUE
@@ -1089,11 +1090,11 @@
     VALUE obj;
     Real *div=NULL, *mod=NULL;
 
-    obj = BigDecimal_DoDivmod(self,r,&div,&mod);
-    if(obj!=(VALUE)0) return obj;
-    SAVE(div);SAVE(mod);
-    obj = rb_assoc_new(BigDecimal_to_i(ToValue(div)), ToValue(mod));
-    return obj;
+    if(BigDecimal_DoDivmod(self,r,&div,&mod)) {
+	SAVE(div); SAVE(mod);
+	return rb_assoc_new(ToValue(div), ToValue(mod));
+    }
+    return DoSomeOne(self,r,rb_intern("divmod"));
 }
 
 static VALUE
@@ -1106,9 +1107,10 @@
        VALUE obj;
        Real *div=NULL;
        Real *mod;
-       obj = BigDecimal_DoDivmod(self,b,&div,&mod);
-       if(obj!=(VALUE)0) return obj;
-       return BigDecimal_to_i(ToValue(div));
+       if(BigDecimal_DoDivmod(self,b,&div,&mod)) {
+	  return BigDecimal_to_i(ToValue(div));
+       }
+       return DoSomeOne(self,b,rb_intern("div"));
     } else {    /* div in BigDecimal sense */
        U_LONG ix = (U_LONG)GetPositiveInt(n);
        if(ix==0) return BigDecimal_div(self,b);

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

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