summaryrefslogtreecommitdiff
path: root/rational.c
diff options
context:
space:
mode:
authortakano32 <takano32@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-12 08:00:16 (GMT)
committertakano32 <takano32@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-12 08:00:16 (GMT)
commit5e04bb66973015fa0edfe4881dd46fd7f4f72a7e (patch)
treee1f875d09fdb354c1a85fd5b93f2105c0712b6dd /rational.c
parent10c5d6ee2593f5b6a0361009201464c248158da6 (diff)
* rational.c: fix dangling if, else-if and else.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'rational.c')
-rw-r--r--rational.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/rational.c b/rational.c
index e009ff2..e96cace 100644
--- a/rational.c
+++ b/rational.c
@@ -991,16 +991,22 @@ nurat_expt(VALUE self, VALUE other)
/* 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 */