From a46544a4f9d31a2df3f9f2538de3fcb9715231fc Mon Sep 17 00:00:00 2001 From: tadf Date: Sun, 21 Sep 2008 09:07:25 +0000 Subject: [PATCH] * complex.c (nucomp_s_convert): checks argc. * rational.c (nurat_s_convert): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ complex.c | 7 +++---- rational.c | 7 +++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index dcb23cf6b0..c3b9627b2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Sep 21 18:06:38 2008 Tadayoshi Funaba + + * complex.c (nucomp_s_convert): checks argc. + + * rational.c (nurat_s_convert): ditto. + Sun Sep 21 10:19:04 2008 Tadayoshi Funaba * complex.c (nucomp_s_canonicalize_internal): checks exactness of diff --git a/complex.c b/complex.c index 442aa69586..52acce544f 100644 --- a/complex.c +++ b/complex.c @@ -1226,10 +1226,9 @@ string_to_c(VALUE self) static VALUE nucomp_s_convert(int argc, VALUE *argv, VALUE klass) { - int c; VALUE a1, a2, backref; - c = rb_scan_args(argc, argv, "02", &a1, &a2); + rb_scan_args(argc, argv, "11", &a1, &a2); backref = rb_backref_get(); rb_match_busy(backref); @@ -1278,11 +1277,11 @@ nucomp_s_convert(int argc, VALUE *argv, VALUE klass) switch (TYPE(a1)) { case T_COMPLEX: - if (c == 1 || (k_exact_p(a2) && f_zero_p(a2))) + if (argc == 1 || (k_exact_p(a2) && f_zero_p(a2))) return a1; } - if (c == 1) { + if (argc == 1) { if (k_numeric_p(a1) && !f_real_p(a1)) return a1; } diff --git a/rational.c b/rational.c index 59c86d8899..fea6f63ab8 100644 --- a/rational.c +++ b/rational.c @@ -1400,10 +1400,9 @@ string_to_r(VALUE self) static VALUE nurat_s_convert(int argc, VALUE *argv, VALUE klass) { - int c; VALUE a1, a2, backref; - c = rb_scan_args(argc, argv, "02", &a1, &a2); + rb_scan_args(argc, argv, "11", &a1, &a2); switch (TYPE(a1)) { case T_COMPLEX: @@ -1448,11 +1447,11 @@ nurat_s_convert(int argc, VALUE *argv, VALUE klass) switch (TYPE(a1)) { case T_RATIONAL: - if (c == 1 || (k_exact_p(a2) && f_one_p(a2))) + if (argc == 1 || (k_exact_p(a2) && f_one_p(a2))) return a1; } - if (c == 1) { + if (argc == 1) { if (k_numeric_p(a1) && !f_integer_p(a1)) return a1; }