authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-04-09 21:14:55-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-04-09 21:14:55-04:00
log4545be360a723a4c5b141cbefcc07ac7f17f0757
tree9d4e5499387066e5bbddc8b127b2f9092fb21332
parent9ef1ba9d54e560ca384c95b74067674878aea019

fix std.io.readline to work on windows

closes #882

1 files changed, 5 insertions(+), 0 deletions(-)

std/io.zig+5
...@@ -486,6 +486,11 @@ pub fn readLine(buf: []u8) !usize {...@@ -486,6 +486,11 @@ pub fn readLine(buf: []u8) !usize {
486 while (true) {486 while (true) {
487 const byte = stream.readByte() catch return error.EndOfFile;487 const byte = stream.readByte() catch return error.EndOfFile;
488 switch (byte) {488 switch (byte) {
489 '\r' => {
490 // trash the following \n
491 _ = stream.readByte() catch return error.EndOfFile;
492 return index;
493 },
489 '\n' => return index,494 '\n' => return index,
490 else => {495 else => {
491 if (index == buf.len) return error.InputTooLong;496 if (index == buf.len) return error.InputTooLong;