* 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
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>
|
Sun Sep 8 21:29:25 2002 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* time.c (time_free): prototype; struct time_object -> void *.
|
* time.c (time_free): prototype; struct time_object -> void *.
|
||||||
|
@ -217,7 +217,7 @@ strio_initialize(argc, argv, self)
|
|||||||
StringValue(string);
|
StringValue(string);
|
||||||
if (!(m = RSTRING(mode)->ptr)) m = "";
|
if (!(m = RSTRING(mode)->ptr)) m = "";
|
||||||
ptr->flags = rb_io_mode_flags(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;
|
errno = EACCES;
|
||||||
rb_sys_fail(0);
|
rb_sys_fail(0);
|
||||||
}
|
}
|
||||||
@ -317,13 +317,13 @@ strio_set_string(self, string)
|
|||||||
{
|
{
|
||||||
struct StringIO *ptr = StringIO(self);
|
struct StringIO *ptr = StringIO(self);
|
||||||
|
|
||||||
if (NIL_P(string)) {
|
ptr->flags &= ~FMODE_READWRITE;
|
||||||
ptr->flags &= ~FMODE_READWRITE;
|
if (!NIL_P(string)) {
|
||||||
}
|
|
||||||
else {
|
|
||||||
StringValue(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;
|
return ptr->string = string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,10 +408,13 @@ static VALUE
|
|||||||
strio_become(copy, orig)
|
strio_become(copy, orig)
|
||||||
VALUE copy, orig;
|
VALUE copy, orig;
|
||||||
{
|
{
|
||||||
struct StringIO *ptr = StringIO(orig);
|
struct StringIO *ptr;
|
||||||
|
|
||||||
if (DATA_PTR(copy)) {
|
orig = rb_convert_type(orig, T_DATA, "StringIO", "to_strio");
|
||||||
strio_free(DATA_PTR(ptr));
|
if (copy == orig) return copy;
|
||||||
|
ptr = StringIO(orig);
|
||||||
|
if (check_strio(copy)) {
|
||||||
|
strio_free(DATA_PTR(copy));
|
||||||
}
|
}
|
||||||
DATA_PTR(copy) = ptr;
|
DATA_PTR(copy) = ptr;
|
||||||
++ptr->count;
|
++ptr->count;
|
||||||
@ -435,14 +438,25 @@ strio_set_lineno(self, lineno)
|
|||||||
|
|
||||||
#define strio_binmode strio_self
|
#define strio_binmode strio_self
|
||||||
|
|
||||||
#define strio_reopen strio_unimpl
|
|
||||||
|
|
||||||
#define strio_fcntl strio_unimpl
|
#define strio_fcntl strio_unimpl
|
||||||
|
|
||||||
#define strio_flush strio_self
|
#define strio_flush strio_self
|
||||||
|
|
||||||
#define strio_fsync strio_0
|
#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
|
static VALUE
|
||||||
strio_get_pos(self)
|
strio_get_pos(self)
|
||||||
VALUE self;
|
VALUE self;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user