diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-10 08:16:14 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-10 08:16:14 +0000 |
commit | 6395c3b38de70621232102597ee24c1fd136ca1b (patch) | |
tree | a4f670542fc90a24e839ec1a058cad23da6948c7 | |
parent | d6ce2b7b2b4dfb1c1e135138714c5fac48f50a3e (diff) |
* ext/stringio/stringio.c (strio_read): adjust behavior at reading
beyond EOF to IO. [ruby-dev:22205]
* test/ruby/ut_eof.rb (TestEOF::Seek): test behaviors at reading
beyond EOF.
* test/ruby/test_file.rb, * test/stringio/test_stringio.rb:
include TestEOF::Seek test case.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 23 | ||||
-rw-r--r-- | ext/stringio/stringio.c | 1 | ||||
-rw-r--r-- | test/ruby/test_file.rb | 2 | ||||
-rw-r--r-- | test/ruby/ut_eof.rb | 27 | ||||
-rw-r--r-- | test/stringio/test_stringio.rb | 2 |
5 files changed, 49 insertions, 6 deletions
@@ -1,7 +1,18 @@ +Wed Dec 10 17:16:06 2003 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * ext/stringio/stringio.c (strio_read): adjust behavior at reading + beyond EOF to IO. [ruby-dev:22205] + + * test/ruby/ut_eof.rb (TestEOF::Seek): test behaviors at reading + beyond EOF. + + * test/ruby/test_file.rb, * test/stringio/test_stringio.rb: + include TestEOF::Seek test case. + Wed Dec 10 15:01:19 2003 Shugo Maeda <shugo@ruby-lang.org> * test/monitor/test_monitor.rb (test_cond): use Queue#deq - insteadof sleep. + instead of sleep. Wed Dec 10 14:45:39 2003 WATANABE Hirofumi <eban@ruby-lang.org> @@ -20,12 +31,12 @@ Wed Dec 10 12:53:05 2003 WATANABE Hirofumi <eban@ruby-lang.org> Tue Dec 9 23:32:23 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> - * ext/tk/lib/tk.rb, ext/tk/lib/tkcanvas.rb, ext/tk/lib/tkdialog.rb, - ext/tk/lib/tkentry.rb, ext/tk/lib/tkscrollbox.rb, ext/tk/lib/tktext.rb, - ext/tk/sample/tkalignbox.rb, ext/tk/sample/tkcombobox.rb, + * ext/tk/lib/tk.rb, ext/tk/lib/tkcanvas.rb, ext/tk/lib/tkdialog.rb, + ext/tk/lib/tkentry.rb, ext/tk/lib/tkscrollbox.rb, ext/tk/lib/tktext.rb, + ext/tk/sample/tkalignbox.rb, ext/tk/sample/tkcombobox.rb, ext/tk/sample/tkmultilistbox.rb, ext/tk/sample/tkoptdb.rb, ext/tk/sample/tktextframe.rb, - ext/tk/sample/demos-en/dialog1.rb, ext/tk/sample/demos-en/dialog2.rb, - ext/tk/sample/demos-jp/dialog1.rb, ext/tk/sample/demos-jp/dialog2.rb: + ext/tk/sample/demos-en/dialog1.rb, ext/tk/sample/demos-en/dialog2.rb, + ext/tk/sample/demos-jp/dialog1.rb, ext/tk/sample/demos-jp/dialog2.rb: overrided instance methods, which are private methods on the super class, are changed to 'private' diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 725b5be192..f94c860728 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -867,6 +867,7 @@ strio_read(argc, argv, self) } str = rb_str_substr(ptr->string, ptr->pos, len); if (NIL_P(str)) { + if (!(ptr->flags & STRIO_EOF)) str = rb_str_new(0, 0); ptr->flags |= STRIO_EOF; } else { diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb index 3cf90f7101..b35a2661c9 100644 --- a/test/ruby/test_file.rb +++ b/test/ruby/test_file.rb @@ -41,4 +41,6 @@ class TestFile < Test::Unit::TestCase yield f end alias open_file_rw open_file + + include TestEOF::Seek end diff --git a/test/ruby/ut_eof.rb b/test/ruby/ut_eof.rb index f1ce4f7198..ffd9ba65ab 100644 --- a/test/ruby/ut_eof.rb +++ b/test/ruby/ut_eof.rb @@ -53,4 +53,31 @@ module TestEOF assert_equal(nil, f.read(1)) } end + + module Seek + def open_file_seek(content, pos) + open_file(content) do |f| + f.seek(pos) + yield f + end + end + + def test_eof_0_seek + open_file_seek("", 10) {|f| + assert_equal("", f.read) + assert_equal(nil, f.read) + } + end + + def test_eof_1_seek + open_file_seek("a", 10) {|f| + assert_equal("", f.read) + assert_equal(nil, f.read) + } + open_file_seek("a", 1) {|f| + assert_equal("", f.read) + assert_equal(nil, f.read) + } + end + end end diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb index e16bd0e37b..a62fa491b8 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -12,4 +12,6 @@ class TestStringIO < Test::Unit::TestCase yield f end alias open_file_rw open_file + + include TestEOF::Seek end |