aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-04-09 21:14:55 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-04-09 21:14:55 -0400
commit4545be360a723a4c5b141cbefcc07ac7f17f0757 (patch)
tree9d4e5499387066e5bbddc8b127b2f9092fb21332 /std
parent9ef1ba9d54e560ca384c95b74067674878aea019 (diff)
downloadzig-4545be360a723a4c5b141cbefcc07ac7f17f0757.tar.gz
zig-4545be360a723a4c5b141cbefcc07ac7f17f0757.zip
fix std.io.readline to work on windows
closes #882
Diffstat (limited to 'std')
-rw-r--r--std/io.zig5
1 files changed, 5 insertions, 0 deletions
diff --git a/std/io.zig b/std/io.zig
index 93d50e6709..7b72af15e4 100644
--- a/std/io.zig
+++ b/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;