wc: Make output POSIX compliant

This commit is contained in:
sin 2015-02-06 19:46:37 +00:00
parent 0c8fe5d19b
commit 39802832af

7
wc.c
View File

@ -17,13 +17,14 @@ void
output(const char *str, size_t nc, size_t nl, size_t nw)
{
int noflags = !cmode && !lflag && !wflag;
int first = 1;
if (lflag || noflags)
printf(" %5zu", nl);
printf("%*.zu", first ? (first = 0) : 7, nl);
if (wflag || noflags)
printf(" %5zu", nw);
printf("%*.zu", first ? (first = 0) : 7, nw);
if (cmode || noflags)
printf(" %5zu", nc);
printf("%*.zu", first ? (first = 0) : 7, nc);
if (str)
printf(" %s", str);
putchar('\n');