mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-01 19:02:19 +00:00
deal with carriage return when getting a number from stdin
This commit is contained in:
parent
a9d36431ba
commit
b3f151fd53
3 changed files with 9 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
|||
const std = @import("std");
|
||||
const str = @import("str");
|
||||
const builtin = @import("builtin");
|
||||
const RocStr = str.RocStr;
|
||||
const testing = std.testing;
|
||||
const expectEqual = testing.expectEqual;
|
||||
|
@ -15,7 +16,6 @@ comptime {
|
|||
// -fcompiler-rt in link.rs instead of doing this. Note that this
|
||||
// workaround is present in many host.zig files, so make sure to undo
|
||||
// it everywhere!
|
||||
const builtin = @import("builtin");
|
||||
if (builtin.os.tag == .macos) {
|
||||
_ = @import("compiler_rt");
|
||||
}
|
||||
|
@ -210,7 +210,8 @@ fn roc_fx_getInt_help() !i64 {
|
|||
const stdin = std.io.getStdIn().reader();
|
||||
var buf: [40]u8 = undefined;
|
||||
|
||||
const line: []u8 = (try stdin.readUntilDelimiterOrEof(&buf, '\n')) orelse "";
|
||||
const delimiter = if (builtin.os.tag == .windows) '\r' else '\n';
|
||||
const line: []u8 = (try stdin.readUntilDelimiterOrEof(&buf, delimiter)) orelse "";
|
||||
|
||||
return std.fmt.parseInt(i64, line, 10);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue