ruby-changes:13037
From: nobu <ko1@a...>
Date: Mon, 7 Sep 2009 17:29:49 +0900 (JST)
Subject: [ruby-changes:13037] Ruby:r24782 (trunk): * io.c (rb_io_tell): adjustment for ungotten data.
nobu 2009-09-07 17:23:00 +0900 (Mon, 07 Sep 2009) New Revision: 24782 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24782 Log: * io.c (rb_io_tell): adjustment for ungotten data. Modified files: trunk/ChangeLog trunk/io.c trunk/test/ruby/test_io.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 24781) +++ ChangeLog (revision 24782) @@ -1,3 +1,7 @@ +Mon Sep 7 17:22:59 2009 Nobuyoshi Nakada <nobu@r...> + + * io.c (rb_io_tell): adjustment for ungotten data. + Mon Sep 7 17:13:53 2009 Nobuyoshi Nakada <nobu@r...> * io.c (io_encname_bom_p): removed magic number. Index: io.c =================================================================== --- io.c (revision 24781) +++ io.c (revision 24782) @@ -1042,6 +1042,7 @@ GetOpenFile(io, fptr); pos = io_tell(fptr); if (pos < 0 && errno) rb_sys_fail_path(fptr->pathv); + pos -= fptr->rbuf_len; return OFFT2NUM(pos); } Index: test/ruby/test_io.rb =================================================================== --- test/ruby/test_io.rb (revision 24781) +++ test/ruby/test_io.rb (revision 24782) @@ -121,16 +121,22 @@ def test_ungetbyte t = make_tempfile t.open + t.binmode t.ungetbyte(0x41) + assert_equal(-1, t.pos) assert_equal(0x41, t.getbyte) t.rewind + assert_equal(0, t.pos) t.ungetbyte("qux") + assert_equal(-3, t.pos) assert_equal("quxfoo\n", t.gets) + assert_equal(4, t.pos) t.set_encoding("utf-8") t.ungetbyte(0x89) t.ungetbyte(0x8e) t.ungetbyte("\xe7") t.ungetbyte("\xe7\xb4\x85") + assert_equal(-2, t.pos) assert_equal("\u7d05\u7389bar\n", t.gets) end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/