From 38c15becf659ca4860ccb280da13a6bc8d4e3de0 Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Thu, 20 Dec 2001 21:11:59 +0000 Subject: Avoid printing a trailing blank character. --- coreutils/wc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'coreutils/wc.c') diff --git a/coreutils/wc.c b/coreutils/wc.c index fb81c0a8f..8e3b5bbf4 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'); } -- cgit v1.2.3