summaryrefslogtreecommitdiffstats
path: root/ext/stringio/stringio.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-05 02:54:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-05 02:54:48 +0000
commitbf625b1809e01a8fe505f5a344149e8df8e3795e (patch)
tree75d78dfa2134f18d318611d3ca7e3f74e417e5d9 /ext/stringio/stringio.c
parent513dbc6e6858cddf28418396fa7f1a7c652c1cb7 (diff)
downloadruby-bf625b1809e01a8fe505f5a344149e8df8e3795e.tar.gz
ruby-bf625b1809e01a8fe505f5a344149e8df8e3795e.tar.xz
ruby-bf625b1809e01a8fe505f5a344149e8df8e3795e.zip
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@5115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/stringio/stringio.c')
-rw-r--r--ext/stringio/stringio.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 0fb60069d..725b5be19 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;
}