textmode File#read on CRLF
I'm not sure this is bug,
when "File#read(X)" for textmode finishes inside of CRLF, stream keeps CR unread against my intuition.
The following code prints "\r" forever for CRLF.
File.open(FILE, "r") do |f|
Updated by h.shirosaki (Hiroshi Shirosaki) about 8 years ago
I think that is not fixed yet.
io_unread() doesn't work properly in that case.
An idea is not using
read into buffer in rb_io_eof() only in that case. Attached the patch.
Updated by riskwa (riskwa anon) about 8 years ago
I tested the code above in some environments.
(a) ruby 1.9.3p125 (2012-02-16 revision 34643) [i386-cygwin] : works fine
(b) ruby 2.0.0dev (2012-04-08 trunk 35259) [i386-cygwin] : works fine
(c) ruby 1.9.3p125 (2012-02-16) [i386-mingw32] : NG
(d) ruby 2.0.0dev (2012-04-08) [i386-mingw32] : NG
(e) ruby 2.0.0dev (2012-04-08) i386-mingw32 : works fine
Updated by Anonymous about 8 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r35296.
riskwa, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
io.c (rb_io_eof): use eof() instead of io_fillbuf(). It's because
io_unread() doesn't work properly when reading CRLF with read(length)
and mode 'r'.
test for above.