mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (io_getpartial): fflush after read for updating pos in FILE.
not portable, I guess. [ruby-core:21561] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@21913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c23f894d30
commit
ad98dd2c24
3 changed files with 27 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Sat Jan 31 16:04:38 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* 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@iDaemons.org>
|
||||
|
||||
* proc.c (Init_Proc): add '===' operator to use procs in when
|
||||
|
|
2
io.c
2
io.c
|
@ -1285,6 +1285,8 @@ io_getpartial(int argc, VALUE *argv, VALUE io, int nonblock)
|
|||
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);
|
||||
|
||||
|
|
|
@ -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 @@ class TestIO < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue