aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <azakai@mozilla.com>2010-12-11 18:39:03 -0800
committerAlon Zakai <azakai@mozilla.com>2010-12-11 18:39:03 -0800
commit1776ba30d4a746cd4f1cf7f69ec4f9a7a762d34a (patch)
tree887344165c296ea0c14ab03b1480e39e0757065b
parent965d44dc699c22669b0fb4800e15e010f0bf48c0 (diff)
support for printing %p
-rw-r--r--src/preamble.js8
-rw-r--r--tests/runner.py2
2 files changed, 8 insertions, 2 deletions
diff --git a/src/preamble.js b/src/preamble.js
index da6660ba..7e1300fb 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -264,7 +264,7 @@ function __formatString() {
textIndex++;
next = IHEAP[textIndex+1];
}
- if (['d', 'u', 'f', '.'].indexOf(String.fromCharCode(next)) != -1) {
+ if (['d', 'u', 'p', 'f', '.'].indexOf(String.fromCharCode(next)) != -1) {
var currArg;
var argText;
// Handle very very simply formatting, namely only %.Xf
@@ -292,6 +292,9 @@ function __formatString() {
} else if (next == 'u'.charCodeAt(0)) {
currArg = getNextArg(next);
argText = String(unSign(currArg, 32));
+ } else if (next == 'p'.charCodeAt(0)) {
+ currArg = getNextArg(next);
+ argText = '0x' + currArg.toString(16);
} else {
currArg = getNextArg(next);
argText = String(+currArg); // +: boolean=>int
@@ -306,6 +309,9 @@ function __formatString() {
} else if (next == 'c'.charCodeAt(0)) {
ret = ret.concat(getNextArg(next));
textIndex += 2;
+ } else {
+ ret.push(curr);
+ textIndex += 1; // not sure what to do with this %, so print it
}
} else {
ret.push(curr);
diff --git a/tests/runner.py b/tests/runner.py
index a8cf123d..e556f3c5 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -183,7 +183,7 @@ if 'benchmark' not in sys.argv:
printf(",");
}
printf("*\\n");
- printf("*%ld*\\n", (long)21);
+ printf("*%ld*%p\\n", (long)21, &hash); // The %p should not enter an infinite loop!
return 0;
}
'''