fix std.io.readline to work on windows

closes #882
This commit is contained in:
Andrew Kelley 2018-04-09 21:14:55 -04:00
parent 9ef1ba9d54
commit 4545be360a

View File

@ -486,6 +486,11 @@ pub fn readLine(buf: []u8) !usize {
while (true) {
const byte = stream.readByte() catch return error.EndOfFile;
switch (byte) {
'\r' => {
// trash the following \n
_ = stream.readByte() catch return error.EndOfFile;
return index;
},
'\n' => return index,
else => {
if (index == buf.len) return error.InputTooLong;