summaryrefslogtreecommitdiff
path: root/src/js/lib/myutils.js
diff options
context:
space:
mode:
authorspv420 <unomilliono@gmail.com>2022-04-23 19:00:46 -0400
committerspv420 <unomilliono@gmail.com>2022-04-23 19:00:46 -0400
commit26c3d55c81b7a33a4d87ba8d2f40a918d2d9f737 (patch)
tree5911108f2bdb563c518347b662e12b916b469931 /src/js/lib/myutils.js
parentbc3e2818f1c96289f1db2ed367274fb7bb06e89a (diff)
hahahahaha we're all gonna die *hbomberguy intro*
Diffstat (limited to 'src/js/lib/myutils.js')
-rw-r--r--src/js/lib/myutils.js23
1 files changed, 21 insertions, 2 deletions
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