summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-20 06:45:22 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-20 06:45:22 +0000
commit5988c787496e104d3552be02841c416f6006f4b6 (patch)
treefd5d1b4f17d12ae7a746490b2f537663c38ccd25 /io.c
parentd38975ac74a13fe1561851e1a193b86ea39a5a6d (diff)
merge revision(s) 26253:
* io.c (io_fwrite): preserve errno. [ruby-core:27425] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@27913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/io.c b/io.c
index e815c07c9f..1b5aa68c72 100644
--- a/io.c
+++ b/io.c
@@ -120,6 +120,9 @@ extern void Init_File _((void));
# endif
#endif
+#define preserving_errno(stmts) \
+ do {int saved_errno = errno; stmts; errno = saved_errno;} while (0)
+
VALUE rb_cIO;
VALUE rb_eEOFError;
VALUE rb_eIOError;
@@ -488,7 +491,7 @@ io_fwrite(str, fptr)
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);
+ preserving_errno(fseeko(f, lseek(fileno(f), (off_t)0, SEEK_CUR), SEEK_SET));
#endif
if (r == n) return len;
if (0 <= r) {