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

source_changes at macosforge.org source_changes at macosforge.org
Thu Nov 4 03:29:07 PDT 2010


Revision: 4878
          http://trac.macosforge.org/projects/ruby/changeset/4878
Author:   watson1978 at gmail.com
Date:     2010-11-04 03:29:02 -0700 (Thu, 04 Nov 2010)
Log Message:
-----------
IO#gets(0) will return empty string.

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

string = "0123"

r, w = IO.pipe
w.print string
w.close
assert_equal("", r.gets(0))
assert_equal("0123", r.gets(10))
assert_nil(r.gets(10))
assert_nil(r.gets(nil, 10))
assert_nil(r.gets)
assert_equal("", r.gets(0))
r.close

puts :ok
}}}

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

Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c	2010-11-04 08:02:11 UTC (rev 4877)
+++ MacRuby/trunk/io.c	2010-11-04 10:29:02 UTC (rev 4878)
@@ -1402,7 +1402,7 @@
 	rb_bstr_resize(bstr, line_limit);
 	uint8_t *bytes = rb_bstr_bytes(bstr);
 	long r = rb_io_read_internal(io_struct, bytes, line_limit);
-	if (r == 0) {
+	if (r == 0 && line_limit != 0) {
 	    return Qnil;
 	}
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101104/0f89ffb5/attachment-0001.html>


More information about the macruby-changes mailing list