From 99617c04505fc3921cecaf6fa204229a2a1f3544 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sat, 25 Jan 2020 22:10:46 -0500 Subject: mostly fixed packages --- std/arr.toc | 2 +- std/io.toc | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'std') diff --git a/std/arr.toc b/std/arr.toc index af89ecb..0e81f3a 100644 --- a/std/arr.toc +++ b/std/arr.toc @@ -20,7 +20,7 @@ pkg "arr"; a.len += 1; }; -#export arr_forfor ::= fn(t ::=, a : Arr(t), f : fn(&t)) { +#export arr_foreach ::= fn(t ::=, a : Arr(t), f : fn(&t)) { for i := 0..a.len-1 { f(&a.data[i]); } diff --git a/std/io.toc b/std/io.toc index f864c3c..147834f 100644 --- a/std/io.toc +++ b/std/io.toc @@ -24,9 +24,13 @@ toc_putchar ::= fn(x: char) { c_putchar(x as c_int); }; +c_fwrite :: fn(&u8, c_size_t, c_size_t, &u8) = #foreign "fwrite", "libc.so.6"; + +stdout_fwrite ::= fn(data: &u8, size: u64, nmemb: u64) { + c_fwrite(data, size as c_size_t, nmemb as c_size_t, #builtin("stdout")); +}; + #export puts ::= fn(x: []char) { - for c := x { - toc_putchar(c); - }; - toc_putchar('\n'); + stdout_fwrite(&x[0] as &u8, 1, x.len as u64); + toc_putchar('\n'); }; \ No newline at end of file -- cgit v1.2.3