Update `IO#ungetc` to keep `@buf` string; ref #4982

parent 2c321541
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment