summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorMatt Kraai2001-12-20 21:11:59 +0000
committerMatt Kraai2001-12-20 21:11:59 +0000
commit38c15becf659ca4860ccb280da13a6bc8d4e3de0 (patch)
treebded2b469ab9008b69ba87ab54d58e4c19b9a822 /coreutils
parent5a841adf5d359679be47645e730e5333caf929b9 (diff)
downloadbusybox-38c15becf659ca4860ccb280da13a6bc8d4e3de0.zip
busybox-38c15becf659ca4860ccb280da13a6bc8d4e3de0.tar.gz
Avoid printing a trailing blank character.
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/wc.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/coreutils/wc.c b/coreutils/wc.c
index fb81c0a..8e3b5bb 100644
--- a/coreutils/wc.c
+++ b/coreutils/wc.c
@@ -42,20 +42,29 @@ static char print_type = 0;
static void print_counts(const unsigned int lines, const unsigned int words,
const unsigned int chars, const unsigned int length, const char *name)
{
+ int output = 0;
+
if (print_type & print_lines) {
- printf("%7d ", lines);
+ printf("%7d", lines);
+ output++;
}
if (print_type & print_words) {
- printf("%7d ", words);
+ if (output++)
+ putchar(' ');
+ printf("%7d", words);
}
if (print_type & print_chars) {
- printf("%7d ", chars);
+ if (output++)
+ putchar(' ');
+ printf("%7d", chars);
}
if (print_type & print_length) {
- printf("%7d ", length);
+ if (output++)
+ putchar(' ');
+ printf("%7d", length);
}
if (*name) {
- printf("%s", name);
+ printf(" %s", name);
}
putchar('\n');
}