aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-09-06 10:34:06 -0700
committeralon@honor <none@none>2010-09-06 10:34:06 -0700
commit3109ce8f1c903653a982d44c471cf7f5bab975b1 (patch)
tree01f05913fe30de41470d6a26e8a68875fabf6b97
parent81161db178519d189e930b423832193802364f63 (diff)
support for %s in printf
-rw-r--r--src/preamble.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 82dbdcb3..0e21f70e 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -101,14 +101,16 @@ function __formatString() {
while (curr != 0) {
curr = HEAP[textIndex];
next = HEAP[textIndex+1];
- // We only support numbers - use puts for strings!
if (curr == '%'.charCodeAt(0) && ['d', 'f'].indexOf(String.fromCharCode(next)) != -1) {
String(arguments[argIndex]).split('').forEach(function(chr) {
ret.push(chr.charCodeAt(0));
});
argIndex += 1;
textIndex += 2;
- continue;
+ } else if (curr == '%'.charCodeAt(0) && next == 's'.charCodeAt(0)) {
+ ret = ret.concat(String_copy(arguments[argIndex]));
+ argIndex += 1;
+ textIndex += 2;
} else {
ret.push(curr);
textIndex ++;