summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-04-22 15:57:24 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-04-22 15:57:24 -0400
commit4062e5c965bc04ec9654d82526e5e785f7f45d03 (patch)
treee12b1af103ba8e7218c4adcff4c718ab236523d1 /std
parent2df588fb6ebc77d067e390e5c70c5da0298a47b2 (diff)
used for loops
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');
}
+