fix printf regression with alt-form octal, zero flag, and field width
[musl] / src / stdio / vfprintf.c
index d421817..e439a07 100644 (file)
@@ -225,7 +225,7 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t)
 
        if (!isfinite(y)) {
                char *s = (t&32)?"inf":"INF";
-               if (y!=y) s=(t&32)?"nan":"NAN", pl=0;
+               if (y!=y) s=(t&32)?"nan":"NAN";
                pad(f, ' ', w, 3+pl, fl&~ZERO_PAD);
                out(f, prefix, pl);
                out(f, s, 3);
@@ -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) && p<z-a+1) p=z-a+1;
+                       if ((fl&ALT_FORM) && p<z-a+1) prefix+=5, pl=1;
                        } if (0) {
                case 'd': case 'i':
                        pl=1;