mirror of
https://github.com/sheumann/hush.git
synced 2025-01-03 16:29:50 +00:00
Simplify print function, prints an extra space if no filename, but saves 4 bytes
This commit is contained in:
parent
02d090d3d2
commit
1477ad8e83
@ -39,24 +39,21 @@ enum print_e {
|
|||||||
static void print_counts(int lines, int words, int chars, int length,
|
static void print_counts(int lines, int words, int chars, int length,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
char const *space = "";
|
|
||||||
|
|
||||||
if (print_type & print_lines) {
|
if (print_type & print_lines) {
|
||||||
printf("%7d", lines);
|
printf("%7d ", lines);
|
||||||
space = " ";
|
|
||||||
}
|
}
|
||||||
if (print_type & print_words) {
|
if (print_type & print_words) {
|
||||||
printf("%s%7d", space, words);
|
printf("%7d ", words);
|
||||||
space = " ";
|
|
||||||
}
|
}
|
||||||
if (print_type & print_chars) {
|
if (print_type & print_chars) {
|
||||||
printf("%s%7d", space, chars);
|
printf("%7d ", chars);
|
||||||
space = " ";
|
}
|
||||||
|
if (print_type & print_length) {
|
||||||
|
printf("%7d ", length);
|
||||||
|
}
|
||||||
|
if (*name) {
|
||||||
|
printf("%s", name);
|
||||||
}
|
}
|
||||||
if (print_type & print_length)
|
|
||||||
printf("%s%7d", space, length);
|
|
||||||
if (*name)
|
|
||||||
printf(" %s", name);
|
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +139,7 @@ int wc_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
|
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
|
||||||
wc_file(stdin, "");
|
wc_file(stdin, NULL);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
while (optind < argc) {
|
while (optind < argc) {
|
||||||
|
Loading…
Reference in New Issue
Block a user