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

ruby-changes:13698

From: nobu <ko1@a...>
Date: Mon, 26 Oct 2009 12:06:49 +0900 (JST)
Subject: [ruby-changes:13698] Ruby:r25485 (trunk, ruby_1_8): * io.c (io_fwrite): adjust stdio file position after direct write on

nobu	2009-10-26 12:06:29 +0900 (Mon, 26 Oct 2009)

  New Revision: 25485

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

  Log:
    * io.c (io_fwrite): adjust stdio file position after direct write on
      BSDish platforms.   [ruby-core:26300]

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25484)
+++ ChangeLog	(revision 25485)
@@ -1,3 +1,8 @@
+Mon Oct 26 12:06:27 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* io.c (io_fwrite): adjust stdio file position after direct write on
+	  BSDish platforms.   [ruby-core:26300]
+
 Sun Oct 25 15:44:24 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/dl/handle.c (dlhandle_sym): fixed an invalid local variable
Index: version.h
===================================================================
--- version.h	(revision 25484)
+++ version.h	(revision 25485)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.2"
-#define RUBY_RELEASE_DATE "2009-10-25"
+#define RUBY_RELEASE_DATE "2009-10-26"
 #define RUBY_PATCHLEVEL -1
 #define RUBY_BRANCH_NAME "trunk"
 
@@ -8,7 +8,7 @@
 #define RUBY_VERSION_TEENY 1
 #define RUBY_RELEASE_YEAR 2009
 #define RUBY_RELEASE_MONTH 10
-#define RUBY_RELEASE_DAY 25
+#define RUBY_RELEASE_DAY 26
 
 #include "ruby/version.h"
 
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 25484)
+++ test/ruby/test_io.rb	(revision 25485)
@@ -1167,6 +1167,21 @@
     end
   end
 
+  def test_pos
+    t = make_tempfile
+
+    open(t.path, IO::RDWR|IO::CREAT|IO::TRUNC, 0600) do |f|
+      f.write "Hello"
+      assert_equal(5, f.pos)
+    end
+    open(t.path, IO::RDWR|IO::CREAT|IO::TRUNC, 0600) do |f|
+      f.sync = true
+      f.read
+      f.write "Hello"
+      assert_equal(5, f.pos)
+    end
+  end
+
   def test_sysseek
     t = make_tempfile
 
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 25484)
+++ ruby_1_8/ChangeLog	(revision 25485)
@@ -1,3 +1,8 @@
+Mon Oct 26 12:06:27 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* io.c (io_fwrite): adjust stdio file position after direct write on
+	  BSDish platforms.   [ruby-core:26300]
+
 Sun Oct 25 20:04:35 2009  Akinori MUSHA  <knu@i...>
 
 	* object.c (rb_class_initialize): The inherited hook should be run
Index: ruby_1_8/version.h
===================================================================
--- ruby_1_8/version.h	(revision 25484)
+++ ruby_1_8/version.h	(revision 25485)
@@ -1,7 +1,7 @@
 #define RUBY_VERSION "1.8.8"
-#define RUBY_RELEASE_DATE "2009-10-25"
+#define RUBY_RELEASE_DATE "2009-10-26"
 #define RUBY_VERSION_CODE 188
-#define RUBY_RELEASE_CODE 20091025
+#define RUBY_RELEASE_CODE 20091026
 #define RUBY_PATCHLEVEL -1
 
 #define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
 #define RUBY_VERSION_TEENY 8
 #define RUBY_RELEASE_YEAR 2009
 #define RUBY_RELEASE_MONTH 10
-#define RUBY_RELEASE_DAY 25
+#define RUBY_RELEASE_DAY 26
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];
Index: ruby_1_8/io.c
===================================================================
--- ruby_1_8/io.c	(revision 25484)
+++ ruby_1_8/io.c	(revision 25485)
@@ -37,6 +37,14 @@
 # define USE_SETVBUF
 #endif
 
+#ifndef BSD_STDIO
+# if defined(__MACH__) || defined(__DARWIN__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
+#   define BSD_STDIO 1
+# else
+#   define BSD_STDIO 0
+# endif
+#endif
+
 #ifdef __QNXNTO__
 #include "unix.h"
 #endif
@@ -481,6 +489,9 @@
         TRAP_BEG;
 	r = write(fileno(f), RSTRING(str)->ptr+offset, l);
         TRAP_END;
+#if BSD_STDIO
+	fseeko(f, lseek(fileno(f), (off_t)0, SEEK_CUR), SEEK_SET);
+#endif
         if (r == n) return len;
         if (0 <= r) {
             offset += r;
Index: ruby_1_8/test/ruby/test_io.rb
===================================================================
--- ruby_1_8/test/ruby/test_io.rb	(revision 25484)
+++ ruby_1_8/test/ruby/test_io.rb	(revision 25485)
@@ -34,4 +34,19 @@
     t.close
     assert_raise(IOError) {t.binmode}
   end
+
+  def test_pos
+    t = make_tempfile
+
+    open(t.path, IO::RDWR|IO::CREAT|IO::TRUNC, 0600) do |f|
+      f.write "Hello"
+      assert_equal(5, f.pos)
+    end
+    open(t.path, IO::RDWR|IO::CREAT|IO::TRUNC, 0600) do |f|
+      f.sync = true
+      f.read
+      f.write "Hello"
+      assert_equal(5, f.pos)
+    end
+  end
 end

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

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