ruby-changes:14104
From: shyouhei <ko1@a...>
Date: Wed, 25 Nov 2009 17:45:27 +0900 (JST)
Subject: [ruby-changes:14104] Ruby:r25918 (ruby_1_8_7): merge revision(s) 25485:
shyouhei 2009-11-25 17:45:13 +0900 (Wed, 25 Nov 2009) New Revision: 25918 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25918 Log: merge revision(s) 25485: * io.c (io_fwrite): adjust stdio file position after direct write on BSDish platforms. [ruby-core:26300] 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 25917) +++ ruby_1_8_7/ChangeLog (revision 25918) @@ -1,3 +1,8 @@ +Wed Nov 25 17:42:33 2009 Nobuyoshi Nakada <nobu@r...> + + * 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@r...> * test/ostruct/test_ostruct.rb (test_frozen): added assertions. Index: ruby_1_8_7/version.h =================================================================== --- ruby_1_8_7/version.h (revision 25917) +++ ruby_1_8_7/version.h (revision 25918) @@ -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 Index: ruby_1_8_7/io.c =================================================================== --- ruby_1_8_7/io.c (revision 25917) +++ ruby_1_8_7/io.c (revision 25918) @@ -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 @@ 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_7/test/ruby/test_io.rb =================================================================== --- ruby_1_8_7/test/ruby/test_io.rb (revision 25917) +++ ruby_1_8_7/test/ruby/test_io.rb (revision 25918) @@ -45,4 +45,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/