summaryrefslogtreecommitdiff
path: root/src/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/lib')
-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