summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-26 03:06:29 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-26 03:06:29 +0000
commitce4e9dff9b79af947bb19bbe96c4b842bffd4611 (patch)
treeaeabf156cee13595eccb86091f31f6fa1eb29e8d /io.c
parentbc078709a5effaee9dfc6a0e50a2c16a457d48d4 (diff)
* 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@25485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/io.c b/io.c
index d45d448e1b..d136c76cf6 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
@@ -481,6 +489,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;