wc: Show line/char/word count even if it's zero

Fix a bug where if a line, character or word count is zero, it's not
printed
This commit is contained in:
Dionysis Grigoropoulos 2015-04-01 03:15:17 +03:00 committed by sin
parent bf90e85f18
commit bbd2b4d243

6
wc.c
View File

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