Broken right-padding in float code
Opened this issue · 1 comments
Deleted user commented
Test case: printf("a%-5.1f", 0.5);
should print a0.5
.
The float code uses the absolute position to compute the amount of padding:
https://github.com/mpaland/printf/blob/master/printf.c#L391
It should use the index within the text produced by the format specifier, like the integer padding code does.
mpaland commented
Hello Vincent,
thanks a lot for finding this bug!
You are right, as a matter of fact, the index position is wrong in _ftoa. Good catch.
Anyway, your above test case should return two spaces at the end.
printf("a%-5.1f", 0.5) should print "a0.5 "
printf("a%-5.1fend", 0.5) should print "a0.5 end"