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

ruby-changes:26758

From: mrkn <ko1@a...>
Date: Mon, 14 Jan 2013 14:43:03 +0900 (JST)
Subject: [ruby-changes:26758] mrkn:r38810 (trunk): * ext/bigdecimal/bigdecimal.c (BigDecimal_to_s): use CRuby style.

mrkn	2013-01-14 14:42:51 +0900 (Mon, 14 Jan 2013)

  New Revision: 38810

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

  Log:
    * ext/bigdecimal/bigdecimal.c (BigDecimal_to_s): use CRuby style.

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38809)
+++ ChangeLog	(revision 38810)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jan 14 14:41:00 2013  Kenta Murata  <mrkn@m...>
+
+	* ext/bigdecimal/bigdecimal.c (BigDecimal_to_s): use CRuby style.
+
 Mon Jan 14 14:39:00 2013  Kenta Murata  <mrkn@m...>
 
 	* ext/bigdecimal/bigdecimal.c: use `RB_TYPE_P(x, t)` instead of
Index: ext/bigdecimal/bigdecimal.c
===================================================================
--- ext/bigdecimal/bigdecimal.c	(revision 38809)
+++ ext/bigdecimal/bigdecimal.c	(revision 38810)
@@ -1840,8 +1840,8 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1840
 BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
 {
     ENTER(5);
-    int   fmt=0;   /* 0:E format */
-    int   fPlus=0; /* =0:default,=1: set ' ' before digits ,set '+' before digits. */
+    int   fmt = 0;   /* 0:E format */
+    int   fPlus = 0; /* =0:default,=1: set ' ' before digits ,set '+' before digits. */
     Real  *vp;
     volatile VALUE str;
     char  *psz;
@@ -1851,42 +1851,53 @@ BigDecimal_to_s(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1851
 
     GUARD_OBJ(vp,GetVpValue(self,1));
 
-    if(rb_scan_args(argc,argv,"01",&f)==1) {
+    if (rb_scan_args(argc,argv,"01",&f)==1) {
 	if (RB_TYPE_P(f, T_STRING)) {
-            SafeStringValue(f);
-            psz = RSTRING_PTR(f);
-            if(*psz==' ') {
-                fPlus = 1; psz++;
-            } else if(*psz=='+') {
-                fPlus = 2; psz++;
-            }
-            while((ch=*psz++)!=0) {
-                if(ISSPACE(ch)) continue;
-                if(!ISDIGIT(ch)) {
-                    if(ch=='F' || ch=='f') fmt = 1; /* F format */
-                    break;
-                }
-                mc = mc * 10 + ch - '0';
-            }
-        }
+	    SafeStringValue(f);
+	    psz = RSTRING_PTR(f);
+	    if (*psz == ' ') {
+		fPlus = 1;
+		psz++;
+	    }
+	    else if (*psz == '+') {
+		fPlus = 2;
+		psz++;
+	    }
+	    while ((ch = *psz++) != 0) {
+		if (ISSPACE(ch)) {
+		    continue;
+		}
+		if (!ISDIGIT(ch)) {
+		    if (ch == 'F' || ch == 'f') {
+			fmt = 1; /* F format */
+		    }
+		    break;
+		}
+		mc = mc * 10 + ch - '0';
+	    }
+	}
 	else {
-            mc = (size_t)GetPositiveInt(f);
-        }
+	    mc = (size_t)GetPositiveInt(f);
+	}
     }
-    if(fmt) {
-        nc = VpNumOfChars(vp,"F");
-    } else {
-        nc = VpNumOfChars(vp,"E");
+    if (fmt) {
+	nc = VpNumOfChars(vp, "F");
+    }
+    else {
+	nc = VpNumOfChars(vp, "E");
+    }
+    if (mc > 0) {
+	nc += (nc + mc - 1) / mc + 1;
     }
-    if(mc>0) nc += (nc + mc - 1) / mc + 1;
 
     str = rb_str_new(0, nc);
     psz = RSTRING_PTR(str);
 
-    if(fmt) {
-        VpToFString(vp, psz, mc, fPlus);
-    } else {
-        VpToString (vp, psz, mc, fPlus);
+    if (fmt) {
+	VpToFString(vp, psz, mc, fPlus);
+    }
+    else {
+	VpToString (vp, psz, mc, fPlus);
     }
     rb_str_resize(str, strlen(psz));
     return str;

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

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