diff options
-rw-r--r-- | src/library.js | 2 | ||||
-rwxr-xr-x | tests/runner.py | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/library.js b/src/library.js index 6bfb49ef..84071b68 100644 --- a/src/library.js +++ b/src/library.js @@ -2869,7 +2869,7 @@ LibraryManager.library = { } else if (next == {{{ charCode('o') }}}) { argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8); } else if (next == {{{ charCode('x') }}} || next == {{{ charCode('X') }}}) { - prefix = flagAlternative ? '0x' : ''; + prefix = (flagAlternative && currArg != 0) ? '0x' : ''; #if PRECISE_I64_MATH if (argSize == 8 && i64Math) { if (origArg[1]) { diff --git a/tests/runner.py b/tests/runner.py index 3b0b81ff..8ed8da65 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -5620,7 +5620,7 @@ at function.:blag open(path_from_root('tests', 'printf', 'output_i64_1.txt'), 'r').read()] self.do_run(src, expected) - def test_printf_types(self): + def test_printf_2(self): src = r''' #include <stdio.h> @@ -5633,11 +5633,12 @@ at function.:blag double d = 6.6; printf("%c,%hd,%d,%lld,%.1f,%.1llf\n", c, s, i, l, f, d); + printf("%#x,%#x\n", 1, 0); return 0; } ''' - self.do_run(src, '1,2,3,4,5.5,6.6\n') + self.do_run(src, '1,2,3,4,5.5,6.6\n0x1,0\n') def test_vprintf(self): src = r''' |