Actions
Bug #2696
closedrubyspec: StringIO#ungetc when passed [char] pads with \000 when the current position is after the end ERROR
Bug #2696:
rubyspec: StringIO#ungetc when passed [char] pads with \000 when the current position is after the end ERROR
Description
=begin
stringio のメンテナのなかださん、もしくはまつもとさん
遠藤です。
stringio に関して、バッファ終端より先に pos を合わせた状態で
StringIO#ungetc を呼んだ時の挙動が 1.8 と 1.9 で違います。
1.8 では間が \0 で埋められる¶
$ ruby18 -rstringio -e '
io = StringIO.new("1234")
io.pos = 15
io.ungetc(?A)
p io.string
'
"1234\000\000\000\000\000\000\000\000\000\000A"
1.9 では例外になる¶
$ ./ruby -rstringio -e '
io = StringIO.new("1234")
io.pos = 15
io.ungetc(?A)
p io.string
'
-e:4:in ungetc': index 14 out of string (IndexError) from -e:4:in '
r13261 が原因のようです。この挙動の変更を狙ったものではない
ような気がしますが、いかがでしょうか。
--
Yusuke ENDOH mame@tsg.ne.jp
=end
Actions