about summary refs log tree commit diff
path: root/src/stdio
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014-11-15 12:16:19 -0500
committerRich Felker <dalias@aerifal.cx>2014-11-15 12:16:19 -0500
commitb91cdbe2bc8b626aa04dc6e3e84345accf34e4b1 (patch)
treec99c9119aceee45a9d88f2a4f0a90cf50942270c /src/stdio
parentec4318943a26d4bd4050481d11709853184f2794 (diff)
downloadmusl-b91cdbe2bc8b626aa04dc6e3e84345accf34e4b1.tar.gz
musl-b91cdbe2bc8b626aa04dc6e3e84345accf34e4b1.tar.xz
musl-b91cdbe2bc8b626aa04dc6e3e84345accf34e4b1.zip
fix behavior of printf with alt-form octal, zero precision, zero value
in this case there are two conflicting rules in play: that an explicit
precision of zero with the value zero produces no output, and that the
'#' modifier for octal increases the precision sufficiently to yield a
leading zero. ISO C (7.19.6.1 paragraph 6 in C99+TC3) includes a
parenthetical remark to clarify that the precision-increasing behavior
takes precedence, but the corresponding text in POSIX off of which I
based the implementation is missing this remark.

this issue was covered in WG14 DR#151.
Diffstat (limited to 'src/stdio')
-rw-r--r--src/stdio/vfprintf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
index ea257720..39c1e867 100644
--- a/src/stdio/vfprintf.c
+++ b/src/stdio/vfprintf.c
@@ -570,7 +570,7 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
 			if (0) {
 		case 'o':
 			a = fmt_o(arg.i, z);
-			if ((fl&ALT_FORM) && arg.i) prefix+=5, pl=1;
+			if ((fl&ALT_FORM) && p<z-a+1) p=z-a+1;
 			} if (0) {
 		case 'd': case 'i':
 			pl=1;