aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-01-13 15:31:00 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-01-13 15:31:52 -0800
commit7844db37f5b6dce1e7772f955ff606ef806ae032 (patch)
treee2806527be8e40b11ce83cb7de6e08915413f92c
parentcb0f677e53e556185951c84a472a340ab49d3dc3 (diff)
handle precision -1 in printf .*
-rw-r--r--src/library.js7
-rw-r--r--tests/printf/output.txt1
-rw-r--r--tests/printf/output_i64_1.txt1
-rw-r--r--tests/printf/test.c1
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;
}