mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Update IO#ungetc to keep @buf string; ref #4982
This commit is contained in:
committed by
Hiroshi Mimaki
parent
d029549c2f
commit
b3c5d94bd1
@@ -182,9 +182,9 @@ class IO
|
||||
def ungetc(substr)
|
||||
raise TypeError.new "expect String, got #{substr.class}" unless substr.is_a?(String)
|
||||
if @buf.empty?
|
||||
@buf = substr.dup
|
||||
@buf.replace(substr)
|
||||
else
|
||||
@buf = substr + @buf
|
||||
@buf[0,0] = substr
|
||||
end
|
||||
nil
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user