mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-10-27 19:34:33 +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 |
||
|---|---|---|
| .. | ||
| bits | ||
| calls | ||
| dns | ||
| fmt | ||
| intrin | ||
| log | ||
| mem | ||
| nexgen32e | ||
| release | ||
| runtime | ||
| sock | ||
| stdio | ||
| str | ||
| thread | ||
| time | ||
| tinymath | ||
| x | ||
| xed | ||
| zipos | ||
| test.mk | ||