summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/vfprintf.c
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2005-04-16 22:36:51 +0000
committerdas <das@FreeBSD.org>2005-04-16 22:36:51 +0000
commitbdb6987b1d0507edeab059f66ed6c31db98f1a65 (patch)
treea5f6c9f1e67f01c6fca27366c5bdc6e2c17baf69 /lib/libc/stdio/vfprintf.c
parent9c49c2a65a7716bcd9c75a74df1af7695cfad48f (diff)
downloadFreeBSD-src-bdb6987b1d0507edeab059f66ed6c31db98f1a65.zip
FreeBSD-src-bdb6987b1d0507edeab059f66ed6c31db98f1a65.tar.gz
Be bug-for-bug compatible with the C standard with respect to
printf("%#.0o", 0). Cite an amusing passage from a defect report.
Diffstat (limited to 'lib/libc/stdio/vfprintf.c')
-rw-r--r--lib/libc/stdio/vfprintf.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index ff688e7..790f687 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -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,
OpenPOWER on IntegriCloud