[macruby-changes] [5045] MacRuby/trunk/io.c
source_changes at macosforge.org
source_changes at macosforge.org
Fri Dec 17 01:20:46 PST 2010
Revision: 5045
http://trac.macosforge.org/projects/ruby/changeset/5045
Author: watson1978 at gmail.com
Date: 2010-12-17 01:20:42 -0800 (Fri, 17 Dec 2010)
Log Message:
-----------
IO#write will not throw an exception if stream is read-only when writing data is 0 byte.
Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
path = "tmp"
io = File.open(path, "w")
io.close
readonly = File.open(path)
assert_nothing_raised { readonly.write("") }
puts :ok
}}}
Modified Paths:
--------------
MacRuby/trunk/io.c
Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c 2010-12-17 08:53:12 UTC (rev 5044)
+++ MacRuby/trunk/io.c 2010-12-17 09:20:42 UTC (rev 5045)
@@ -462,11 +462,8 @@
return rb_vm_call(io, selWrite, 1, &data);
}
io = tmp;
-
- rb_io_t *io_struct = ExtractIOStruct(io);
- rb_io_assert_writable(io_struct);
+
data = rb_obj_as_string(data);
-
data = rb_str_bstr(data);
const uint8_t *buffer = rb_bstr_bytes(data);
const long length = rb_bstr_length(data);
@@ -475,6 +472,9 @@
return INT2FIX(0);
}
+ rb_io_t *io_struct = ExtractIOStruct(io);
+ rb_io_assert_writable(io_struct);
+
ssize_t code = write(io_struct->write_fd, buffer, length);
if (code == -1) {
rb_sys_fail("write() failed");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101217/b6f46084/attachment.html>
More information about the macruby-changes
mailing list