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

ruby-changes:27680

From: takano32 <ko1@a...>
Date: Tue, 12 Mar 2013 17:03:02 +0900 (JST)
Subject: [ruby-changes:27680] takano32:r39732 (trunk): * rational.c: fix dangling if, else-if and else.

takano32	2013-03-12 17:00:16 +0900 (Tue, 12 Mar 2013)

  New Revision: 39732

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

  Log:
    * rational.c: fix dangling if, else-if and else.

  Modified files:
    trunk/ChangeLog
    trunk/rational.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39731)
+++ ChangeLog	(revision 39732)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Mar 12 16:48:19 2013  TAKANO Mitsuhiro <tak@n...>
+
+	* rational.c: fix dangling if, else-if and else.
+
 Tue Mar 12 06:27:59 2013  Eric Hodel  <drbrain@s...>
 
 	* lib/rubygems/commands/setup_command.rb:  Don't delete non-rubygems
Index: rational.c
===================================================================
--- rational.c	(revision 39731)
+++ rational.c	(revision 39732)
@@ -991,16 +991,22 @@ nurat_expt(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/rational.c#L991
     /* Deal with special cases of 0**n and 1**n */
     if (k_numeric_p(other) && k_exact_p(other)) {
 	get_dat1(self);
-	if (f_one_p(dat->den))
-	    if (f_one_p(dat->num))
+	if (f_one_p(dat->den)) {
+	    if (f_one_p(dat->num)) {
 		return f_rational_new_bang1(CLASS_OF(self), ONE);
-	    else if (f_minus_one_p(dat->num) && k_integer_p(other))
+	    }
+	    else if (f_minus_one_p(dat->num) && k_integer_p(other)) {
 		return f_rational_new_bang1(CLASS_OF(self), INT2FIX(f_odd_p(other) ? -1 : 1));
-	    else if (f_zero_p(dat->num))
-		if (FIX2INT(f_cmp(other, ZERO)) == -1)
+	    }
+	    else if (f_zero_p(dat->num)) {
+		if (FIX2INT(f_cmp(other, ZERO)) == -1) {
 		    rb_raise_zerodiv();
-		else
+		}
+		else {
 		    return f_rational_new_bang1(CLASS_OF(self), ZERO);
+		}
+	    }
+	}
     }
 
     /* General case */

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

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