authorgravatar for 1405645+jean-dao@users.noreply.github.comjean-dao <1405645+jean-dao@users.noreply.github.com> 2017-09-10 17:10:55+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-10 11:10:55-04:00
log0f7544cfca63fc5b49790974e6b01097365bb18c
tree39d9d8ac69e20b940847588f9b656dbc422ebc45
parentb00b7bd29037f25ee155f07e74fcb5de44918926

std.io.InStream: add readLine function (#458)


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

std/io.zig+13
......@@ -419,6 +419,19 @@ pub const InStream = struct {
419419 }
420420 }
421421
422 pub fn readLine(is: &InStream, buf: &Buffer) -> %void {
423 %return buf.resize(0);
424
425 while (true) {
426 var byte: u8 = %return is.readByte();
427 %return buf.appendByte(byte);
428
429 if (buf.endsWith(os.line_sep)) {
430 break;
431 }
432 }
433 }
434
422435 pub fn isTty(self: &InStream) -> %bool {
423436 if (is_posix) {
424437 if (builtin.link_libc) {