summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-11-25 14:49:32 -0500
committerJakob Kaivo <jkk@ung.org>2019-11-25 14:49:32 -0500
commitc1b0486affa2e0fea086a57565ab88aac630b7f4 (patch)
treea529ee028e25c51ebcdc823f3054bd200e9c1b33
parentfdc345a4d7ff9f55f169eb69e8641bea082d0015 (diff)
clean up output a bit
-rw-r--r--wc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/wc.c b/wc.c
index 378b655..160f6ed 100644
--- a/wc.c
+++ b/wc.c
@@ -52,12 +52,16 @@ static void wc_print(uintmax_t n, uintmax_t w, uintmax_t c, char *f, int flags)
flags = WC_LINES | WC_WORDS | WC_CHARS;
}
+ flags &= (WC_LINES | WC_WORDS | WC_CHARS);
+
if (flags & WC_LINES) {
- printf("%ju%s", n, flags ^ WC_LINES ? " " : "");
+ flags ^= WC_LINES;
+ printf("%ju%s", n, flags ? " " : "");
}
if (flags & WC_WORDS) {
- printf("%ju%s", w, flags ^ (WC_LINES | WC_WORDS) ? " " : "");
+ flags ^= WC_WORDS;
+ printf("%ju%s", w, flags ? " " : "");
}
if (flags & WC_CHARS) {