Bug #701
closedWrong behaviour of StringIO#ungetc
Description
=begin
This is the behaviour of StringIO#ungetc from Ruby 1.8.7:
irb(main):001:0> require 'stringio'
=> true
irb(main):002:0> a=StringIO.new('abcd')
=> #StringIO:0x2ba7e24
irb(main):003:0> a.getc;a.getc;a.getc;a.tell # Read 'a','b','c'. Current position is on 'd'.
=> 3
irb(main):004:0> a.ungetc(?#)
=> nil
irb(main):005:0> a.tell
=> 2
irb(main):006:0> a.string
=> "ab#d"
irb(main):007:0>
And this is from Ruby 1.9.1 (Win32 version):
irb(main):001:0> require 'stringio'
=> true
irb(main):002:0> a=StringIO.new('abcd')
=> #StringIO:0xe0388c
irb(main):003:0> a.getc; a.getc; a.getc; a.tell
=> 3
irb(main):004:0> a.ungetc('#')
=> nil
irb(main):005:0> a.tell
=> 1
irb(main):006:0> a.string
=> "a#cd"
a.ungetc should replace 'c' to '#', but not 'b'.
=end