summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authordearblue <[email protected]>2019-09-15 22:31:59 +0900
committerdearblue <[email protected]>2019-09-16 00:11:43 +0900
commit77368ce762b7a0e332580cd091fbe063ad2702c1 (patch)
treef000745d87f5cc18d706655066a329aaf78fbeee
parent0734d9f314c5014685f7af7d9b47d850317cd532 (diff)
downloadmruby-77368ce762b7a0e332580cd091fbe063ad2702c1.tar.gz
mruby-77368ce762b7a0e332580cd091fbe063ad2702c1.zip
Revert part of 8c90b5fc6
`IO#readline` and `IO#readchar` process in character units.
-rw-r--r--mrbgems/mruby-io/mrblib/io.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/mrbgems/mruby-io/mrblib/io.rb b/mrbgems/mruby-io/mrblib/io.rb
index aaf22da2e..3f5216fcb 100644
--- a/mrbgems/mruby-io/mrblib/io.rb
+++ b/mrbgems/mruby-io/mrblib/io.rb
@@ -253,12 +253,14 @@ class IO
break
end
- if limit && limit <= @buf.bytesize
- array.push IO._bufread(@buf, limit)
+ if limit && limit <= @buf.size
+ array.push @buf[0, limit]
+ @buf = @buf[limit, @buf.size - limit]
break
elsif idx = @buf.index(rs)
- len = idx + rs.bytesize
- array.push IO._bufread(@buf, len)
+ len = idx + rs.size
+ array.push @buf[0, len]
+ @buf = @buf[len, @buf.size - len]
break
else
array.push @buf
@@ -281,7 +283,9 @@ class IO
def readchar
_read_buf
- IO._bufread(@buf, 1)
+ c = @buf[0]
+ @buf = @buf[1, @buf.size]
+ c
end
def getc