diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-07-14 14:40:08 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-07-14 14:40:08 -0400 |
commit | 8b2384c94e2f5834f3b8929f982a19edde1503d9 (patch) | |
tree | 54c8871c582bc858216c665b663e38da4830cfe6 /std | |
parent | 2ef832fb45f7044f64746bdb422a4dfac20cefe9 (diff) |
type information finished
Diffstat (limited to 'std')
-rw-r--r-- | std/io.toc | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -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) { |