summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-07-14 14:40:08 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-07-14 14:40:08 -0400
commit8b2384c94e2f5834f3b8929f982a19edde1503d9 (patch)
tree54c8871c582bc858216c665b663e38da4830cfe6 /std
parent2ef832fb45f7044f64746bdb422a4dfac20cefe9 (diff)
type information finished
Diffstat (limited to 'std')
-rw-r--r--std/io.toc19
1 files changed, 17 insertions, 2 deletions
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) {