From 26c3d55c81b7a33a4d87ba8d2f40a918d2d9f737 Mon Sep 17 00:00:00 2001 From: spv420 Date: Sat, 23 Apr 2022 19:00:46 -0400 Subject: hahahahaha we're all gonna die *hbomberguy intro* --- src/js/lib/myutils.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/js/lib/myutils.js') diff --git a/src/js/lib/myutils.js b/src/js/lib/myutils.js index 80d4d9b..38b85b8 100644 --- a/src/js/lib/myutils.js +++ b/src/js/lib/myutils.js @@ -1,9 +1,28 @@ function puts(s) { - return calls4arg("puts\0", sptr(s + "\0"), 0, 0, 0); + return calls4arg("puts\0", sptr(s), 0, 0, 0); } function printf() { + if (arguments.length > 4) { + return printf("warning: tried to printf with %d args, max %d.\n", arguments.length, 4); + } + + var args_to_pass = new Array(); + + args_to_pass.push("printf"); + for (var i = 0; i < arguments.length; i++) { - puts(arguments[i]); + if (arguments[i].constructor === String) { + args_to_pass.push(sptr(arguments[i])); + } else { + args_to_pass.push(arguments[i]); + } } + + var count_to_me = 5 - arguments.length; + for (var i = 0; i < count_to_me; i++) { + args_to_pass.push(0); + } + + return calls4arg.apply(this, args_to_pass); } \ No newline at end of file -- cgit v1.2.3