summaryrefslogtreecommitdiff
path: root/ext/stringio/stringio.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-03 05:20:14 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-03 05:20:14 +0000
commit6f484e4930be69c58462dd11c97663e6c8488b8e (patch)
tree324b1dbdf4149be943eb3cbff26ad7f377e53dc0 /ext/stringio/stringio.c
parent20254d4e133331e69e6aa7514e1e72ad7d14d496 (diff)
* 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
Diffstat (limited to 'ext/stringio/stringio.c')
-rw-r--r--ext/stringio/stringio.c20
1 files changed, 11 insertions, 9 deletions
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);