[macruby-changes] [MacRuby/MacRuby] 82517d: IO#sysread will handle 2nd argument as buffer when...

noreply at github.com noreply at github.com
Mon May 16 07:51:47 PDT 2011


Branch: refs/heads/master
Home:   https://github.com/MacRuby/MacRuby

Commit: 82517df769fbcb81dbd3123066af0901f04d1073
    https://github.com/MacRuby/MacRuby/commit/82517df769fbcb81dbd3123066af0901f04d1073
Author: Watson <watson1978 at gmail.com>
Date:   2011-05-16 (Mon, 16 May 2011)

Changed paths:
  M io.c

Log Message:
-----------
IO#sysread will handle 2nd argument as buffer when was passed Object which has to_str method.

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

File.open("/tmp/foo", "w") {|f|
  f.write "01234567890123456789"
}

obj = Object.new
$buffer = "abc"

def obj.to_str
  $buffer
end

File.open("/tmp/foo") {|f|
  f.sysread(5, obj)
  assert_equal("01234", obj.to_str)
  assert_equal("01234", $buffer)
}

puts :ok
}}}




More information about the macruby-changes mailing list