summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-02 08:31:04 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-02 08:31:04 +0000
commit2470ac539348cbf6e6e13a39b270c21eebf7c7f9 (patch)
tree9acf743ec17a2a52706d8b87938514d17e9371b4
parent56a0b4b33cd86c60b6c73d14704ab85fa6c952ed (diff)
downloadruby-2470ac539348cbf6e6e13a39b270c21eebf7c7f9.tar.gz
ruby-2470ac539348cbf6e6e13a39b270c21eebf7c7f9.tar.xz
ruby-2470ac539348cbf6e6e13a39b270c21eebf7c7f9.zip
* range.c (range_step): call to_int if step is not a numeric
value. [ruby-dev:34575] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--range.c3
2 files changed, 8 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index cb2ce2cd0..c25f72594 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri May 2 17:29:59 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_step): call to_int if step is not a numeric
+ value. [ruby-dev:34575]
+
Fri May 2 16:10:57 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* range.c (range_step): do not forcefully convert steps into
diff --git a/range.c b/range.c
index 5835d80c2..45ba78dcf 100644
--- a/range.c
+++ b/range.c
@@ -306,6 +306,9 @@ range_step(int argc, VALUE *argv, VALUE range)
}
else {
rb_scan_args(argc, argv, "01", &step);
+ if (!rb_obj_is_kind_of(step, rb_cNumeric)) {
+ step = rb_to_int(step);
+ }
if (rb_funcall(step, '<', 1, INT2FIX(0))) {
rb_raise(rb_eArgError, "step can't be negative");
}