From 139ac45cb1b89a0abfd91d87e5586279c37d2d52 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Mon, 16 Apr 2018 01:56:10 +0200 Subject: [PATCH] Use only putchar() for printing --- src/runtime/runtime.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index 7a623501..51cda99c 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -4,10 +4,10 @@ #include #include "runtime.h" -#define print(buf, len) write(STDOUT_FILENO, buf, len) - void __go_printstring(string_t str) { - write(STDOUT_FILENO, str.buf, str.len); + for (int i = 0; i < str.len; i++) { + putchar(str.buf[i]); + } } void __go_printint(intgo_t n) { @@ -16,23 +16,22 @@ void __go_printint(intgo_t n) { // TODO: don't recurse, but still be compact (and don't divide/mod // more than necessary). if (n < 0) { - print("-", 1); + putchar('-'); n = -n; } intgo_t prevdigits = n / 10; if (prevdigits != 0) { __go_printint(prevdigits); } - char buf[1] = {(n % 10) + '0'}; - print(buf, 1); + putchar((n % 10) + '0'); } void __go_printspace() { - print(" ", 1); + putchar(' '); } void __go_printnl() { - print("\n", 1); + putchar('\n'); } void go_main() __asm__("main.main");