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

ruby-changes:11229

From: shyouhei <ko1@a...>
Date: Mon, 9 Mar 2009 09:55:11 +0900 (JST)
Subject: [ruby-changes:11229] Ruby:r22838 (ruby_1_8_7): merge revision(s) 21913:

shyouhei	2009-03-09 09:55:01 +0900 (Mon, 09 Mar 2009)

  New Revision: 22838

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

  Log:
    merge revision(s) 21913:
    * io.c (io_getpartial): fflush after read for updating pos in FILE.
      not portable, I guess.  [ruby-core:21561]

  Modified files:
    branches/ruby_1_8_7/ChangeLog
    branches/ruby_1_8_7/io.c
    branches/ruby_1_8_7/test/ruby/test_io.rb
    branches/ruby_1_8_7/version.h

Index: ruby_1_8_7/ChangeLog
===================================================================
--- ruby_1_8_7/ChangeLog	(revision 22837)
+++ ruby_1_8_7/ChangeLog	(revision 22838)
@@ -1,3 +1,8 @@
+Mon Mar  9 09:52:53 2009  Tanaka Akira  <akr@f...>
+
+	* io.c (io_getpartial): fflush after read for updating pos in FILE.
+	  not portable, I guess.  [ruby-core:21561]
+
 Mon Mar  9 09:04:39 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* gc.c (define_final): cannot define finalizer for immediate
Index: ruby_1_8_7/version.h
===================================================================
--- ruby_1_8_7/version.h	(revision 22837)
+++ ruby_1_8_7/version.h	(revision 22838)
@@ -2,7 +2,7 @@
 #define RUBY_RELEASE_DATE "2009-03-09"
 #define RUBY_VERSION_CODE 187
 #define RUBY_RELEASE_CODE 20090309
-#define RUBY_PATCHLEVEL 146
+#define RUBY_PATCHLEVEL 147
 
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 8
Index: ruby_1_8_7/io.c
===================================================================
--- ruby_1_8_7/io.c	(revision 22837)
+++ ruby_1_8_7/io.c	(revision 22838)
@@ -1283,6 +1283,8 @@
                 goto again;
             rb_sys_fail(fptr->path);
         }
+        if (fptr->f) /* update pos in FILE structure [ruby-core:21561] */
+            fflush(fptr->f);
     }
     rb_str_resize(str, n);
 
Index: ruby_1_8_7/test/ruby/test_io.rb
===================================================================
--- ruby_1_8_7/test/ruby/test_io.rb	(revision 22837)
+++ ruby_1_8_7/test/ruby/test_io.rb	(revision 22838)
@@ -1,6 +1,15 @@
 require 'test/unit'
+require 'tmpdir'
 
 class TestIO < Test::Unit::TestCase
+  def mkcdtmpdir
+    Dir.mktmpdir {|d|
+      Dir.chdir(d) {
+        yield
+      }
+    }
+  end
+
   def test_gets_rs
     r, w = IO.pipe
     w.print "\377xyz"
@@ -8,4 +17,15 @@
     assert_equal("\377", r.gets("\377"), "[ruby-dev:24460]")
     r.close
   end
+
+  def test_readpartial_pos
+    mkcdtmpdir {
+      open("foo", "w") {|f| f << "abc" }
+      open("foo") {|f|
+        f.seek(0)
+        assert_equal("ab", f.readpartial(2))
+        assert_equal(2, f.pos)
+      }
+    }
+  end
 end

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

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