diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-03-05 05:22:17 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-03-05 05:22:17 +0000 |
commit | 39787ea14db33dd4265d7f6271cd2d59ccaeff37 (patch) | |
tree | 49743edd8a3dbb4fa4cfea6c472f3398edfe0639 /range.c | |
parent | 413db1b036083f76a2b34895af3c8a3204e174f2 (diff) | |
download | ruby-39787ea14db33dd4265d7f6271cd2d59ccaeff37.tar.gz |
* 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 'range.c')
-rw-r--r-- | range.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -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"); |