Actions
Bug #684
closedio.read(nil, buf) で buf が変更されない
ruby -v:
Backport:
Description
=begin
IO#read の第一引数に nil、第二引数に出力バッファ用の文字列を指定した場合
出力バッファが変更されません。
$ ruby -ve '
r, w = IO.pipe
w.print "a"
w.close
buf = "x"
p r.read(nil, buf)
p buf
'
ruby 1.9.0 (2008-10-26 revision 19941) [i386-mingw32]
"a"
"x"
このような感じでどうでしょうか。
Index: io.c¶
--- io.c (revision 19941)
+++ io.c (working copy)
@@ -1556,7 +1556,12 @@
int cr;
if (NEED_READCONV(fptr)) {
-
VALUE str = rb_str_new(NULL, 0);
-
if (NIL_P(str)) {
-
str = rb_str_new(NULL, 0);
-
}
-
else {
-
rb_str_resize(str, 0);
-
} make_readconv(fptr); while (1) { if (fptr->cbuf_len) {
=end
Actions
Like0
Like0