wc: Removing output padding
Since the first column is not padded on the left, all the others will not be aligned, so the padding isn't very useful. POSIX says thet output should have the form "%d %d %d %s\n", <newlines>, <words>, <bytes>, <file> so just do that.
This commit is contained in:
parent
27f3ca6063
commit
61f5d4887a
10
wc.c
10
wc.c
@ -15,19 +15,19 @@ output(const char *str, size_t nc, size_t nl, size_t nw)
|
|||||||
int first = 1;
|
int first = 1;
|
||||||
|
|
||||||
if (lflag) {
|
if (lflag) {
|
||||||
if (!first)
|
first = 0;
|
||||||
putchar(' ');
|
printf("%zu", nl);
|
||||||
printf("%*zu", first ? (first = 0) : 6, nl);
|
|
||||||
}
|
}
|
||||||
if (wflag) {
|
if (wflag) {
|
||||||
if (!first)
|
if (!first)
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
printf("%*zu", first ? (first = 0) : 6, nw);
|
first = 0;
|
||||||
|
printf("%zu", nw);
|
||||||
}
|
}
|
||||||
if (cmode) {
|
if (cmode) {
|
||||||
if (!first)
|
if (!first)
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
printf("%*zu", first ? (first = 0) : 6, nc);
|
printf("%zu", nc);
|
||||||
}
|
}
|
||||||
if (str)
|
if (str)
|
||||||
printf(" %s", str);
|
printf(" %s", str);
|
||||||
|
Loading…
Reference in New Issue
Block a user