kripken/emscripten — pull request #1650 by rharkeadsk (2013-09-23 02:21:37+00:00)
Title: Fix 3 issues with formatting (printf)

This fixes three bugs with the formatting code (used by printf et al) .. well, arguably one of them is a new feature (one called for by the spec).

1. If you zero-pad a negative integer (as with %010d), the zeros would appear before the negative sign (00000-1977) instead of after (-000001977). This was only a bug with integers, not with floats.
2. If you force the display of the sign on a negative integer (as with %+d), the sign would be printed twice (--1977 instead of just -1977). Again, this only seemed to be a problem on integers.
3. The "space" formatting flag (which is basically the same as + but prints a space instead of a positive sign) was not implemented.

I've added tests for all 3 new cases. I did note however that test_printf seems to have two reference output files, one for regular and one for precise 64-bit math. However there does not seem to be a way to run the test with precise 64-bit math. It looks like there was intended to be, but I don't see a way to trigger it.

As for running the existing tests, I get 7 errors (out of 2718 tests) running all core tests on the incoming branch. This is before my changes, not after. The tests with errors are default.test_bigswitch, asm1.test_cases, asm2.test_cases, asm2.test_fuzz, asm2g.test_cases, asm2g.test_fuzz, asm2x86.test_cases. With my changes, the errors are exactly the same. I did not cause any of the errors, nor am I sure what is causing them.

Let me know if you have any questions.. thanks!