diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2001-11-21 09:58:29 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2001-11-21 09:58:29 +0000 |
commit | 1477ad8e8319a3ef4623b699083295a0fd560adf (patch) | |
tree | 925f31ac295f91cb6471afdc17a7f6afdad9c7cc /coreutils/wc.c | |
parent | 02d090d3d2623047009a17d47bf09df83285a75e (diff) | |
download | busybox-w32-1477ad8e8319a3ef4623b699083295a0fd560adf.tar.gz busybox-w32-1477ad8e8319a3ef4623b699083295a0fd560adf.tar.bz2 busybox-w32-1477ad8e8319a3ef4623b699083295a0fd560adf.zip |
Simplify print function, prints an extra space if no filename, but saves 4 bytes
Diffstat (limited to 'coreutils/wc.c')
-rw-r--r-- | coreutils/wc.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/coreutils/wc.c b/coreutils/wc.c index 03dd3c3af..728d725a3 100644 --- a/coreutils/wc.c +++ b/coreutils/wc.c | |||
@@ -39,24 +39,21 @@ enum print_e { | |||
39 | static void print_counts(int lines, int words, int chars, int length, | 39 | static void print_counts(int lines, int words, int chars, int length, |
40 | const char *name) | 40 | const char *name) |
41 | { | 41 | { |
42 | char const *space = ""; | ||
43 | |||
44 | if (print_type & print_lines) { | 42 | if (print_type & print_lines) { |
45 | printf("%7d", lines); | 43 | printf("%7d ", lines); |
46 | space = " "; | ||
47 | } | 44 | } |
48 | if (print_type & print_words) { | 45 | if (print_type & print_words) { |
49 | printf("%s%7d", space, words); | 46 | printf("%7d ", words); |
50 | space = " "; | ||
51 | } | 47 | } |
52 | if (print_type & print_chars) { | 48 | if (print_type & print_chars) { |
53 | printf("%s%7d", space, chars); | 49 | printf("%7d ", chars); |
54 | space = " "; | 50 | } |
51 | if (print_type & print_length) { | ||
52 | printf("%7d ", length); | ||
53 | } | ||
54 | if (*name) { | ||
55 | printf("%s", name); | ||
55 | } | 56 | } |
56 | if (print_type & print_length) | ||
57 | printf("%s%7d", space, length); | ||
58 | if (*name) | ||
59 | printf(" %s", name); | ||
60 | putchar('\n'); | 57 | putchar('\n'); |
61 | } | 58 | } |
62 | 59 | ||
@@ -142,7 +139,7 @@ int wc_main(int argc, char **argv) | |||
142 | } | 139 | } |
143 | 140 | ||
144 | if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) { | 141 | if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) { |
145 | wc_file(stdin, ""); | 142 | wc_file(stdin, NULL); |
146 | return EXIT_SUCCESS; | 143 | return EXIT_SUCCESS; |
147 | } else { | 144 | } else { |
148 | while (optind < argc) { | 145 | while (optind < argc) { |