[hackers] [sbase] wc: Removing output padding || Michael Forney
commit 61f5d4887aa62c67d0888992adfe0eafe834d030
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Sat Dec 21 20:19:08 2019 -0800
Commit: Michael Forney <mforney_AT_mforney.org>
CommitDate: Sat Dec 21 20:19:08 2019 -0800
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.
diff --git a/wc.c b/wc.c
index 3ac530e..c89d19f 100644
--- a/wc.c
+++ b/wc.c
_AT_@ -15,19 +15,19 @@ output(const char *str, size_t nc, size_t nl, size_t nw)
int first = 1;
if (lflag) {
- if (!first)
- putchar(' ');
- printf("%*zu", first ? (first = 0) : 6, nl);
+ first = 0;
+ printf("%zu", nl);
}
if (wflag) {
if (!first)
putchar(' ');
- printf("%*zu", first ? (first = 0) : 6, nw);
+ first = 0;
+ printf("%zu", nw);
}
if (cmode) {
if (!first)
putchar(' ');
- printf("%*zu", first ? (first = 0) : 6, nc);
+ printf("%zu", nc);
}
if (str)
printf(" %s", str);
Received on Sun Dec 22 2019 - 05:26:26 CET
This archive was generated by hypermail 2.3.0
: Sun Dec 22 2019 - 05:36:23 CET