[macruby-changes] [2103] MacRuby/branches/experimental/io.c
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jul 28 00:27:22 PDT 2009
Revision: 2103
http://trac.macosforge.org/projects/ruby/changeset/2103
Author: lsansonetti at apple.com
Date: 2009-07-28 00:27:19 -0700 (Tue, 28 Jul 2009)
Log Message:
-----------
fixed a problem in IO#gets where the stream wasn't marked as EOF after reading the last separator-terminated line
Modified Paths:
--------------
MacRuby/branches/experimental/io.c
Modified: MacRuby/branches/experimental/io.c
===================================================================
--- MacRuby/branches/experimental/io.c 2009-07-27 23:20:14 UTC (rev 2102)
+++ MacRuby/branches/experimental/io.c 2009-07-28 07:27:19 UTC (rev 2103)
@@ -1336,6 +1336,16 @@
data_read += seplen;
if (memcmp(tmp_buf, sepstr, seplen) == 0) {
+ // We found the separator, however in order to conform to the
+ // Ruby specification we must try to read one more byte, in
+ // order to properly mark the stream as EOF.
+ UInt8 c;
+ if (rb_io_read_internal(io_struct, &c, 1) == 1) {
+ // If we could read one byte, let's seek to one byte in the
+ // past to revert the stream to its original position.
+ rb_io_seek(io, OFFT2NUM(NUM2OFFT(rb_io_tell(io, 0)) - 1),
+ SEEK_SET);
+ }
break;
}
}
@@ -1345,9 +1355,9 @@
}
CFDataSetLength(data, data_read);
}
- OBJ_TAINT(bstr);
- io_struct->lineno += 1;
- ARGF.lineno = INT2FIX(io_struct->lineno);
+ OBJ_TAINT(bstr);
+ io_struct->lineno += 1;
+ ARGF.lineno = INT2FIX(io_struct->lineno);
return bstr;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090728/dddebe33/attachment.html>
More information about the macruby-changes
mailing list