mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (copy_stream_body): call rb_io_check_readable and
rb_io_check_writable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ffc456d0ed
commit
b1166a0469
3 changed files with 42 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Apr 21 19:08:32 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* io.c (copy_stream_body): call rb_io_check_readable and
|
||||||
|
rb_io_check_writable.
|
||||||
|
|
||||||
Mon Apr 21 17:45:27 2008 Akinori MUSHA <knu@iDaemons.org>
|
Mon Apr 21 17:45:27 2008 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
* ext/dbm/dbm.c (fdbm_each_value, fdbm_each_key, fdbm_each_pair):
|
* ext/dbm/dbm.c (fdbm_each_value, fdbm_each_key, fdbm_each_pair):
|
||||||
|
|
2
io.c
2
io.c
|
@ -6628,6 +6628,7 @@ copy_stream_body(VALUE arg)
|
||||||
stp->close_src = 1;
|
stp->close_src = 1;
|
||||||
}
|
}
|
||||||
GetOpenFile(src_io, src_fptr);
|
GetOpenFile(src_io, src_fptr);
|
||||||
|
rb_io_check_readable(src_fptr);
|
||||||
src_fd = src_fptr->fd;
|
src_fd = src_fptr->fd;
|
||||||
}
|
}
|
||||||
stp->src_fd = src_fd;
|
stp->src_fd = src_fd;
|
||||||
|
@ -6660,6 +6661,7 @@ copy_stream_body(VALUE arg)
|
||||||
stp->dst = dst_io;
|
stp->dst = dst_io;
|
||||||
}
|
}
|
||||||
GetOpenFile(dst_io, dst_fptr);
|
GetOpenFile(dst_io, dst_fptr);
|
||||||
|
rb_io_check_writable(dst_fptr);
|
||||||
dst_fd = dst_fptr->fd;
|
dst_fd = dst_fptr->fd;
|
||||||
}
|
}
|
||||||
stp->dst_fd = dst_fd;
|
stp->dst_fd = dst_fd;
|
||||||
|
|
|
@ -237,7 +237,6 @@ class TestIO < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bigcontent = "abc" * 123456
|
bigcontent = "abc" * 123456
|
||||||
File.open("bigsrc", "w") {|f| f << bigcontent }
|
File.open("bigsrc", "w") {|f| f << bigcontent }
|
||||||
ret = IO.copy_stream("bigsrc", "bigdst")
|
ret = IO.copy_stream("bigsrc", "bigdst")
|
||||||
|
@ -511,4 +510,39 @@ class TestIO < Test::Unit::TestCase
|
||||||
assert_equal("bcd", sio.string)
|
assert_equal("bcd", sio.string)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_copy_stream_src_wbuf
|
||||||
|
mkcdtmpdir {|d|
|
||||||
|
with_pipe {|r, w|
|
||||||
|
File.open("foe", "w+") {|f|
|
||||||
|
f.write "abcd\n"
|
||||||
|
f.rewind
|
||||||
|
f.write "xy"
|
||||||
|
IO.copy_stream(f, w)
|
||||||
|
}
|
||||||
|
assert_equal("xycd\n", File.read("foe"))
|
||||||
|
w.close
|
||||||
|
assert_equal("cd\n", r.read)
|
||||||
|
r.close
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_copy_stream_dst_rbuf
|
||||||
|
mkcdtmpdir {|d|
|
||||||
|
with_pipe {|r, w|
|
||||||
|
w << "xyz"
|
||||||
|
w.close
|
||||||
|
File.open("fom", "w+") {|f|
|
||||||
|
f.write "abcd\n"
|
||||||
|
f.rewind
|
||||||
|
assert_equal("abc", f.read(3))
|
||||||
|
f.ungetc "c"
|
||||||
|
IO.copy_stream(r, f)
|
||||||
|
}
|
||||||
|
assert_equal("abxyz", File.read("fom"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue