mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-io: fix IO#ungetbyte; ref #5389
- remove `Integer#chr` (thus `mruby-sting-ext`) dependency - fix the behavior when `c.is_a? String` - fix the behavior when `c > 255`
This commit is contained in:
@@ -184,9 +184,15 @@ class IO
|
||||
nil
|
||||
end
|
||||
|
||||
def ungetbyte(substr)
|
||||
substr = substr.chr if substr.is_a? Integer
|
||||
ungetc substr
|
||||
def ungetbyte(c)
|
||||
if c.is_a? String
|
||||
c = c.getbyte(0)
|
||||
else
|
||||
c &= 0xff
|
||||
end
|
||||
s = " "
|
||||
s.setbyte(0,c)
|
||||
ungetc s
|
||||
end
|
||||
|
||||
def read(length = nil, outbuf = "")
|
||||
|
||||
Reference in New Issue
Block a user