- Fix incorrect errno returned by IO::write.

Reported by:	John-Paul Bader <contact@smyck.org>
Obtained from:	ruby svn (revision r26253)
This commit is contained in:
Stanislav Sedov 2010-04-28 23:59:55 +00:00
parent 44b546fe8c
commit 8649bd09e5
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=253400
2 changed files with 24 additions and 1 deletions

View File

@ -170,7 +170,7 @@ RUBY?= ${LOCALBASE}/bin/${RUBY_NAME}
# Ruby 1.8
#
RUBY_RELVERSION= 1.8.7
RUBY_PORTREVISION= 1
RUBY_PORTREVISION= 2
RUBY_PORTEPOCH= 1
RUBY_PATCHLEVEL= 248

View File

@ -0,0 +1,23 @@
Index: io.c
===================================================================
--- io.c (revision 26252)
+++ io.c (revision 26253)
@@ -122,6 +122,9 @@
# 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;
@@ -490,7 +493,7 @@
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) {