Bug #684: io.read(nil, buf) e$B$Ge(B buf e$B$,JQ99$5$l$J$$e(B
http://redmine.ruby-lang.org/issues/show/684
e$B5/I<<Te(B: _ wanabe
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
IO#read e$B$NBh0l0z?t$Ke(B
nile$B!"BhFs0z?t$K=PNO%P%C%U%!MQ$NJ8;zNs$r;XDj$7$?>l9ge(B
e$B=PNO%P%C%U%!$,JQ99$5$l$^$;$s!#e(B
$ 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”
e$B$3$N$h$&$J46$8$G$I$&$G$7$g$&$+!#e(B
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) {