summaryrefslogtreecommitdiff
path: root/enumerator.c
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-24 06:23:07 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-24 06:23:07 +0000
commitbcbeb5d008c1e91454b7f2c2d0e1d7b4735006e2 (patch)
tree986e4943ead7213784247920eacd19c1cf1fb3f4 /enumerator.c
parentde0e88763561e4a5ee6be87dd6eee524ccf9c391 (diff)
* enumerator.c: Fix state handling for Lazy#drop_while
[bug #7696] [bug #7691] * test/ruby/test_lazy_enumerator.rb: test for above git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enumerator.c')
-rw-r--r--enumerator.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/enumerator.c b/enumerator.c
index 1522a3f..769d940 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -1754,12 +1754,11 @@ lazy_drop(VALUE obj, VALUE n)
static VALUE
lazy_drop_while_func(VALUE val, VALUE args, int argc, VALUE *argv)
{
- NODE *memo = RNODE(args);
-
- if (!memo->u3.state && !RTEST(rb_yield_values2(argc - 1, &argv[1]))) {
- memo->u3.state = TRUE;
+ VALUE memo = rb_ivar_get(argv[0], id_memo);
+ if (NIL_P(memo) && !RTEST(rb_yield_values2(argc - 1, &argv[1]))) {
+ rb_ivar_set(argv[0], id_memo, memo = Qtrue);
}
- if (memo->u3.state) {
+ if (memo == Qtrue) {
rb_funcall2(argv[0], id_yield, argc - 1, argv + 1);
}
return Qnil;
@@ -1768,14 +1767,11 @@ lazy_drop_while_func(VALUE val, VALUE args, int argc, VALUE *argv)
static VALUE
lazy_drop_while(VALUE obj)
{
- NODE *memo;
-
if (!rb_block_given_p()) {
rb_raise(rb_eArgError, "tried to call lazy drop_while without a block");
}
- memo = NEW_MEMO(0, 0, FALSE);
return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj,
- lazy_drop_while_func, (VALUE) memo),
+ lazy_drop_while_func, 0),
Qnil, 0);
}