summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-11-17 07:30:37 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-11-17 07:30:37 +0000
commit8e48dc16e97a783a69f0972b4882ad2faae561ea (patch)
treec25927a4f286e4ed5f3c7637076332e99287b089 /enum.c
parent943e99e62746388456955729e9f8417f3df5f8b5 (diff)
19991117
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enum.c')
-rw-r--r--enum.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/enum.c b/enum.c
index 05194c1..008e0a4 100644
--- a/enum.c
+++ b/enum.c
@@ -33,11 +33,11 @@ grep_i(i, arg)
}
static VALUE
-grep_iter_i(i, pat)
- VALUE i, pat;
+grep_iter_i(i, arg)
+ VALUE i, *arg;
{
- if (RTEST(rb_funcall(pat, id_eqq, 1, i))) {
- rb_yield(i);
+ if (RTEST(rb_funcall(arg[0], id_eqq, 1, i))) {
+ rb_ary_push(arg[1], rb_yield(i));
}
return Qnil;
}
@@ -46,19 +46,16 @@ static VALUE
enum_grep(obj, pat)
VALUE obj, pat;
{
+ VALUE tmp, arg[2];
+
+ arg[0] = pat; arg[1] = tmp = rb_ary_new();
if (rb_iterator_p()) {
rb_iterate(rb_each, obj, grep_iter_i, pat);
- return obj;
}
else {
- VALUE tmp, arg[2];
-
- arg[0] = pat; arg[1] = tmp = rb_ary_new();
rb_iterate(rb_each, obj, grep_i, (VALUE)arg);
-
- if (RARRAY(tmp)->len == 0) return Qnil;
- return tmp;
}
+ return tmp;
}
struct find_arg {