[macruby-changes] [4894] MacRuby/trunk/io.c
source_changes at macosforge.org
source_changes at macosforge.org
Sun Nov 7 07:47:53 PST 2010
Revision: 4894
http://trac.macosforge.org/projects/ruby/changeset/4894
Author: watson1978 at gmail.com
Date: 2010-11-07 07:47:49 -0800 (Sun, 07 Nov 2010)
Log Message:
-----------
fixed a bug of changing the SEEK position when IO#eof? returns false.
Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
File.open('tmp.txt', 'w') {|f|
f.print <<END
MacRuby is an implementation of Ruby 1.9 directly
END
}
io = File.open('tmp.txt')
io.read
io.seek(-10, IO::SEEK_CUR)
assert_equal(false, io.eof?)
assert_equal(10, io.read(nil).size)
assert_equal(true, io.eof?)
assert_equal("", io.read(nil))
puts :ok
}}}
Modified Paths:
--------------
MacRuby/trunk/io.c
Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c 2010-11-06 14:48:14 UTC (rev 4893)
+++ MacRuby/trunk/io.c 2010-11-07 15:47:49 UTC (rev 4894)
@@ -737,10 +737,12 @@
}
UInt8 c;
+ const off_t pos = lseek(io_struct->fd, 0, SEEK_CUR);
if (rb_io_read_internal(io_struct, &c, 1) != 1) {
return Qtrue;
}
+ lseek(io_struct->fd, pos, SEEK_SET);
if (io_struct->buf != NULL) {
io_struct->buf_offset--;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101107/a5387639/attachment.html>
More information about the macruby-changes
mailing list