Be bug-for-bug compatible with the C standard with respect to

printf("%#.0o", 0).  Cite an amusing passage from a defect report.
This commit is contained in:
David Schultz 2005-04-16 22:36:51 +00:00
parent a4ca7ca8ac
commit 1be5319a76
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=145172
2 changed files with 16 additions and 4 deletions

View file

@ -1093,16 +1093,22 @@ number: if ((dprec = prec) >= 0)
* ``The result of converting a zero value with an
* explicit precision of zero is no characters.''
* -- ANSI X3J11
*
* ``The C Standard is clear enough as is. The call
* printf("%#.0o", 0) should print 0.''
* -- Defect Report #151
*/
cp = buf + BUF;
if (flags & INTMAX_SIZE) {
if (ujval != 0 || prec != 0)
if (ujval != 0 || prec != 0 ||
(flags & ALT && base == 8))
cp = __ujtoa(ujval, cp, base,
flags & ALT, xdigs,
flags & GROUPING, thousands_sep,
grouping);
} else {
if (ulval != 0 || prec != 0)
if (ulval != 0 || prec != 0 ||
(flags & ALT && base == 8))
cp = __ultoa(ulval, cp, base,
flags & ALT, xdigs,
flags & GROUPING, thousands_sep,

View file

@ -1092,16 +1092,22 @@ number: if ((dprec = prec) >= 0)
* ``The result of converting a zero value with an
* explicit precision of zero is no characters.''
* -- ANSI X3J11
*
* ``The C Standard is clear enough as is. The call
* printf("%#.0o", 0) should print 0.''
* -- Defect Report #151
*/
cp = buf + BUF;
if (flags & INTMAX_SIZE) {
if (ujval != 0 || prec != 0)
if (ujval != 0 || prec != 0 ||
(flags & ALT && base == 8))
cp = __ujtoa(ujval, cp, base,
flags & ALT, xdigs,
flags & GROUPING, thousands_sep,
grouping);
} else {
if (ulval != 0 || prec != 0)
if (ulval != 0 || prec != 0 ||
(flags & ALT && base == 8))
cp = __ultoa(ulval, cp, base,
flags & ALT, xdigs,
flags & GROUPING, thousands_sep,