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

source_changes at macosforge.org source_changes at macosforge.org
Mon Nov 15 19:06:16 PST 2010


Revision: 4912
          http://trac.macosforge.org/projects/ruby/changeset/4912
Author:   watson1978 at gmail.com
Date:     2010-11-15 19:06:14 -0800 (Mon, 15 Nov 2010)
Log Message:
-----------
ARGF.readbyte will be passed the multiple file path.

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

t1 = Tempfile.new("foo")
t1.puts "1"
t1.puts "2"
t1.close
t2 = Tempfile.new("bar")
t2.puts "3"
t2.puts "4"
t2.close

def ruby(*args)
  args = ['-e', '$>.write($<.read)'] if args.empty?
  ruby = ARGV[0] || "/usr/local/bin/macruby"
  f = IO.popen([ruby] + args, 'r+')
  yield(f)
ensure
  f.close unless !f || f.closed?
end

ruby('-e', <<-SRC, t1.path, t2.path) do |f|
  begin
    s = []
    while c = ARGF.readbyte
      s << c
    end
  rescue EOFError
    p s
  end
SRC
  assert_equal("[49, 10, 50, 10, 51, 10, 52, 10]\n", f.read)
end

puts :ok
}}}

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

Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c	2010-11-16 03:06:10 UTC (rev 4911)
+++ MacRuby/trunk/io.c	2010-11-16 03:06:14 UTC (rev 4912)
@@ -4463,11 +4463,16 @@
 }
 
 static VALUE
-argf_readbyte(VALUE argf)
+argf_readbyte(VALUE argf, SEL sel)
 {
-    next_argv();
-    ARGF_FORWARD(0, 0);
-    return rb_io_readbyte(ARGF.current_file, 0);
+    VALUE c;
+
+    NEXT_ARGF_FORWARD(0, 0);
+    c = argf_getbyte(argf, sel);
+    if (NIL_P(c)) {
+	rb_eof_error();
+    }
+    return c;
 }
 
 static VALUE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101115/132f2c48/attachment-0001.html>


More information about the macruby-changes mailing list