Project

General

Profile

Actions

Backport #2057

closed

Strange behavior IO#ungetc at the beginning of the stream

Added by yugui (Yuki Sonoda) over 14 years ago. Updated almost 5 years ago.

Status:
Closed

Description

=begin
Issue cloned from #1909.

--
This works:
io = File.open("a.txt", "r+")
io.read(0)
p io.pos # => 0
io.ungetc(100)
p io.pos # => 0

while this doesn't:
io = File.open("a.txt", "r+")
p io.pos # => 0
io.ungetc(100) # => unread stream (IOError)

I would expect the first case to raise the same error as the second one since ungetc is supposed to shift the position back by 1 and we are at the beginning of the stream.

In ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mswin32] neither case raises an exception, which is at least consistent but still weird.
=end

Actions #1

Updated by ujihisa (Tatsuhiro Ujihisa) over 14 years ago

  • Status changed from Open to Assigned
  • Assignee set to nobu (Nobuyoshi Nakada)

=begin

=end

Actions #2

Updated by jeremyevans0 (Jeremy Evans) almost 5 years ago

  • ruby -v deleted (ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32])
  • Tracker changed from Bug to Backport
  • Project changed from Ruby 1.8 to Backport187
  • Description updated (diff)
  • Status changed from Assigned to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0