mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/stringio/stringio.c (strio_set_string): reinitialize
properly. * ext/stringio/stringio.c (strio_become): added self-assign check and experimental auto-conversion to StringIO. * ext/stringio/stringio.c (strio_reopen): added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
73d4f4b0bb
commit
23fb79a290
2 changed files with 36 additions and 11 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Mon Sep 9 11:21:04 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* ext/stringio/stringio.c (strio_set_string): reinitialize
|
||||
properly.
|
||||
|
||||
* ext/stringio/stringio.c (strio_become): added self-assign check
|
||||
and experimental auto-conversion to StringIO.
|
||||
|
||||
* ext/stringio/stringio.c (strio_reopen): added.
|
||||
|
||||
|
||||
Sun Sep 8 21:29:25 2002 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||
|
||||
* time.c (time_free): prototype; struct time_object -> void *.
|
||||
|
|
|
@ -217,7 +217,7 @@ strio_initialize(argc, argv, self)
|
|||
StringValue(string);
|
||||
if (!(m = RSTRING(mode)->ptr)) m = "";
|
||||
ptr->flags = rb_io_mode_flags(m);
|
||||
if (ptr->flags & FMODE_WRITABLE && OBJ_FROZEN(string)) {
|
||||
if ((ptr->flags & FMODE_WRITABLE) && OBJ_FROZEN(string)) {
|
||||
errno = EACCES;
|
||||
rb_sys_fail(0);
|
||||
}
|
||||
|
@ -317,13 +317,13 @@ strio_set_string(self, string)
|
|||
{
|
||||
struct StringIO *ptr = StringIO(self);
|
||||
|
||||
if (NIL_P(string)) {
|
||||
ptr->flags &= ~FMODE_READWRITE;
|
||||
}
|
||||
else {
|
||||
ptr->flags &= ~FMODE_READWRITE;
|
||||
if (!NIL_P(string)) {
|
||||
StringValue(string);
|
||||
ptr->flags |= FMODE_READWRITE;
|
||||
ptr->flags = OBJ_FROZEN(string) ? FMODE_READABLE : FMODE_READWRITE;
|
||||
}
|
||||
ptr->pos = 0;
|
||||
ptr->lineno = 0;
|
||||
return ptr->string = string;
|
||||
}
|
||||
|
||||
|
@ -408,10 +408,13 @@ static VALUE
|
|||
strio_become(copy, orig)
|
||||
VALUE copy, orig;
|
||||
{
|
||||
struct StringIO *ptr = StringIO(orig);
|
||||
struct StringIO *ptr;
|
||||
|
||||
if (DATA_PTR(copy)) {
|
||||
strio_free(DATA_PTR(ptr));
|
||||
orig = rb_convert_type(orig, T_DATA, "StringIO", "to_strio");
|
||||
if (copy == orig) return copy;
|
||||
ptr = StringIO(orig);
|
||||
if (check_strio(copy)) {
|
||||
strio_free(DATA_PTR(copy));
|
||||
}
|
||||
DATA_PTR(copy) = ptr;
|
||||
++ptr->count;
|
||||
|
@ -435,14 +438,25 @@ strio_set_lineno(self, lineno)
|
|||
|
||||
#define strio_binmode strio_self
|
||||
|
||||
#define strio_reopen strio_unimpl
|
||||
|
||||
#define strio_fcntl strio_unimpl
|
||||
|
||||
#define strio_flush strio_self
|
||||
|
||||
#define strio_fsync strio_0
|
||||
|
||||
static VALUE
|
||||
strio_reopen(argc, argv, self)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE self;
|
||||
{
|
||||
rb_secure(4);
|
||||
if (argc == 1 && TYPE(*argv) != T_STRING) {
|
||||
return strio_become(self, *argv);
|
||||
}
|
||||
return strio_initialize(argc, argv, self);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
strio_get_pos(self)
|
||||
VALUE self;
|
||||
|
|
Loading…
Reference in a new issue