diff options
-rw-r--r-- | src/library.js | 7 | ||||
-rw-r--r-- | tests/printf/output.txt | 1 | ||||
-rw-r--r-- | tests/printf/output_i64_1.txt | 1 | ||||
-rw-r--r-- | tests/printf/test.c | 1 |
4 files changed, 6 insertions, 4 deletions
diff --git a/src/library.js b/src/library.js index 3f030489..6cbe7854 100644 --- a/src/library.js +++ b/src/library.js @@ -1950,9 +1950,9 @@ LibraryManager.library = { } // Handle precision. - var precisionSet = false; + var precisionSet = false, precision = -1; if (next == {{{ charCode('.') }}}) { - var precision = 0; + precision = 0; precisionSet = true; textIndex++; next = {{{ makeGetValue(0, 'textIndex+1', 'i8') }}}; @@ -1969,9 +1969,8 @@ LibraryManager.library = { } } next = {{{ makeGetValue(0, 'textIndex+1', 'i8') }}}; - } else { - var precision = 6; // Standard default. } + if (precision === -1) precision = 6; // Standard default. // Handle integer sizes. WARNING: These assume a 32-bit architecture! var argSize; diff --git a/tests/printf/output.txt b/tests/printf/output.txt index 0155f0da..a3baed28 100644 --- a/tests/printf/output.txt +++ b/tests/printf/output.txt @@ -8280,4 +8280,5 @@ ffffff8000000000 1 1 +1.234568E+04 no_new_line diff --git a/tests/printf/output_i64_1.txt b/tests/printf/output_i64_1.txt index e38fb78f..ea85d302 100644 --- a/tests/printf/output_i64_1.txt +++ b/tests/printf/output_i64_1.txt @@ -8280,4 +8280,5 @@ ffffff8000000000 1 1 +1.234568E+04 no_new_line diff --git a/tests/printf/test.c b/tests/printf/test.c index 1c8ad9f7..adeb69db 100644 --- a/tests/printf/test.c +++ b/tests/printf/test.c @@ -8285,6 +8285,7 @@ int main() { printf("%hx\n", -0xFFFF); printf("%x\n", -0xFFFFFFFF); printf("\n"); + printf("%*.*E\n", 10, -1, 12345.6789123); printf("no_new_line"); return 0; } |