ruby-changes:10370
From: akr <ko1@a...>
Date: Sat, 31 Jan 2009 16:07:34 +0900 (JST)
Subject: [ruby-changes:10370] Ruby:r21913 (ruby_1_8): * io.c (io_getpartial): fflush after read for updating pos in FILE.
akr 2009-01-31 16:07:21 +0900 (Sat, 31 Jan 2009) New Revision: 21913 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21913 Log: * io.c (io_getpartial): fflush after read for updating pos in FILE. not portable, I guess. [ruby-core:21561] Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/io.c branches/ruby_1_8/test/ruby/test_io.rb Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 21912) +++ ruby_1_8/ChangeLog (revision 21913) @@ -1,3 +1,8 @@ +Sat Jan 31 16:04:38 2009 Tanaka Akira <akr@f...> + + * io.c (io_getpartial): fflush after read for updating pos in FILE. + not portable, I guess. [ruby-core:21561] + Fri Jan 30 15:41:51 2009 Akinori MUSHA <knu@i...> * proc.c (Init_Proc): add '===' operator to use procs in when Index: ruby_1_8/io.c =================================================================== --- ruby_1_8/io.c (revision 21912) +++ ruby_1_8/io.c (revision 21913) @@ -1285,6 +1285,8 @@ goto again; rb_sys_fail(fptr->path); } + if (fptr->f) /* update pos in FILE structure [ruby-core:21561] */ + fflush(fptr->f); } rb_str_resize(str, n); Index: ruby_1_8/test/ruby/test_io.rb =================================================================== --- ruby_1_8/test/ruby/test_io.rb (revision 21912) +++ ruby_1_8/test/ruby/test_io.rb (revision 21913) @@ -1,6 +1,15 @@ require 'test/unit' +require 'tmpdir' class TestIO < Test::Unit::TestCase + def mkcdtmpdir + Dir.mktmpdir {|d| + Dir.chdir(d) { + yield + } + } + end + def test_gets_rs r, w = IO.pipe w.print "\377xyz" @@ -8,4 +17,15 @@ assert_equal("\377", r.gets("\377"), "[ruby-dev:24460]") r.close end + + def test_readpartial_pos + mkcdtmpdir { + open("foo", "w") {|f| f << "abc" } + open("foo") {|f| + f.seek(0) + assert_equal("ab", f.readpartial(2)) + assert_equal(2, f.pos) + } + } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/