зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
2897cdae9b
Коммит
a46544a4f9
|
@ -1,3 +1,9 @@
|
|||
Sun Sep 21 18:06:38 2008 Tadayoshi Funaba <tadf@dotrb.org>
|
||||
|
||||
* complex.c (nucomp_s_convert): checks argc.
|
||||
|
||||
* rational.c (nurat_s_convert): ditto.
|
||||
|
||||
Sun Sep 21 10:19:04 2008 Tadayoshi Funaba <tadf@dotrb.org>
|
||||
|
||||
* complex.c (nucomp_s_canonicalize_internal): checks exactness of
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче