summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
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) {