diff options
| author | Christopher Aue <[email protected]> | 2017-06-13 21:40:36 +0200 |
|---|---|---|
| committer | Christopher Aue <[email protected]> | 2017-06-13 21:40:36 +0200 |
| commit | 3642fe40131220520e961157fa501ee1adf2ebca (patch) | |
| tree | 29ca5c04ea47dbb9d9a777294fbfe417182f4cbe /mrblib | |
| parent | fe99819bc996891ea97c10446ca3e495c77d790f (diff) | |
| download | mruby-3642fe40131220520e961157fa501ee1adf2ebca.tar.gz mruby-3642fe40131220520e961157fa501ee1adf2ebca.zip | |
fixed #87: IO#read(n) with n > IO::BUF_SIZE
Diffstat (limited to 'mrblib')
| -rw-r--r-- | mrblib/io.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/mrblib/io.rb b/mrblib/io.rb index 3ea839379..f538af490 100644 --- a/mrblib/io.rb +++ b/mrblib/io.rb @@ -205,10 +205,12 @@ class IO break end - if length && length <= @buf.size - array.push @buf[0, length] - @buf = @buf[length, @buf.size - length] - break + if length + consume = (length <= @buf.size) ? length : @buf.size + array.push @buf[0, consume] + @buf = @buf[consume, @buf.size - consume] + length -= consume + break if length == 0 else array.push @buf @buf = '' |
