ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:25451] [Bug #2057] Strange behavior IO#ungetc at the beginning of the stream
@ 2009-09-07  6:06 Yuki Sonoda
  0 siblings, 0 replies; only message in thread
From: Yuki Sonoda @ 2009-09-07  6:06 UTC (permalink / raw
  To: ruby-core

Bug #2057: Strange behavior IO#ungetc at the beginning of the stream
http://redmine.ruby-lang.org/issues/show/2057

Author: Yuki Sonoda
Status: Open, Priority: Normal
ruby -v: ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]

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.


----------------------------------------
http://redmine.ruby-lang.org

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-09-07  6:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-07  6:06 [ruby-core:25451] [Bug #2057] Strange behavior IO#ungetc at the beginning of the stream Yuki Sonoda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).