diff --git a/ChangeLog b/ChangeLog index 0c06c042b6..a3fe82cc53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,12 @@ +Sat Aug 13 18:35:27 2005 Nobuyoshi Nakada + + * ext/stringio/stringio.c (strio_set_string): disallow nil. + http://www.rubyist.net/~nobu/t/20050811.html#c05 + Sat Aug 13 08:01:59 2005 NARUSE, Yui - * ext/nkf/lib/kconv.rb: Kconv.kconv is now alias of Kconv.conv - * ext/nkf/lib/kconv.rb: remove nkf dependend symbols fomr SYMBOL_TO_OPTION + * ext/nkf/lib/kconv.rb: Kconv.kconv is now alias of Kconv.conv + * ext/nkf/lib/kconv.rb: remove nkf dependend symbols fomr SYMBOL_TO_OPTION Fri Aug 12 17:06:53 2005 Yukihiro Matsumoto diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 55678f71d8..60333a1ff9 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -96,9 +96,9 @@ get_strio(self) #define StringIO(obj) get_strio(obj) -#define CLOSED(ptr) NIL_P((ptr)->string) -#define READABLE(ptr) (!CLOSED(ptr) && ((ptr)->flags & FMODE_READABLE)) -#define WRITABLE(ptr) (!CLOSED(ptr) && ((ptr)->flags & FMODE_WRITABLE)) +#define CLOSED(ptr) (!((ptr)->flags & FMODE_READWRITE)) +#define READABLE(ptr) ((ptr)->flags & FMODE_READABLE) +#define WRITABLE(ptr) ((ptr)->flags & FMODE_WRITABLE) static struct StringIO* readable(ptr) @@ -361,10 +361,8 @@ strio_set_string(self, string) if (!OBJ_TAINTED(self)) rb_secure(4); ptr->flags &= ~FMODE_READWRITE; - if (!NIL_P(string)) { - StringValue(string); - ptr->flags = OBJ_FROZEN(string) ? FMODE_READABLE : FMODE_READWRITE; - } + StringValue(string); + ptr->flags = OBJ_FROZEN(string) ? FMODE_READABLE : FMODE_READWRITE; ptr->pos = 0; ptr->lineno = 0; return ptr->string = string; @@ -382,7 +380,7 @@ strio_close(self) VALUE self; { struct StringIO *ptr = StringIO(self); - if (CLOSED(ptr) || !(ptr->flags & FMODE_READWRITE)) { + if (CLOSED(ptr)) { rb_raise(rb_eIOError, "closed stream"); } ptr->flags &= ~FMODE_READWRITE;