summaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog4
-rw-r--r--io.c5
-rw-r--r--test/ruby/test_pipe.rb14
-rw-r--r--version.h8
4 files changed, 26 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index aa3ff2655b..e1e5baaa5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu May 20 15:39:26 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (io_fwrite): preserve errno. [ruby-core:27425]
+
Tue Apr 20 08:04:37 2010 NAKAMURA Usaku <usa@ruby-lang.org>
* io.c (rb_io_s_read): close the IO if an exception is raised on
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) {
diff --git a/test/ruby/test_pipe.rb b/test/ruby/test_pipe.rb
index c3b4d29c0a..0ac921b9c2 100644
--- a/test/ruby/test_pipe.rb
+++ b/test/ruby/test_pipe.rb
@@ -15,4 +15,18 @@ class TestPipe < Test::Unit::TestCase
r.close
end
end
+
+ def test_write
+ bug2559 = '[ruby-core:27425]'
+ a, b = IO.pipe
+ begin
+ a.close
+ assert_raises(Errno::EPIPE, bug2559) do
+ b.write("hi")
+ end
+ ensure
+ a.close if !a.closed?
+ b.close if !b.closed?
+ end
+ end
end
diff --git a/version.h b/version.h
index 57a5368cc2..e37a14cec3 100644
--- a/version.h
+++ b/version.h
@@ -1,14 +1,14 @@
#define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2010-04-20"
+#define RUBY_RELEASE_DATE "2010-05-20"
#define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20100420
-#define RUBY_PATCHLEVEL 254
+#define RUBY_RELEASE_CODE 20100520
+#define RUBY_PATCHLEVEL 255
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 7
#define RUBY_RELEASE_YEAR 2010
-#define RUBY_RELEASE_MONTH 4
+#define RUBY_RELEASE_MONTH 5
#define RUBY_RELEASE_DAY 20
#ifdef RUBY_EXTERN