diff options
author | max99x <max99x@gmail.com> | 2011-06-28 08:56:33 +0300 |
---|---|---|
committer | max99x <max99x@gmail.com> | 2011-06-28 08:56:33 +0300 |
commit | 3a0e9450e8c4f3667477b3c77f3ebc9c429963e4 (patch) | |
tree | 0a3f350975d6e161a809b7c1a99f8d097d47c4da | |
parent | 26d16fbbca1de5f13306359bf78389adc438ba6b (diff) |
Added support for %n in _formatString/printf.
-rw-r--r-- | src/library.js | 3 | ||||
-rw-r--r-- | tests/printf/output.txt | 2 | ||||
-rw-r--r-- | tests/printf/test.c | 3 |
3 files changed, 6 insertions, 2 deletions
diff --git a/src/library.js b/src/library.js index 54256c44..b2c3d13c 100644 --- a/src/library.js +++ b/src/library.js @@ -340,8 +340,7 @@ var Library = { if (!flagLeftAlign) ret = ret.concat(getNextArg(next)); textIndex += 2; } else if (next == 'n'.charCodeAt(0)) { - // TODO: Implement. Requires arguments to be passed in C-style. - // {{{ makeSetValue('argIndex', '0', 'ret.length', 'i32') }}} + {{{ makeSetValue('getNextArg("d")', '0', 'ret.length', 'i32') }}} textIndex += 2; } else { // TODO: Add support for a/A specifiers (hex float). diff --git a/tests/printf/output.txt b/tests/printf/output.txt index bdf9d0bc..be93561b 100644 --- a/tests/printf/output.txt +++ b/tests/printf/output.txt @@ -1,3 +1,5 @@ +ab1.23cd +n=7 Characters: a A Decimals: 1977 650000 12 4 diff --git a/tests/printf/test.c b/tests/printf/test.c index ac662dca..e388ee9c 100644 --- a/tests/printf/test.c +++ b/tests/printf/test.c @@ -2,6 +2,9 @@ #include <math.h> int main() { + int x; + printf("ab%gc%nd\n", 1.23f, &x); + printf("n=%d\n", x); printf("\n"); printf("Characters: %c %c\n", 'a', 65); printf("Decimals: %d %ld %lld %d\n", 1977, 650000L, 12LL, 4); |