[macruby-changes] [4782] MacRuby/trunk/lib/stringio.rb
source_changes at macosforge.org
source_changes at macosforge.org
Sun Oct 10 06:04:32 PDT 2010
Revision: 4782
http://trac.macosforge.org/projects/ruby/changeset/4782
Author: watson1978 at gmail.com
Date: 2010-10-10 06:04:31 -0700 (Sun, 10 Oct 2010)
Log Message:
-----------
Fixed a bug of StringIO#read(length, buffer). Should set empty string to buffer when calls at EOF.
Test Script:
{{{
require 'stringio'
def assert_equal(x, y)
if x == y
puts "ok"
else
puts "ng : x = #{x.inspect} : y = #{y.inspect}"
end
end
str = StringIO.new("abc")
s = "xxx"
assert_equal("abc", str.read(nil, s))
assert_equal("abc", s)
assert_equal("", str.read(nil, s))
assert_equal("", s)
puts "-----"
str = StringIO.new("")
s = "xxx"
assert_equal("", t = str.read(nil, s))
assert_equal("", s)
assert_equal(t.object_id, s.object_id)
puts "-----"
str = StringIO.new("")
s = "x"
assert_equal(nil, str.read(10, s))
assert_equal("", s)
}}}
Modified Paths:
--------------
MacRuby/trunk/lib/stringio.rb
Modified: MacRuby/trunk/lib/stringio.rb
===================================================================
--- MacRuby/trunk/lib/stringio.rb 2010-10-10 11:00:18 UTC (rev 4781)
+++ MacRuby/trunk/lib/stringio.rb 2010-10-10 13:04:31 UTC (rev 4782)
@@ -135,11 +135,14 @@
if length == 0
buffer.replace("")
elsif length == nil
- return "" if self.eof?
+ return buffer.replace("") if self.eof?
buffer.replace(@string[@pos..-1])
@pos = string.size
else
- return nil if self.eof?
+ if self.eof?
+ buffer.replace("")
+ return nil
+ end
raise TypeError unless length.respond_to?(:to_int)
length = length.to_int
raise ArgumentError if length < 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101010/e9065c66/attachment.html>
More information about the macruby-changes
mailing list