From 6f484e4930be69c58462dd11c97663e6c8488b8e Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 3 Sep 2002 05:20:14 +0000 Subject: * variable.c (rb_copy_generic_ivar): remove old generic instance variable table if it existes. * class.c (rb_make_metaclass): metaclass of a metaclass is a metaclass itself. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/stringio/stringio.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'ext/stringio') diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index a6ba07307e..4f682b3a20 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -148,7 +148,7 @@ static VALUE strio_closed _((VALUE)); static VALUE strio_closed_read _((VALUE)); static VALUE strio_closed_write _((VALUE)); static VALUE strio_eof _((VALUE)); -static VALUE strio_clone _((VALUE)); +static VALUE strio_become _((VALUE, VALUE)); static VALUE strio_get_lineno _((VALUE)); static VALUE strio_set_lineno _((VALUE, VALUE)); static VALUE strio_get_pos _((VALUE)); @@ -405,14 +405,17 @@ strio_eof(self) } static VALUE -strio_clone(self) - VALUE self; +strio_become(copy, orig) + VALUE copy, orig; { - struct StringIO *ptr = StringIO(self); - VALUE clone = rb_call_super(0, 0); - DATA_PTR(clone) = ptr; + struct StringIO *ptr = StringIO(orig); + + if (DATA_PTR(copy)) { + strio_free(DATA_PTR(ptr)); + } + DATA_PTR(copy) = ptr; ++ptr->count; - return self; + return copy; } static VALUE @@ -883,8 +886,7 @@ Init_stringio() rb_define_singleton_method(StringIO, "open", strio_s_open, -1); rb_define_method(StringIO, "initialize", strio_initialize, -1); rb_enable_super(StringIO, "initialize"); - rb_define_method(StringIO, "clone", strio_clone, 0); - rb_enable_super(StringIO, "clone"); + rb_define_method(StringIO, "become", strio_become, 1); rb_define_method(StringIO, "reopen", strio_reopen, -1); rb_define_method(StringIO, "string", strio_get_string, 0); -- cgit v1.2.3