diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-09 12:02:29 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-09 12:02:29 +0000 |
commit | a20cf402cfa15e0f078e2750dc0fc17c44b529f6 (patch) | |
tree | 14396e33139bd6f790cbb8392a2aae427352a332 /rational.c | |
parent | f8ef02adc40e364107bb7629cf9eca1e9097309a (diff) | |
download | bundler-a20cf402cfa15e0f078e2750dc0fc17c44b529f6.tar.gz |
* complex.c (nucomp_s_convert): can accept Complex('i').
[ruby-dev:34991]
and some minor changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'rational.c')
-rw-r--r-- | rational.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/rational.c b/rational.c index 8bf786a166..54bca51094 100644 --- a/rational.c +++ b/rational.c @@ -512,25 +512,19 @@ nurat_s_canonicalize(int argc, VALUE *argv, VALUE klass) #endif static VALUE -nurat_s_new(VALUE klass, VALUE num, VALUE den) +nurat_s_new(int argc, VALUE *argv, VALUE klass) { + VALUE num, den; + + if (rb_scan_args(argc, argv, "11", &num, &den) == 1) + den = ONE; + nurat_int_check(num); nurat_int_check(den); return nurat_s_canonicalize_internal(klass, num, den); } -static VALUE -nurat_s_new_m(int argc, VALUE *argv, VALUE klass) -{ - VALUE num, den; - - if (rb_scan_args(argc, argv, "11", &num, &den) == 1) { - den = ONE; - } - return nurat_s_new(klass, num, den); -} - inline static VALUE f_rational_new1(VALUE klass, VALUE x) { @@ -1428,9 +1422,8 @@ nurat_s_convert(int argc, VALUE *argv, VALUE klass) { VALUE a1, a2; - if (rb_scan_args(argc, argv, "02", &a1, &a2) == 1) { + if (rb_scan_args(argc, argv, "02", &a1, &a2) == 1) a2 = ONE; - } switch (TYPE(a1)) { case T_COMPLEX: @@ -1489,7 +1482,12 @@ nurat_s_convert(int argc, VALUE *argv, VALUE klass) return f_div(a1, a2); } - return nurat_s_new(klass, a1, a2); + { + VALUE argv2[2]; + argv2[0] = a1; + argv2[1] = a2; + return nurat_s_new(argc, argv2, klass); + } } static VALUE @@ -1533,7 +1531,7 @@ Init_Rational(void) rb_funcall(rb_cRational, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("new!"))); - rb_define_singleton_method(rb_cRational, "new", nurat_s_new_m, -1); + rb_define_singleton_method(rb_cRational, "new", nurat_s_new, -1); rb_funcall(rb_cRational, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("new"))); |