mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-04 11:42:28 +00:00
The C standard states that, within the context of a printf-family function, when specifying the precision of a conversion specification: > A negative precision argument is taken as if the precision were > omitted. - Quoth the C Standard, 7.23.6.1. The fprintf function Cosmopolitan instead treated negative precision arguments as though they had a value of 0, which was non-conforming. This change fixes that. Another issue we found relates to: > For o conversion, it increases the precision, if and only if > necessary, to force the first digit of the result to be a zero (if > the value and precision are both 0, a single 0 is printed). - Quoth the C standard, 7.23.6.1.6. The fprintf function When printing numbers in their alternative form, with a precision and with a conversion specifier of o (octal), Cosmopolitan wasn't following the standard in two ways: 1. When printing a value with a precision that results in 0-padding, cosmopolitan would still add an extra 0 even though this should be done "if and only if necessary" 2. When printing a value of 0 with a precision of 0, nothing is printed, even though the standard specifically states that a single 0 is printed in this case This change fixes those issues too. Furthermore, regression tests have been introduced to ensure Cosmopolitan continues to be conformant going forward. Fixes #774 Fixes #782 Fixes #789 |
||
---|---|---|
.. | ||
atoi_test.c | ||
basename_test.c | ||
dirname_test.c | ||
encodenf32_test.c | ||
fmt_test.c | ||
formatbinary64_test.c | ||
formatflex64_test.c | ||
formathex64_test.c | ||
formatint64_test.c | ||
formatint64thousands_test.c | ||
formatoctal32_test.c | ||
formatoctal64_test.c | ||
imaxdiv_test.c | ||
itoa64radix16_test.c | ||
joinpaths_test.c | ||
lengthuint64_test.c | ||
palandprintf_test.c | ||
sizetol_test.c | ||
sleb128_test.c | ||
sprintf_s.inc | ||
sprintf_s_test.c | ||
sscanf_test.c | ||
strerror_r_test.c | ||
stripexts_test.c | ||
test.mk | ||
timevaltofiletime_test.c | ||
uleb64_test.c | ||
uleb128_test.c | ||
zleb64_test.c |