From 8b2384c94e2f5834f3b8929f982a19edde1503d9 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Tue, 14 Jul 2020 14:40:08 -0400 Subject: type information finished --- std/io.toc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'std') diff --git a/std/io.toc b/std/io.toc index 15314c9..96b0e21 100644 --- a/std/io.toc +++ b/std/io.toc @@ -239,10 +239,21 @@ fwrites ::= fn(use f: &File, s : []char) FileError { } } +fwritec ::= fn(use f: &File, c : char) err : FileError { + if buffer_used > BUFSZ-1 { + flush(f); + buffer[0] = c; + } else { + buffer[buffer_used] = c; + buffer_used += 1; + } + if nobuffer { flush(f); } +} + fputs ::= fn(f: &File, s: []char) err : FileError { err = fwrites(f, s); if !err { - err = fwrites(f, "\n"); + err = fwritec(f, '\n'); } } @@ -250,6 +261,10 @@ writes ::= fn(s: []char) { fwrites(&std_out, s); } +writec ::= fn(c: char) { + fwritec(&std_out, c); +} + puts ::= fn(s: []char) { fputs(&std_out, s); } @@ -311,7 +326,7 @@ writei ::= fn(x: int) { puti ::= fn(x: int) { writei(x); - writes("\n"); + writec('\n'); } putb ::= fn(x: bool) { -- cgit v1.2.3