summaryrefslogtreecommitdiff
path: root/src/stdio
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2016-03-16 16:35:22 -0400
committerRich Felker <dalias@aerifal.cx>2016-03-16 16:35:22 -0400
commit4aac019a0efd59011a48d031ad046c934c7e8365 (patch)
tree2604d4e94d02d86070b574da41ff9121b0981cf3 /src/stdio
parentde400b6609becbc6a5ae87fa8b155f02a860e257 (diff)
downloadmusl-4aac019a0efd59011a48d031ad046c934c7e8365.tar.gz
musl-4aac019a0efd59011a48d031ad046c934c7e8365.tar.bz2
musl-4aac019a0efd59011a48d031ad046c934c7e8365.tar.xz
musl-4aac019a0efd59011a48d031ad046c934c7e8365.zip
fix padding string formats to width in wide printf variants
the idiom fprintf(f, "%.*s", n, "") was wrongly used in vfwprintf as a means of producing n spaces; instead it produces no output. the correct form is fprintf(f, "%*s", n, ""), using width instead of precision, since for %s the later is a maximum rather than a minimum.
Diffstat (limited to 'src/stdio')
-rw-r--r--src/stdio/vfwprintf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c
index f06d5aed..f9f1ecfd 100644
--- a/src/stdio/vfwprintf.c
+++ b/src/stdio/vfwprintf.c
@@ -288,9 +288,9 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
z = wmemchr(a, 0, p);
if (z) p=z-a;
if (w<p) w=p;
- if (!(fl&LEFT_ADJ)) fprintf(f, "%.*s", w-p, "");
+ if (!(fl&LEFT_ADJ)) fprintf(f, "%*s", w-p, "");
out(f, a, p);
- if ((fl&LEFT_ADJ)) fprintf(f, "%.*s", w-p, "");
+ if ((fl&LEFT_ADJ)) fprintf(f, "%*s", w-p, "");
l=w;
continue;
case 'm':
@@ -303,14 +303,14 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
if (i<0) return -1;
p=l;
if (w<p) w=p;
- if (!(fl&LEFT_ADJ)) fprintf(f, "%.*s", w-p, "");
+ if (!(fl&LEFT_ADJ)) fprintf(f, "%*s", w-p, "");
bs = arg.p;
while (l--) {
i=mbtowc(&wc, bs, MB_LEN_MAX);
bs+=i;
fputwc(wc, f);
}
- if ((fl&LEFT_ADJ)) fprintf(f, "%.*s", w-p, "");
+ if ((fl&LEFT_ADJ)) fprintf(f, "%*s", w-p, "");
l=w;
continue;
}