Project

General

Profile

Actions

Bug #2696

closed

rubyspec: StringIO#ungetc when passed [char] pads with \000 when the current position is after the end ERROR

Added by mame (Yusuke Endoh) over 15 years ago. Updated over 14 years ago.

Status:
Closed
Target version:
-
ruby -v:
nil
Backport:
[ruby-dev:40271]

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
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0