* range.c (range_step): check if step can be converted to an integer.
[ruby-dev:34558] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0a32f9a43f
commit
7b2c68fd32
@ -1,4 +1,7 @@
|
||||
Thu May 1 23:35:11 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Thu May 1 23:43:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* range.c (range_step): check if step can be converted to an integer.
|
||||
[ruby-dev:34558]
|
||||
|
||||
* range.c (range_step): allow float step bigger than zero but less
|
||||
than one. [ruby-dev:34557]
|
||||
|
6
range.c
6
range.c
@ -308,11 +308,13 @@ range_step(int argc, VALUE *argv, VALUE range)
|
||||
}
|
||||
else {
|
||||
rb_scan_args(argc, argv, "01", &step);
|
||||
if (FIXNUM_P(step)) {
|
||||
tmp = rb_check_to_integer(step, "to_int");
|
||||
if (!NIL_P(tmp)) {
|
||||
step = tmp;
|
||||
unit = NUM2LONG(step);
|
||||
}
|
||||
else {
|
||||
VALUE tmp = rb_funcall(rb_funcall(b, '+', 1, step), '-', 1, b);
|
||||
tmp = rb_funcall(rb_funcall(b, '+', 1, step), '-', 1, b);
|
||||
unit = rb_cmpint(tmp, step, INT2FIX(0));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user