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

ruby-changes:43364

From: nobu <ko1@a...>
Date: Sat, 18 Jun 2016 11:25:32 +0900 (JST)
Subject: [ruby-changes:43364] nobu:r55438 (trunk): Integer conversion

nobu	2016-06-18 11:25:28 +0900 (Sat, 18 Jun 2016)

  New Revision: 55438

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55438

  Log:
    Integer conversion
    
    * ext/bigdecimal/bigdecimal.c: use NUM2INT and NUM2USHORT to
      reject nil.

  Modified files:
    trunk/ext/bigdecimal/bigdecimal.c
Index: ext/bigdecimal/bigdecimal.c
===================================================================
--- ext/bigdecimal/bigdecimal.c	(revision 55437)
+++ ext/bigdecimal/bigdecimal.c	(revision 55438)
@@ -468,7 +468,7 @@ check_rounding_mode(VALUE const v) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L468
 	break;
     }
 
-    sw = (unsigned short)FIX2UINT(v);
+    sw = NUM2USHORT(v);
     if (!VpIsRoundMode(sw)) {
 	rb_raise(rb_eArgError, "invalid rounding mode");
     }
@@ -521,7 +521,7 @@ BigDecimal_mode(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L521
     unsigned long f,fo;
 
     rb_scan_args(argc, argv, "11", &which, &val);
-    f = (unsigned long)FIX2INT(which);
+    f = (unsigned long)NUM2INT(which);
 
     if (f & VP_EXCEPTION_ALL) {
 	/* Exception mode setting */
@@ -591,7 +591,7 @@ static SIGNED_VALUE https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L591
 GetPositiveInt(VALUE v)
 {
     SIGNED_VALUE n;
-    n = FIX2INT(v);
+    n = NUM2INT(v);
     if (n < 0) {
 	rb_raise(rb_eArgError, "argument must be positive");
     }
@@ -1720,10 +1720,10 @@ BigDecimal_round(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1720
 	iLoc = 0;
 	break;
       case 1:
-	iLoc = FIX2INT(vLoc);
+	iLoc = NUM2INT(vLoc);
 	break;
       case 2:
-	iLoc = FIX2INT(vLoc);
+	iLoc = NUM2INT(vLoc);
 	sw = check_rounding_mode(vRound);
 	break;
       default:
@@ -1774,7 +1774,7 @@ BigDecimal_truncate(int argc, VALUE *arg https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1774
 	iLoc = 0;
     }
     else {
-	iLoc = FIX2INT(vLoc);
+	iLoc = NUM2INT(vLoc);
     }
 
     GUARD_OBJ(a, GetVpValue(self, 1));
@@ -1834,7 +1834,7 @@ BigDecimal_floor(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1834
 	iLoc = 0;
     }
     else {
-	iLoc = FIX2INT(vLoc);
+	iLoc = NUM2INT(vLoc);
     }
 
     GUARD_OBJ(a, GetVpValue(self, 1));
@@ -1880,7 +1880,7 @@ BigDecimal_ceil(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1880
     if (rb_scan_args(argc, argv, "01", &vLoc) == 0) {
 	iLoc = 0;
     } else {
-	iLoc = FIX2INT(vLoc);
+	iLoc = NUM2INT(vLoc);
     }
 
     GUARD_OBJ(a, GetVpValue(self, 1));
@@ -2623,7 +2623,7 @@ BigDecimal_limit(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2623
     if (rb_scan_args(argc, argv, "01", &nFig) == 1) {
 	int nf;
 	if (NIL_P(nFig)) return nCur;
-	nf = FIX2INT(nFig);
+	nf = NUM2INT(nFig);
 	if (nf < 0) {
 	    rb_raise(rb_eArgError, "argument must be positive");
 	}
@@ -3458,7 +3458,7 @@ VpGetException (void) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3458
 	return RMPD_EXCEPTION_MODE_DEFAULT;
     }
 
-    return (unsigned short)FIX2UINT(vmode);
+    return NUM2USHORT(vmode);
 }
 
 static void
@@ -3528,7 +3528,7 @@ VpGetRoundMode(void) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3528
 	return RMPD_ROUNDING_MODE_DEFAULT;
     }
 
-    return (unsigned short)FIX2INT(vmode);
+    return NUM2USHORT(vmode);
 }
 
 VP_EXPORT int

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

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