[前][次][番号順一覧][スレッド一覧]

ruby-changes:12444

From: nobu <ko1@a...>
Date: Thu, 16 Jul 2009 16:00:39 +0900 (JST)
Subject: [ruby-changes:12444] Ruby:r24144 (trunk): * io.c (io_reopen): discards read buffer.

nobu	2009-07-16 16:00:23 +0900 (Thu, 16 Jul 2009)

  New Revision: 24144

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24144

  Log:
    * io.c (io_reopen): discards read buffer.  [ruby-core:24240]

  Modified files:
    trunk/io.c
    trunk/test/ruby/test_io.rb

Index: io.c
===================================================================
--- io.c	(revision 24143)
+++ io.c	(revision 24144)
@@ -5648,6 +5648,9 @@
         if (io_fflush(fptr) < 0)
             rb_sys_fail(0);
     }
+    else {
+	io_tell(fptr);
+    }
 
     /* copy rb_io_t structure */
     fptr->mode = orig->mode | (fptr->mode & FMODE_PREP);
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 24143)
+++ test/ruby/test_io.rb	(revision 24144)
@@ -1270,6 +1270,16 @@
         assert_equal("foo\n", f.gets)
       }
     end
+
+    open(__FILE__) do |f|
+      f.gets
+      f2 = open(t.path)
+      f2.gets
+      assert_nothing_raised {
+        f.reopen(f2)
+        assert_equal("bar\n", f.gets, '[ruby-core:24240]')
+      }
+    end
   end
 
   def test_foreach

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]