fix failure of printf %g to strip trailing zeros in some cases
authorRich Felker <dalias@aerifal.cx>
Mon, 7 Apr 2014 06:05:20 +0000 (02:05 -0400)
committerRich Felker <dalias@aerifal.cx>
Wed, 16 Apr 2014 06:46:05 +0000 (02:46 -0400)
commit9de00a019e01c8a37a0b54f39be4bd54028fc57f
tree02978040ef3c4a344ef72c23124f6aaab3b4a0f5
parentad0dfd04c2daf176235085c4e97f4d6ed3851654
fix failure of printf %g to strip trailing zeros in some cases

the code to strip trailing zeros was only looking in the last slot for
up to 9 zeros, assuming that the rounding code had already removed
fully-zero slots from the end. however, this ignored cases where the
rounding code did not run at all, which occur when the value being
printed is exactly representable in the requested precision.

the simplest solution is to move the code that strips trailing zero
slots to run unconditionally, immediately after rounding, rather than
as the last step of rounding.

(cherry picked from commit 89740868c9f1c84b8ee528468d12df1fa72cd392)
src/stdio/vfprintf.c