X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2Fvfprintf.c;h=4c990e5e54fa730c755206a9c5a6b4c597e8b2a3;hb=aed707f679cce80afd929f0efaf080f1e8481330;hp=a8cf41b666c9520fc407ca810fd260d9693dd7f4;hpb=2f3d02cd83a46244c3f5a6fec851d7eded1376f4;p=musl diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c index a8cf41b6..4c990e5e 100644 --- a/src/stdio/vfprintf.c +++ b/src/stdio/vfprintf.c @@ -326,13 +326,15 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t) if (x || d+1!=z) { long double round = CONCAT(0x1p,LDBL_MANT_DIG); long double small; - if (x 999999999) { *d--=0; (*d)++; @@ -341,6 +343,7 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t) for (i=10, e=9*(r-a); *a>=i; i*=10, e++); } } + if (z>d+1) z=d+1; for (; !z[-1] && z>a; z--); } @@ -549,7 +552,7 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg, fl |= ALT_FORM; case 'x': case 'X': a = fmt_x(arg.i, z, t&32); - if (fl & ALT_FORM) prefix+=(t>>4), pl=2; + if (arg.i && (fl & ALT_FORM)) prefix+=(t>>4), pl=2; if (0) { case 'o': a = fmt_o(arg.i, z); @@ -567,8 +570,11 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg, case 'u': a = fmt_u(arg.i, z); } - if (!arg.i && !p) continue; if (p>=0) fl &= ~ZERO_PAD; + if (!arg.i && !p) { + a=z; + break; + } p = MAX(p, z-a + !arg.i); break; case 'c':