summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
Diffstat (limited to 'std')
-rw-r--r--std/io.toc16
1 files changed, 12 insertions, 4 deletions
diff --git a/std/io.toc b/std/io.toc
index d3ce467..2c82dc9 100644
--- a/std/io.toc
+++ b/std/io.toc
@@ -2,16 +2,19 @@ putchar ::= #foreign("putchar", "libc.so.6") fn(#C int) #C int;
toc_putchar ::= fn(x: char) {
putchar(x as #C int);
}
+printf ::= #foreign("printf", "libc.so.6") fn(#C &"char const", #C ..) #C int;
+writes ::= fn(x: []char) {
+ printf_strfmt := "%s\0";
+ printf(&printf_strfmt[0], &x[0]);
+}
puts ::= fn(x: []char) {
- for c := x {
- toc_putchar(c);
- }
+ writes(x);
toc_putchar('\n');
}
-puti ::= fn(x: int) {
+writei ::= fn(x: int) {
if x < 0 {
toc_putchar('-');
// NOTE: don't do x = -x; here to make sure I64_MIN works
@@ -31,5 +34,10 @@ puti ::= fn(x: int) {
scan_digit /= 10;
}
}
+}
+
+puti ::= fn(x: int) {
+ writei(x);
toc_putchar('\n');
}
+