Commit 4545be360a

Andrew Kelley <superjoe30@gmail.com>
2018-04-10 03:14:55
fix std.io.readline to work on windows
closes #882
1 parent 9ef1ba9
Changed files (1)
std
std/io.zig
@@ -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;