summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorksss <[email protected]>2017-06-12 09:32:56 +0900
committerksss <[email protected]>2017-06-12 09:43:02 +0900
commit1ebe1c8b1f11d1c2975c4370a4fd3c566132c9d7 (patch)
tree5bba4d25d7f2cf5b3649787b55958a717f9fdae8
parent3a73a5849388fe908af7131804f9fc7f55472651 (diff)
downloadmruby-1ebe1c8b1f11d1c2975c4370a4fd3c566132c9d7.tar.gz
mruby-1ebe1c8b1f11d1c2975c4370a4fd3c566132c9d7.zip
Support outbuf argument for IO#read
-rw-r--r--mrblib/io.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/mrblib/io.rb b/mrblib/io.rb
index 694fdb0c9..4262504f2 100644
--- a/mrblib/io.rb
+++ b/mrblib/io.rb
@@ -181,7 +181,7 @@ class IO
nil
end
- def read(length = nil)
+ def read(length = nil, outbuf = "")
unless length.nil?
unless length.is_a? Fixnum
raise TypeError.new "can't convert #{length.class} into Integer"
@@ -217,7 +217,12 @@ class IO
end
end
- array && array.join
+ if array.nil?
+ outbuf.replace("")
+ nil
+ else
+ outbuf.replace(array.join)
+ end
end
def readline(arg = $/, limit = nil)