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

ruby-changes:27820

From: mrkn <ko1@a...>
Date: Fri, 22 Mar 2013 10:39:05 +0900 (JST)
Subject: [ruby-changes:27820] mrkn:r39872 (trunk): * ext/bigdecimal/bigdecimal.c: Fix style.

mrkn	2013-03-22 10:38:55 +0900 (Fri, 22 Mar 2013)

  New Revision: 39872

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

  Log:
    * ext/bigdecimal/bigdecimal.c: Fix style.

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39871)
+++ ChangeLog	(revision 39872)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Mar 22 10:29:00 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/bigdecimal/bigdecimal.c: Fix style.
+
 Fri Mar 22 05:30:49 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (ambiguous_operator): refine warning message, since this
Index: ext/bigdecimal/bigdecimal.c
===================================================================
--- ext/bigdecimal/bigdecimal.c	(revision 39871)
+++ ext/bigdecimal/bigdecimal.c	(revision 39872)
@@ -149,7 +149,7 @@ BigDecimal_memsize(const void *ptr) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L149
 
 static const rb_data_type_t BigDecimal_data_type = {
     "BigDecimal",
-    {0, BigDecimal_delete, BigDecimal_memsize,},
+    { 0, BigDecimal_delete, BigDecimal_memsize, },
 };
 
 static inline int
@@ -161,12 +161,14 @@ is_kind_of_BigDecimal(VALUE const v) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L161
 static VALUE
 ToValue(Real *p)
 {
-    if(VpIsNaN(p)) {
-        VpException(VP_EXCEPTION_NaN,"Computation results to 'NaN'(Not a Number)",0);
-    } else if(VpIsPosInf(p)) {
-        VpException(VP_EXCEPTION_INFINITY,"Computation results to 'Infinity'",0);
-    } else if(VpIsNegInf(p)) {
-        VpException(VP_EXCEPTION_INFINITY,"Computation results to '-Infinity'",0);
+    if (VpIsNaN(p)) {
+        VpException(VP_EXCEPTION_NaN, "Computation results to 'NaN'(Not a Number)", 0);
+    }
+    else if (VpIsPosInf(p)) {
+        VpException(VP_EXCEPTION_INFINITY, "Computation results to 'Infinity'", 0);
+    }
+    else if (VpIsNegInf(p)) {
+        VpException(VP_EXCEPTION_INFINITY, "Computation results to '-Infinity'", 0);
     }
     return p->obj;
 }
@@ -200,11 +202,10 @@ GetVpValueWithPrec(VALUE v, long prec, i https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L202
     VALUE orig = Qundef;
 
 again:
-    switch(TYPE(v))
-    {
+    switch(TYPE(v)) {
       case T_FLOAT:
 	if (prec < 0) goto unable_to_coerce_without_prec;
-	if (prec > DBL_DIG+1)goto SomeOneMayDoIt;
+	if (prec > DBL_DIG+1) goto SomeOneMayDoIt;
 	v = rb_funcall(v, id_to_r, 0);
 	goto again;
       case T_RATIONAL:
@@ -303,7 +304,7 @@ BigDecimal_prec(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L304
     Real *p;
     VALUE obj;
 
-    GUARD_OBJ(p,GetVpValue(self,1));
+    GUARD_OBJ(p, GetVpValue(self, 1));
     obj = rb_assoc_new(INT2NUM(p->Prec*VpBaseFig()),
 		       INT2NUM(p->MaxPrec*VpBaseFig()));
     return obj;
@@ -324,7 +325,7 @@ BigDecimal_hash(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L325
     Real *p;
     st_index_t hash;
 
-    GUARD_OBJ(p,GetVpValue(self,1));
+    GUARD_OBJ(p, GetVpValue(self, 1));
     hash = (st_index_t)p->sign;
     /* hash!=2: the case for 0(1),NaN(0) or +-Infinity(3) is sign itself */
     if(hash == 2 || hash == (st_index_t)-2) {
@@ -356,8 +357,8 @@ BigDecimal_dump(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L357
     volatile VALUE dump;
 
     rb_scan_args(argc, argv, "01", &dummy);
-    GUARD_OBJ(vp,GetVpValue(self,1));
-    dump = rb_str_new(0,VpNumOfChars(vp,"E")+50);
+    GUARD_OBJ(vp,GetVpValue(self, 1));
+    dump = rb_str_new(0, VpNumOfChars(vp, "E")+50);
     psz = RSTRING_PTR(dump);
     sprintf(psz, "%"PRIuSIZE":", VpMaxPrec(vp)*VpBaseFig());
     VpToString(vp, psz+strlen(psz), 0, 0);
@@ -380,16 +381,18 @@ BigDecimal_load(VALUE self, VALUE str) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L381
     SafeStringValue(str);
     pch = (unsigned char *)RSTRING_PTR(str);
     /* First get max prec */
-    while((*pch)!=(unsigned char)'\0' && (ch=*pch++)!=(unsigned char)':') {
+    while((*pch) != (unsigned char)'\0' && (ch = *pch++) != (unsigned char)':') {
         if(!ISDIGIT(ch)) {
             rb_raise(rb_eTypeError, "load failed: invalid character in the marshaled string");
         }
         m = m*10 + (unsigned long)(ch-'0');
     }
-    if(m>VpBaseFig()) m -= VpBaseFig();
-    GUARD_OBJ(pv,VpNewRbClass(m,(char *)pch,self));
+    if (m > VpBaseFig()) m -= VpBaseFig();
+    GUARD_OBJ(pv, VpNewRbClass(m, (char *)pch, self));
     m /= VpBaseFig();
-    if(m && pv->MaxPrec>m) pv->MaxPrec = m+1;
+    if (m && pv->MaxPrec > m) {
+	pv->MaxPrec = m+1;
+    }
     return ToValue(pv);
 }
 
@@ -474,40 +477,39 @@ BigDecimal_mode(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L477
     VALUE val;
     unsigned long f,fo;
 
-    if(rb_scan_args(argc,argv,"11",&which,&val)==1) val = Qnil;
-
+    rb_scan_args(argc, argv, "11", &which, &val);
     Check_Type(which, T_FIXNUM);
     f = (unsigned long)FIX2INT(which);
 
-    if(f&VP_EXCEPTION_ALL) {
-        /* Exception mode setting */
-        fo = VpGetException();
-        if(val==Qnil) return INT2FIX(fo);
-        if(val!=Qfalse && val!=Qtrue) {
-            rb_raise(rb_eArgError, "second argument must be true or false");
-            return Qnil; /* Not reached */
-        }
-        if(f&VP_EXCEPTION_INFINITY) {
-            VpSetException((unsigned short)((val==Qtrue)?(fo|VP_EXCEPTION_INFINITY):
-                           (fo&(~VP_EXCEPTION_INFINITY))));
-        }
-        fo = VpGetException();
-        if(f&VP_EXCEPTION_NaN) {
-            VpSetException((unsigned short)((val==Qtrue)?(fo|VP_EXCEPTION_NaN):
-                           (fo&(~VP_EXCEPTION_NaN))));
-        }
-        fo = VpGetException();
-        if(f&VP_EXCEPTION_UNDERFLOW) {
-            VpSetException((unsigned short)((val==Qtrue)?(fo|VP_EXCEPTION_UNDERFLOW):
-                           (fo&(~VP_EXCEPTION_UNDERFLOW))));
-        }
-        fo = VpGetException();
-        if(f&VP_EXCEPTION_ZERODIVIDE) {
-            VpSetException((unsigned short)((val==Qtrue)?(fo|VP_EXCEPTION_ZERODIVIDE):
-                           (fo&(~VP_EXCEPTION_ZERODIVIDE))));
-        }
-        fo = VpGetException();
-        return INT2FIX(fo);
+    if (f & VP_EXCEPTION_ALL) {
+	/* Exception mode setting */
+	fo = VpGetException();
+	if (val == Qnil) return INT2FIX(fo);
+	if (val != Qfalse && val!=Qtrue) {
+	    rb_raise(rb_eArgError, "second argument must be true or false");
+	    return Qnil; /* Not reached */
+	}
+	if (f & VP_EXCEPTION_INFINITY) {
+	    VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_INFINITY) :
+			(fo & (~VP_EXCEPTION_INFINITY))));
+	}
+	fo = VpGetException();
+	if (f & VP_EXCEPTION_NaN) {
+	    VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_NaN) :
+			(fo & (~VP_EXCEPTION_NaN))));
+	}
+	fo = VpGetException();
+	if (f & VP_EXCEPTION_UNDERFLOW) {
+	    VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_UNDERFLOW) :
+			(fo & (~VP_EXCEPTION_UNDERFLOW))));
+	}
+	fo = VpGetException();
+	if(f & VP_EXCEPTION_ZERODIVIDE) {
+	    VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_ZERODIVIDE) :
+			(fo & (~VP_EXCEPTION_ZERODIVIDE))));
+	}
+	fo = VpGetException();
+	return INT2FIX(fo);
     }
     if (VP_ROUND_MODE == f) {
 	/* Rounding mode setting */
@@ -529,16 +531,16 @@ GetAddSubPrec(Real *a, Real *b) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L531
     size_t mx = a->Prec;
     SIGNED_VALUE d;
 
-    if(!VpIsDef(a) || !VpIsDef(b)) return (size_t)-1L;
-    if(mx < b->Prec) mx = b->Prec;
-    if(a->exponent!=b->exponent) {
-        mxs = mx;
-        d = a->exponent - b->exponent;
-        if (d < 0) d = -d;
-        mx = mx + (size_t)d;
-        if (mx<mxs) {
-            return VpException(VP_EXCEPTION_INFINITY,"Exponent overflow",0);
-        }
+    if (!VpIsDef(a) || !VpIsDef(b)) return (size_t)-1L;
+    if (mx < b->Prec) mx = b->Prec;
+    if (a->exponent != b->exponent) {
+	mxs = mx;
+	d = a->exponent - b->exponent;
+	if (d < 0) d = -d;
+	mx = mx + (size_t)d;
+	if (mx < mxs) {
+	    return VpException(VP_EXCEPTION_INFINITY, "Exponent overflow", 0);
+	}
     }
     return mx;
 }
@@ -550,7 +552,7 @@ GetPositiveInt(VALUE v) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L552
     Check_Type(v, T_FIXNUM);
     n = FIX2INT(v);
     if (n < 0) {
-        rb_raise(rb_eArgError, "argument must be positive");
+	rb_raise(rb_eArgError, "argument must be positive");
     }
     return n;
 }
@@ -594,8 +596,8 @@ VpCopy(Real *pv, Real const* const x) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L596
 static VALUE
 BigDecimal_IsNaN(VALUE self)
 {
-    Real *p = GetVpValue(self,1);
-    if(VpIsNaN(p))  return Qtrue;
+    Real *p = GetVpValue(self, 1);
+    if (VpIsNaN(p))  return Qtrue;
     return Qfalse;
 }
 
@@ -605,9 +607,9 @@ BigDecimal_IsNaN(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L607
 static VALUE
 BigDecimal_IsInfinite(VALUE self)
 {
-    Real *p = GetVpValue(self,1);
-    if(VpIsPosInf(p)) return INT2FIX(1);
-    if(VpIsNegInf(p)) return INT2FIX(-1);
+    Real *p = GetVpValue(self, 1);
+    if (VpIsPosInf(p)) return INT2FIX(1);
+    if (VpIsNegInf(p)) return INT2FIX(-1);
     return Qnil;
 }
 
@@ -615,21 +617,23 @@ BigDecimal_IsInfinite(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L617
 static VALUE
 BigDecimal_IsFinite(VALUE self)
 {
-    Real *p = GetVpValue(self,1);
-    if(VpIsNaN(p)) return Qfalse;
-    if(VpIsInf(p)) return Qfalse;
+    Real *p = GetVpValue(self, 1);
+    if (VpIsNaN(p)) return Qfalse;
+    if (VpIsInf(p)) return Qfalse;
     return Qtrue;
 }
 
 static void
 BigDecimal_check_num(Real *p)
 {
-    if(VpIsNaN(p)) {
-       VpException(VP_EXCEPTION_NaN,"Computation results to 'NaN'(Not a Number)",1);
-    } else if(VpIsPosInf(p)) {
-       VpException(VP_EXCEPTION_INFINITY,"Computation results to 'Infinity'",1);
-    } else if(VpIsNegInf(p)) {
-       VpException(VP_EXCEPTION_INFINITY,"Computation results to '-Infinity'",1);
+    if (VpIsNaN(p)) {
+	VpException(VP_EXCEPTION_NaN, "Computation results to 'NaN'(Not a Number)", 1);
+    }
+    else if (VpIsPosInf(p)) {
+	VpException(VP_EXCEPTION_INFINITY, "Computation results to 'Infinity'", 1);
+    }
+    else if (VpIsNegInf(p)) {
+	VpException(VP_EXCEPTION_INFINITY, "Computation results to '-Infinity'", 1);
     }
 }
 
@@ -646,14 +650,14 @@ BigDecimal_to_i(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L650
     ssize_t e, nf;
     Real *p;
 
-    GUARD_OBJ(p,GetVpValue(self,1));
+    GUARD_OBJ(p, GetVpValue(self, 1));
     BigDecimal_check_num(p);
 
     e = VpExponent10(p);
-    if(e<=0) return INT2FIX(0);
+    if (e <= 0) return INT2FIX(0);
     nf = VpBaseFig();
-    if(e<=nf) {
-        return LONG2NUM((long)(VpGetSign(p)*(BDIGIT_DBL_SIGNED)p->frac[0]));
+    if (e <= nf) {
+        return LONG2NUM((long)(VpGetSign(p) * (BDIGIT_DBL_SIGNED)p->frac[0]));
     }
     else {
 	VALUE a = BigDecimal_split(self);
@@ -670,12 +674,14 @@ BigDecimal_to_i(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L674
 			      rb_funcall(INT2FIX(10), rb_intern("**"), 1,
 					 INT2FIX(-dpower)));
 	}
-	else
+	else {
 	    ret = rb_funcall(numerator, '*', 1,
 			     rb_funcall(INT2FIX(10), rb_intern("**"), 1,
 					INT2FIX(dpower)));
-	if (RB_TYPE_P(ret, T_FLOAT))
+	}
+	if (RB_TYPE_P(ret, T_FLOAT)) {
 	    rb_raise(rb_eFloatDomainError, "Infinity");
+	}
 	return ret;
     }
 }
@@ -702,7 +708,7 @@ BigDecimal_to_f(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L708
     if (e < (SIGNED_VALUE)(DBL_MIN_10_EXP-BASE_FIG))
 	goto underflow;
 
-    str = rb_str_new(0, VpNumOfChars(p,"E"));
+    str = rb_str_new(0, VpNumOfChars(p, "E"));
     buf = RSTRING_PTR(str);
     VpToString(p, buf, 0, 0);
     errno = 0;
@@ -738,7 +744,7 @@ BigDecimal_to_r(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L744
     ssize_t sign, power, denomi_power;
     VALUE a, digits, numerator;
 
-    p = GetVpValue(self,1);
+    p = GetVpValue(self, 1);
     BigDecimal_check_num(p);
 
     sign = VpGetSign(p);
@@ -757,7 +763,7 @@ BigDecimal_to_r(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L763
 				      INT2FIX(-denomi_power)));
     }
     else {
-        return rb_Rational1(rb_funcall(numerator, '*', 1,
+	return rb_Rational1(rb_funcall(numerator, '*', 1,
 				       rb_funcall(INT2FIX(10), rb_intern("**"), 1,
 						  INT2FIX(denomi_power))));
     }
@@ -847,7 +853,7 @@ BigDecimal_add(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L853
 	b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1);
     }
     else {
-	b = GetVpValue(r,0);
+	b = GetVpValue(r, 0);
     }
 
     if (!b) return DoSomeOne(self,r,'+');
@@ -893,7 +899,7 @@ BigDecimal_sub(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L899
     Real *c, *a, *b;
     size_t mx;
 
-    GUARD_OBJ(a,GetVpValue(self,1));
+    GUARD_OBJ(a, GetVpValue(self,1));
     if (RB_TYPE_P(r, T_FLOAT)) {
 	b = GetVpValueWithPrec(r, DBL_DIG+1, 1);
     }
@@ -904,23 +910,25 @@ BigDecimal_sub(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L910
 	b = GetVpValue(r,0);
     }
 
-    if(!b) return DoSomeOne(self,r,'-');
+    if (!b) return DoSomeOne(self,r,'-');
     SAVE(b);
 
-    if(VpIsNaN(b)) return b->obj;
-    if(VpIsNaN(a)) return a->obj;
+    if (VpIsNaN(b)) return b->obj;
+    if (VpIsNaN(a)) return a->obj;
 
     mx = GetAddSubPrec(a,b);
     if (mx == (size_t)-1L) {
-        GUARD_OBJ(c,VpCreateRbObject(VpBaseFig() + 1, "0"));
-        VpAddSub(c, a, b, -1);
-    } else {
-        GUARD_OBJ(c,VpCreateRbObject(mx *(VpBaseFig() + 1), "0"));
-        if(!mx) {
-            VpSetInf(c,VpGetSign(a));
-        } else {
-            VpAddSub(c, a, b, -1);
-        }
+	GUARD_OBJ(c,VpCreateRbObject(VpBaseFig() + 1, "0"));
+	VpAddSub(c, a, b, -1);
+    }
+    else {
+	GUARD_OBJ(c,VpCreateRbObject(mx *(VpBaseFig() + 1), "0"));
+	if (!mx) {
+	    VpSetInf(c,VpGetSign(a));
+	}
+	else {
+	    VpAddSub(c, a, b, -1);
+	}
     }
     return ToValue(c);
 }
@@ -931,7 +939,7 @@ BigDecimalCmp(VALUE self, VALUE r,char o https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L939
     ENTER(5);
     SIGNED_VALUE e;
     Real *a, *b=0;
-    GUARD_OBJ(a,GetVpValue(self,1));
+    GUARD_OBJ(a, GetVpValue(self, 1));
     switch (TYPE(r)) {
     case T_DATA:
 	if (!is_kind_of_BigDecimal(r)) break;
@@ -939,7 +947,7 @@ BigDecimalCmp(VALUE self, VALUE r,char o https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L947
     case T_FIXNUM:
 	/* fall through */
     case T_BIGNUM:
-	GUARD_OBJ(b, GetVpValue(r,0));
+	GUARD_OBJ(b, GetVpValue(r, 0));
 	break;
 
     case T_FLOAT:
@@ -991,23 +999,23 @@ BigDecimalCmp(VALUE self, VALUE r,char o https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L999
 	return   INT2FIX(e); /* any op */
 
     case '=':
-	if(e==0) return Qtrue;
+	if (e == 0) return Qtrue;
 	return Qfalse;
 
     case 'G':
-	if(e>=0) return Qtrue;
+	if (e >= 0) return Qtrue;
 	return Qfalse;
 
     case '>':
-	if(e> 0) return Qtrue;
+	if (e >  0) return Qtrue;
 	return Qfalse;
 
     case 'L':
-	if(e<=0) return Qtrue;
+	if (e <= 0) return Qtrue;
 	return Qfalse;
 
     case '<':
-	if(e< 0) return Qtrue;
+	if (e <  0) return Qtrue;
 	return Qfalse;
 
     default:
@@ -1023,7 +1031,7 @@ BigDecimalCmp(VALUE self, VALUE r,char o https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1031
 static VALUE
 BigDecimal_zero(VALUE self)
 {
-    Real *a = GetVpValue(self,1);
+    Real *a = GetVpValue(self, 1);
     return VpIsZero(a) ? Qtrue : Qfalse;
 }
 
@@ -1031,7 +1039,7 @@ BigDecimal_zero(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1039
 static VALUE
 BigDecimal_nonzero(VALUE self)
 {
-    Real *a = GetVpValue(self,1);
+    Real *a = GetVpValue(self, 1);
     return VpIsZero(a) ? Qnil : self;
 }
 
@@ -1126,8 +1134,8 @@ BigDecimal_neg(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1134
 {
     ENTER(5);
     Real *c, *a;
-    GUARD_OBJ(a,GetVpValue(self,1));
-    GUARD_OBJ(c,VpCreateRbObject(a->Prec *(VpBaseFig() + 1), "0"));
+    GUARD_OBJ(a, GetVpValue(self, 1));
+    GUARD_OBJ(c, VpCreateRbObject(a->Prec *(VpBaseFig() + 1), "0"));
     VpAsgn(c, a, -1);
     return ToValue(c);
 }
@@ -1154,7 +1162,7 @@ BigDecimal_mult(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1162
     Real *c, *a, *b;
     size_t mx;
 
-    GUARD_OBJ(a,GetVpValue(self,1));
+    GUARD_OBJ(a, GetVpValue(self, 1));
     if (RB_TYPE_P(r, T_FLOAT)) {
 	b = GetVpValueWithPrec(r, DBL_DIG+1, 1);
     }
@@ -1165,11 +1173,11 @@ BigDecimal_mult(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1173
 	b = GetVpValue(r,0);
     }
 
-    if(!b) return DoSomeOne(self,r,'*');
+    if (!b) return DoSomeOne(self, r, '*');
     SAVE(b);
 
     mx = a->Prec + b->Prec;
-    GUARD_OBJ(c,VpCreateRbObject(mx *(VpBaseFig() + 1), "0"));
+    GUARD_OBJ(c, VpCreateRbObject(mx *(VpBaseFig() + 1), "0"));
     VpMult(c, a, b);
     return ToValue(c);
 }
@@ -1182,26 +1190,26 @@ BigDecimal_divide(Real **c, Real **res, https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1190
     Real *a, *b;
     size_t mx;
 
-    GUARD_OBJ(a,GetVpValue(self,1));
+    GUARD_OBJ(a, GetVpValue(self, 1));
     if (RB_TYPE_P(r, T_FLOAT)) {
 	b = GetVpValueWithPrec(r, DBL_DIG+1, 1);
     }
     else if (RB_TYPE_P(r, T_RATIONAL)) {
 	b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1);
-    }
+     }
     else {
-	b = GetVpValue(r,0);
+	b = GetVpValue(r, 0);
     }
 
-    if(!b) return DoSomeOne(self,r,'/');
+    if (!b) return DoSomeOne(self, r, '/');
     SAVE(b);
 
     *div = b;
     mx = a->Prec + vabs(a->exponent);
-    if(mx<b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent);
+    if (mx<b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent);
     mx =(mx + 1) * VpBaseFig();
-    GUARD_OBJ((*c),VpCreateRbObject(mx, "#0"));
-    GUARD_OBJ((*res),VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
+    GUARD_OBJ((*c), VpCreateRbObject(mx, "#0"));
+    GUARD_OBJ((*res), VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
     VpDivd(*c, *res, a, b);
     return (VALUE)0;
 }
@@ -1232,15 +1240,15 @@ BigDecimal_div(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1240
     ENTER(5);
     Real *c=NULL, *res=NULL, *div = NULL;
     r = BigDecimal_divide(&c, &res, &div, self, r);
-    if(r!=(VALUE)0) return r; /* coerced by other */
-    SAVE(c);SAVE(res);SAVE(div);
+    if (r != (VALUE)0) return r; /* coerced by other */
+    SAVE(c); SAVE(res); SAVE(div);
     /* a/b = c + r/b */
     /* c xxxxx
        r 00000yyyyy  ==> (y/b)*BASE >= HALF_BASE
      */
     /* Round */
-    if(VpHasVal(div)) { /* frac[0] must be zero for NaN,INF,Zero */
-	VpInternalRound(c, 0, c->frac[c->Prec-1], (BDIGIT)(VpBaseVal()*(BDIGIT_DBL)res->frac[0]/div->frac[0]));
+    if (VpHasVal(div)) { /* frac[0] must be zero for NaN,INF,Zero */
+	VpInternalRound(c, 0, c->frac[c->Prec-1], (BDIGIT)(VpBaseVal() * (BDIGIT_DBL)res->frac[0] / div->frac[0]));
     }
     return ToValue(c);
 }
@@ -1257,7 +1265,7 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1265
     Real *a, *b;
     size_t mx;
 
-    GUARD_OBJ(a,GetVpValue(self,1));
+    GUARD_OBJ(a, GetVpValue(self, 1));
     if (RB_TYPE_P(r, T_FLOAT)) {
 	b = GetVpValueWithPrec(r, DBL_DIG+1, 1);
     }
@@ -1265,65 +1273,65 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1273
 	b = GetVpValueWithPrec( (... truncated)

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

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