Project

General

Profile

Bug #684

io.read(nil, buf) で buf が変更されない

Added by wanabe (_ wanabe) over 10 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
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

History

#1

Updated by usa (Usaku NAKAMURA) over 10 years ago

  • Status changed from Open to Closed
  • Assignee set to nobu (Nobuyoshi Nakada)

=begin
r19943
=end

Also available in: Atom PDF