summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-25 08:45:13 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-25 08:45:13 +0000
commit08759d1f0abcd9829becff4178858ffd5dbc6c71 (patch)
tree8e4c63a0fafe6fc1c73ffe2c5700d72222cb2d4f
parent45c322bfdb3f6d38a006aef9ce3e4654db9bc8ed (diff)
merge revision(s) 25485:
* io.c (io_fwrite): adjust stdio file position after direct write on BSDish platforms. [ruby-core:26300] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@25918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--io.c11
-rw-r--r--test/ruby/test_io.rb15
-rw-r--r--version.h2
4 files changed, 32 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index c80512d3ee..064b2af1bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Nov 25 17:42:33 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (io_fwrite): adjust stdio file position after direct write on
+ BSDish platforms. [ruby-core:26300]
+
Wed Nov 25 17:39:28 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/ostruct/test_ostruct.rb (test_frozen): added assertions.
diff --git a/io.c b/io.c
index 1bdb5ec2c9..c3fb3e420d 100644
--- a/io.c
+++ b/io.c
@@ -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
@@ -479,6 +487,9 @@ io_fwrite(str, fptr)
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;
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index b5e9b8ec06..ce1d4c6668 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -45,4 +45,19 @@ class TestIO < Test::Unit::TestCase
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
diff --git a/version.h b/version.h
index b083535fe7..85084c60ff 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2009-11-25"
#define RUBY_VERSION_CODE 187
#define RUBY_RELEASE_CODE 20091125
-#define RUBY_PATCHLEVEL 224
+#define RUBY_PATCHLEVEL 225
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8