mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
std.io.InStream: add readLine function (#458)
This commit is contained in:
parent
b00b7bd290
commit
0f7544cfca
13
std/io.zig
13
std/io.zig
@ -419,6 +419,19 @@ pub const InStream = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn readLine(is: &InStream, buf: &Buffer) -> %void {
|
||||
%return buf.resize(0);
|
||||
|
||||
while (true) {
|
||||
var byte: u8 = %return is.readByte();
|
||||
%return buf.appendByte(byte);
|
||||
|
||||
if (buf.endsWith(os.line_sep)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn isTty(self: &InStream) -> %bool {
|
||||
if (is_posix) {
|
||||
if (builtin.link_libc) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user