diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-05 02:54:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-05 02:54:48 +0000 |
commit | 7fbf13f7f21876b4206701cb3913fab5e7d82843 (patch) | |
tree | 75d78dfa2134f18d318611d3ca7e3f74e417e5d9 /ext/stringio | |
parent | e3ed2691934d4f7e11b3d9469a7f744ac9e4b433 (diff) |
* ext/stringio/stringio.c (strio_read): follow IO#read.
* test/ruby/ut_eof.rb, test/ruby/test_file.rb, test/ruby/test_pipe.rb,
test/stringio/test_stringio.rb: add EOF test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/stringio')
-rw-r--r-- | ext/stringio/stringio.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 0fb60069de..725b5be192 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -866,10 +866,12 @@ strio_read(argc, argv, self) rb_raise(rb_eArgError, "wrong number arguments (%d for 0)", argc); } str = rb_str_substr(ptr->string, ptr->pos, len); - if (len > 0 && - (NIL_P(str) || (ptr->pos += RSTRING(str)->len) >= RSTRING(ptr->string)->len)) { + if (NIL_P(str)) { ptr->flags |= STRIO_EOF; } + else { + ptr->pos += RSTRING(str)->len; + } return str; } |