* ext/stringio/stringio.c (strio_read): clear the buffer argument

when returning nil.  [ruby-dev:22363]

* test/ruby/ut_eof.rb (TestEOF::test_eof_0, TestEOF::test_eof_1):
  add buffer argument tests.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2003-12-24 05:23:32 +00:00
parent 73d77c8f57
commit 6fe8d987ce
3 changed files with 30 additions and 0 deletions

View File

@ -1,3 +1,11 @@
Wed Dec 24 14:23:27 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_read): clear the buffer argument
when returning nil. [ruby-dev:22363]
* test/ruby/ut_eof.rb (TestEOF::test_eof_0, TestEOF::test_eof_1):
add buffer argument tests.
Wed Dec 24 14:07:55 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/test/unit/assertions.rb: Modules are allowed to rescue.

View File

@ -851,9 +851,11 @@ strio_read(argc, argv, self)
}
if (len > 0 && ptr->pos >= RSTRING(ptr->string)->len) {
ptr->flags |= STRIO_EOF;
if (!NIL_P(str)) rb_str_resize(str, 0);
return Qnil;
}
else if (ptr->flags & STRIO_EOF) {
if (!NIL_P(str)) rb_str_resize(str, 0);
return Qnil;
}
break;

View File

@ -14,6 +14,16 @@ module TestEOF
assert_equal("", f.read)
assert_nil(f.read(1))
}
open_file("") {|f|
s = "x"
assert_equal("", f.read(nil, s))
assert_equal("", s)
}
open_file("") {|f|
s = "x"
assert_nil(f.read(10, s))
assert_equal("", s)
}
end
def test_eof_0_rw
@ -61,6 +71,16 @@ module TestEOF
assert_equal("a", f.read)
assert_nil(f.read(0))
}
open_file("a") {|f|
s = "x"
assert_equal("a", f.read(nil, s))
assert_equal("a", s)
}
open_file("a") {|f|
s = "x"
assert_equal("a", f.read(10, s))
assert_equal("a", s)
}
end
module Seek