[macruby-changes] [4916] MacRuby/trunk/io.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Nov 17 00:39:23 PST 2010


Revision: 4916
          http://trac.macosforge.org/projects/ruby/changeset/4916
Author:   watson1978 at gmail.com
Date:     2010-11-17 00:39:20 -0800 (Wed, 17 Nov 2010)
Log Message:
-----------
use the rb_funcall in rb_io_write. Zlib::GzipWriter#putc, #print, #printf and #<< will works.

Test Script:
{{{
require 'tempfile'
require 'zlib'
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

t = Tempfile.new("gzip")
t.close

Zlib::GzipWriter.open(t.path) {|gz|
  gz.putc("#")
  gz.print("foo")
  gz << "bar"
  gz.printf("baz%04d", 1)
}

Zlib::GzipReader.open(t.path) {|gz|
  assert_equal("#foobarbaz0001", gz.read)
}

puts :ok
}}}

Modified Paths:
--------------
    MacRuby/trunk/io.c

Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c	2010-11-17 06:52:26 UTC (rev 4915)
+++ MacRuby/trunk/io.c	2010-11-17 08:39:20 UTC (rev 4916)
@@ -502,7 +502,7 @@
 VALUE
 rb_io_addstr(VALUE io, SEL sel, VALUE str)
 {
-    io_write(io, 0, str);
+    rb_io_write(io, str);
     return io;
 }
 
@@ -2803,7 +2803,6 @@
 VALUE
 rb_io_print(VALUE io, SEL sel, int argc, VALUE *argv)
 {
-    rb_io_assert_writable(ExtractIOStruct(io));
     VALUE line;
     if (argc == 0) {
         argc = 1;
@@ -2983,8 +2982,7 @@
 VALUE
 rb_io_write(VALUE v, VALUE i)
 {
-    io_write(v, 0, i);
-    return Qnil;
+    return rb_funcall(v, id_write, 1, i);
 }
 
 /*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101117/b6f409b6/attachment.html>


More information about the macruby-changes mailing list