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

ruby-changes:25650

From: tadf <ko1@a...>
Date: Sun, 18 Nov 2012 09:26:45 +0900 (JST)
Subject: [ruby-changes:25650] tadf:r37707 (trunk): trivial changes.

tadf	2012-11-18 09:26:15 +0900 (Sun, 18 Nov 2012)

  New Revision: 37707

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

  Log:
    trivial changes.

  Modified files:
    trunk/complex.c
    trunk/rational.c

Index: complex.c
===================================================================
--- complex.c	(revision 37706)
+++ complex.c	(revision 37707)
@@ -1,5 +1,5 @@
 /*
-  complex.c: Coded by Tadayoshi Funaba 2008-2011
+  complex.c: Coded by Tadayoshi Funaba 2008-2012
 
   This implementation is based on Keiju Ishitsuka's Complex library
   which is written in ruby.
@@ -1626,10 +1626,8 @@
 {
     if (strchr(s, '/'))
 	return rb_cstr_to_rat(s, 0);
-    if (strpbrk(s, ".eE")) {
-	double d = rb_cstr_to_dbl(s, 0);
-	return DBL2NUM(d);
-    }
+    if (strpbrk(s, ".eE"))
+	return DBL2NUM(rb_cstr_to_dbl(s, 0));
     return rb_cstr_to_inum(s, 10, 0);
 }
 
@@ -1715,6 +1713,13 @@
     }
 }
 
+static void
+skip_ws(const char **s)
+{
+    while (isspace((unsigned char)**s))
+	(*s)++;
+}
+
 static int
 parse_comp(const char *s, int strict,
 	   VALUE *num)
@@ -1724,15 +1729,11 @@
     buf = ALLOCA_N(char, strlen(s) + 1);
     b = buf;
 
-    while (isspace((unsigned char)*s))
-	s++;
-
+    skip_ws(&s);
     if (!read_comp(&s, strict, num, &b))
 	return 0;
+    skip_ws(&s);
 
-    while (isspace((unsigned char)*s))
-	s++;
-
     if (strict)
 	if (*s != '\0')
 	    return 0;
Index: rational.c
===================================================================
--- rational.c	(revision 37706)
+++ rational.c	(revision 37707)
@@ -1,5 +1,5 @@
 /*
-  rational.c: Coded by Tadayoshi Funaba 2008-2011
+  rational.c: Coded by Tadayoshi Funaba 2008-2012
 
   This implementation is based on Keiju Ishitsuka's Rational library
   which is written in ruby.
@@ -2093,19 +2093,22 @@
     return 1;
 }
 
+static void
+skip_ws(const char **s)
+{
+    while (isspace((unsigned char)**s))
+	(*s)++;
+}
+
 static int
 parse_rat(const char *s, int strict,
 	  VALUE *num)
 {
-    while (isspace((unsigned char)*s))
-	s++;
-
+    skip_ws(&s);
     if (!read_rat(&s, strict, num))
 	return 0;
+    skip_ws(&s);
 
-    while (isspace((unsigned char)*s))
-	s++;
-
     if (strict)
 	if (*s != '\0')
 	    return 0;

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

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