Project

General

Profile

Actions

Bug #701

closed

Wrong behaviour of StringIO#ungetc

Added by eao197 (Yauheni Akhotnikau) over 15 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
ruby -v:
Backport:
[ruby-core:19632]

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

Actions #1

Updated by matz (Yukihiro Matsumoto) over 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r20150.
=end

Actions

Also available in: Atom PDF

Like0
Like0