summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-17 06:44:28 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-17 06:44:28 +0000
commitd9abe0513d913b1eb6e149ad9f610a694385e226 (patch)
treea4841882d0c7df6889c3559522ee2c0b6037b716
parentcfa3a72cc260edfc307d0abb405a70093a6c3127 (diff)
merge revision(s) 24751:
* io.c (rb_io_binmode): check if closed regardless platforms. [ruby-core:25363] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@25812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--io.c4
-rw-r--r--test/ruby/test_io.rb17
-rw-r--r--version.h2
4 files changed, 25 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 50e909d9f4..eb4a1f578e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Nov 17 15:32:27 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (rb_io_binmode): check if closed regardless platforms.
+ [ruby-core:25363]
+
Tue Nov 17 15:31:09 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (round): added declaration. [ruby-dev:39222]
diff --git a/io.c b/io.c
index a47bfc5170..b295d102ad 100644
--- a/io.c
+++ b/io.c
@@ -2696,11 +2696,11 @@ VALUE
rb_io_binmode(io)
VALUE io;
{
-#if defined(_WIN32) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__) || defined(__EMX__)
rb_io_t *fptr;
GetOpenFile(io, fptr);
-#ifdef __human68k__
+#if (defined(O_BINARY) && O_BINARY) || (defined(_IOBIN) && _IOBIN)
+#if (defined(_IOBIN) && _IOBIN) /* __human68k__ */
if (fptr->f)
fmode(fptr->f, _IOBIN);
if (fptr->f2)
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 19b4f0ebf6..b5e9b8ec06 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1,5 +1,6 @@
require 'test/unit'
require 'tmpdir'
+require 'tempfile'
class TestIO < Test::Unit::TestCase
def mkcdtmpdir
@@ -28,4 +29,20 @@ class TestIO < Test::Unit::TestCase
}
}
end
+
+ def make_tempfile
+ t = Tempfile.new("foo")
+ t.binmode
+ t.puts "foo"
+ t.puts "bar"
+ t.puts "baz"
+ t.close
+ t
+ end
+
+ def test_binmode_after_closed
+ t = make_tempfile
+ t.close
+ assert_raise(IOError) {t.binmode}
+ end
end
diff --git a/version.h b/version.h
index 657ed422aa..652291c069 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2009-11-17"
#define RUBY_VERSION_CODE 187
#define RUBY_RELEASE_CODE 20091117
-#define RUBY_PATCHLEVEL 206
+#define RUBY_PATCHLEVEL 207
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8