summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-05 05:22:17 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-05 05:22:17 +0000
commit39787ea14db33dd4265d7f6271cd2d59ccaeff37 (patch)
tree49743edd8a3dbb4fa4cfea6c472f3398edfe0639 /numeric.c
parent413db1b036083f76a2b34895af3c8a3204e174f2 (diff)
* numeric.c (fix_to_s): avoid rb_scan_args() when no argument
given. * bignum.c (rb_big_to_s): ditto. * enum.c (enum_first): ditto. * eval_jump.c (rb_f_catch): ditto. * io.c (rb_obj_display): ditto. * class.c (rb_obj_singleton_methods): ditto. * object.c (rb_class_initialize): ditto. * random.c (rb_f_srand): ditto. * range.c (range_step): ditto. * re.c (rb_reg_s_last_match): ditto. * string.c (rb_str_to_i): ditto. * string.c (rb_str_each_line): ditto. * string.c (rb_str_chomp_bang): ditto. * string.c (rb_str_sum): ditto. * string.c (str_modifiable): declare inline. * string.c (str_independent): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/numeric.c b/numeric.c
index d1626d0..3398c37 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1263,7 +1263,7 @@ flo_round(int argc, VALUE *argv, VALUE num)
int ndigits = 0, i;
long val;
- if (rb_scan_args(argc, argv, "01", &nd) == 1) {
+ if (argc > 0 && rb_scan_args(argc, argv, "01", &nd) == 1) {
ndigits = NUM2INT(nd);
}
number = RFLOAT_VALUE(num);
@@ -2008,12 +2008,15 @@ rb_fix2str(VALUE x, int base)
static VALUE
fix_to_s(int argc, VALUE *argv, VALUE x)
{
- VALUE b;
int base;
- rb_scan_args(argc, argv, "01", &b);
if (argc == 0) base = 10;
- else base = NUM2INT(b);
+ else {
+ VALUE b;
+
+ rb_scan_args(argc, argv, "01", &b);
+ base = NUM2INT(b);
+ }
return rb_fix2str(x, base);
}