summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-01 14:43:24 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-01 14:43:24 +0000
commit7b2c68fd32ea4300131c34a6dfd346649fe78383 (patch)
tree1575fcb3d7920fcb964fdfa8876f85158a59d247
parent0a32f9a43faba89f8aa7b43f524ab3552570ce65 (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--range.c6
2 files changed, 8 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index e58bf4862c..0c63fce6c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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]
diff --git a/range.c b/range.c
index d81db5fff5..ae172be4e7 100644
--- a/range.c
+++ b/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));
}
}