Skip to content
Snippets Groups Projects
Commit 3d3b621f authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix fencepost error in format arguments.

The first argument after the list was still being replaced.
Extended test to try the hard stuff.
parent fea42451
No related branches found
No related tags found
No related merge requests found
Pipeline #7815 passed
const args = [ 1, 1.1, true, "one", -1, 1e9 ]; const args = [ 1, 1.1, true, "one", -1, 1e9, null ];
const test = { const test = {
"%s": "1", "%s": "1",
...@@ -18,6 +18,10 @@ const test = { ...@@ -18,6 +18,10 @@ const test = {
"%5$d": "-1", "%5$d": "-1",
"%5$x": "ffffffff", "%5$x": "ffffffff",
"%6$u": "1000000000", "%6$u": "1000000000",
"%7$u": "0",
"%7$s": "null",
"%7$s %s": "null %s",
"%8$s": "%8$s",
}; };
for (var i in test) { for (var i in test) {
......
...@@ -48,7 +48,7 @@ js_sprintf(JSContext *cx, uint argn, uintN argc, jsval *argv) ...@@ -48,7 +48,7 @@ js_sprintf(JSContext *cx, uint argn, uintN argc, jsval *argv)
cur = next; cur = next;
else else
cur++; cur++;
if (cur > argc) if (cur >= argc)
break; break;
if (JSVAL_IS_DOUBLE(argv[cur])) if (JSVAL_IS_DOUBLE(argv[cur]))
p = xp_asprintf_next(p, XP_PRINTF_CONVERT | XP_PRINTF_TYPE_DOUBLE, JSVAL_TO_DOUBLE(argv[cur])); p = xp_asprintf_next(p, XP_PRINTF_CONVERT | XP_PRINTF_TYPE_DOUBLE, JSVAL_TO_DOUBLE(argv[cur]));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment