diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-11 14:29:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-11 14:29:46 +0000 |
commit | c06b78ca928f410d97b38a498b197471cd73f27b (patch) | |
tree | 8953fdd2e8c689022abb385c04a223b0f15f93ea /ext | |
parent | cc88d93a0ef39c3a8a89d2b2cde147f236be360c (diff) | |
download | ruby-c06b78ca928f410d97b38a498b197471cd73f27b.tar.gz |
* ext/stringio/stringio.c: keep holding string after closed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/stringio/stringio.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index db93c1ff89..55678f71d8 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -382,10 +382,9 @@ strio_close(self) VALUE self; { struct StringIO *ptr = StringIO(self); - if (CLOSED(ptr)) { + if (CLOSED(ptr) || !(ptr->flags & FMODE_READWRITE)) { rb_raise(rb_eIOError, "closed stream"); } - ptr->string = Qnil; ptr->flags &= ~FMODE_READWRITE; return Qnil; } @@ -405,9 +404,7 @@ strio_close_read(self) if (!READABLE(ptr)) { rb_raise(rb_eIOError, "closing non-duplex IO for reading"); } - if (!((ptr->flags &= ~FMODE_READABLE) & FMODE_READWRITE)) { - ptr->string = Qnil; - } + ptr->flags &= ~FMODE_READABLE; return Qnil; } @@ -426,9 +423,7 @@ strio_close_write(self) if (!WRITABLE(ptr)) { rb_raise(rb_eIOError, "closing non-duplex IO for writing"); } - if (!((ptr->flags &= ~FMODE_WRITABLE) & FMODE_READWRITE)) { - ptr->string = Qnil; - } + ptr->flags &= ~FMODE_WRITABLE; return Qnil; } |