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

parent 2c321541
...@@ -182,9 +182,9 @@ class IO ...@@ -182,9 +182,9 @@ class IO
def ungetc(substr) def ungetc(substr)
raise TypeError.new "expect String, got #{substr.class}" unless substr.is_a?(String) raise TypeError.new "expect String, got #{substr.class}" unless substr.is_a?(String)
if @buf.empty? if @buf.empty?
@buf = substr.dup @buf.replace(substr)
else else
@buf = substr + @buf @buf[0,0] = substr
end end
nil nil
end 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