From 39787ea14db33dd4265d7f6271cd2d59ccaeff37 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 5 Mar 2008 05:22:17 +0000 Subject: * 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 --- range.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'range.c') diff --git a/range.c b/range.c index e3dd44290a..94e8182a87 100644 --- a/range.c +++ b/range.c @@ -300,17 +300,20 @@ range_step(int argc, VALUE *argv, VALUE range) b = RANGE_BEG(range); e = RANGE_END(range); - if (rb_scan_args(argc, argv, "01", &step) == 0) { + if (argc == 0) { step = INT2FIX(1); unit = 1; } - else if (FIXNUM_P(step)) { - unit = NUM2LONG(step); - } else { - VALUE tmp = rb_to_int(step); - unit = rb_cmpint(tmp, step, INT2FIX(0)); - step = tmp; + rb_scan_args(argc, argv, "01", &step); + if (FIXNUM_P(step)) { + unit = NUM2LONG(step); + } + else { + VALUE tmp = rb_to_int(step); + unit = rb_cmpint(tmp, step, INT2FIX(0)); + step = tmp; + } } if (unit < 0) { rb_raise(rb_eArgError, "step can't be negative"); -- cgit v1.2.3