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

This commit is contained in:
Yukihiro "Matz" Matsumoto
2020-04-28 12:03:32 +09:00
committed by Hiroshi Mimaki
parent d029549c2f
commit b3c5d94bd1
+2 -2
View File
@@ -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