diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-01-25 22:52:38 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-01-25 22:52:38 +0000 |
commit | 369b098721cff440a9f962f30df869e5470a2675 (patch) | |
tree | 558a6ff2abfb9957d97ca62c4ae2e01ae7747394 /enumerator.c | |
parent | df7c570713e7f59537348bfa91a13d0111c81d93 (diff) | |
download | ruby-369b098721cff440a9f962f30df869e5470a2675.tar.gz |
* enumerator.c (enumerator_init_copy): need to copy internal
structure on clone and dup. [ruby-dev:30192]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enumerator.c')
-rw-r--r-- | enumerator.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/enumerator.c b/enumerator.c index 3f176a77a9..83cdff9c58 100644 --- a/enumerator.c +++ b/enumerator.c @@ -261,6 +261,21 @@ enumerator_initialize(int argc, VALUE *argv, VALUE obj) return enumerator_init(obj, recv, meth, argc, argv); } +/* :nodoc: */ +static VALUE +enumerator_init_copy(VALUE obj, VALUE orig) +{ + struct enumerator *ptr0 = enumerator_ptr(orig); + struct enumerator *ptr1 = enumerator_ptr(obj); + + ptr1->method = ptr0->method; + ptr1->proc = ptr0->proc; + ptr1->iter = ptr0->iter; + ptr1->args = ptr0->args; + + return obj; +} + VALUE rb_enumeratorize(VALUE obj, VALUE meth, int argc, VALUE *argv) { @@ -351,6 +366,7 @@ Init_Enumerator(void) rb_define_alloc_func(rb_cEnumerator, enumerator_allocate); rb_define_method(rb_cEnumerator, "initialize", enumerator_initialize, -1); + rb_define_method(rb_cEnumerator, "initialize_copy", enumerator_init_copy, 1); rb_define_method(rb_cEnumerator, "each", enumerator_each, 0); rb_define_method(rb_cEnumerator, "with_index", enumerator_with_index, 0); rb_define_method(rb_cEnumerator, "to_splat", enumerator_to_splat, 0); |