Project

General

Profile

Actions

Bug #684

closed

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

Added by wanabe (_ wanabe) over 15 years ago. Updated almost 13 years ago.

Status:
Closed
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

Actions #1

Updated by usa (Usaku NAKAMURA) over 15 years ago

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

=begin
r19943
=end

Actions

Also available in: Atom PDF

Like0
Like0