summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-12-07 09:25:55 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-12-07 09:25:55 +0000
commitc18d3740a925e8752c3b93acea6087fb0e03be53 (patch)
tree433875ec298641b66886505abab4d16b7b555cd6 /range.c
parentdee96209bfbb957538c7adeb01a65f3830749179 (diff)
991207
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r--range.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/range.c b/range.c
index f521c14..8af5b69 100644
--- a/range.c
+++ b/range.c
@@ -263,6 +263,25 @@ range_inspect(range)
}
static VALUE
+length_i(i, length)
+ VALUE i;
+ int *length;
+{
+ (*length)++;
+ return Qnil;
+}
+
+VALUE
+rb_length_by_each(obj)
+ VALUE obj;
+{
+ int length = 0;
+
+ rb_iterate(rb_each, obj, length_i, (VALUE)&length);
+ return INT2FIX(length);
+}
+
+static VALUE
range_length(range)
VALUE range;
{
@@ -284,7 +303,7 @@ range_length(range)
}
}
if (!rb_obj_is_kind_of(beg, rb_cNumeric)) {
- return rb_enum_length(range);
+ return rb_length_by_each(range);
}
size = rb_funcall(end, '-', 1, beg);
if (!EXCL(range)) {