mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
io.c: copy_stream to duplex IO
* io.c (copy_stream_body): use IO to write to copy to duplex IO. http://twitter.com/knu/status/786505317974585344 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f087533b8b
commit
34d420acc4
3 changed files with 18 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Oct 13 19:41:32 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (copy_stream_body): use IO to write to copy to duplex IO.
|
||||||
|
http://twitter.com/knu/status/786505317974585344
|
||||||
|
|
||||||
Thu Oct 13 17:05:57 2016 Dwain Faithfull <dwfaithfull@gmail.com>
|
Thu Oct 13 17:05:57 2016 Dwain Faithfull <dwfaithfull@gmail.com>
|
||||||
|
|
||||||
* hash.c (rb_hash_compact, rb_hash_compact_bang): Removes nil
|
* hash.c (rb_hash_compact, rb_hash_compact_bang): Removes nil
|
||||||
|
|
2
io.c
2
io.c
|
@ -10657,7 +10657,7 @@ copy_stream_body(VALUE arg)
|
||||||
else {
|
else {
|
||||||
VALUE tmp_io = rb_io_check_io(dst_io);
|
VALUE tmp_io = rb_io_check_io(dst_io);
|
||||||
if (!NIL_P(tmp_io)) {
|
if (!NIL_P(tmp_io)) {
|
||||||
dst_io = tmp_io;
|
dst_io = GetWriteIO(tmp_io);
|
||||||
}
|
}
|
||||||
else if (!RB_TYPE_P(dst_io, T_FILE)) {
|
else if (!RB_TYPE_P(dst_io, T_FILE)) {
|
||||||
VALUE args[3];
|
VALUE args[3];
|
||||||
|
|
|
@ -1105,6 +1105,18 @@ class TestIO < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_copy_stream_to_duplex_io
|
||||||
|
result = IO.pipe {|a,w|
|
||||||
|
Thread.start {w.puts "yes"; w.close}
|
||||||
|
IO.popen([EnvUtil.rubybin, '-pe$_="#$.:#$_"'], "r+") {|b|
|
||||||
|
IO.copy_stream(a, b)
|
||||||
|
b.close_write
|
||||||
|
b.read
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert_equal("1:yes\n", result)
|
||||||
|
end
|
||||||
|
|
||||||
def ruby(*args)
|
def ruby(*args)
|
||||||
args = ['-e', '$>.write($<.read)'] if args.empty?
|
args = ['-e', '$>.write($<.read)'] if args.empty?
|
||||||
ruby = EnvUtil.rubybin
|
ruby = EnvUtil.rubybin
|
||||||
|
|
Loading…
Add table
Reference in a new issue