X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=coreutils%2Fwc.c;h=695e7e7d4e4b765b1954d5ecb5d9ea11f1128a10;hb=a6ce670a87ee77ccb9337ed6d87442134e1a48ed;hp=9d569459de63bc5cb9bda2af312b494835a962b6;hpb=bbaef66b3f99213f06adf04df6b3e5e61278d75b;p=oweals%2Fbusybox.git diff --git a/coreutils/wc.c b/coreutils/wc.c index 9d569459d..695e7e7d4 100644 --- a/coreutils/wc.c +++ b/coreutils/wc.c @@ -20,15 +20,17 @@ * */ -#include "busybox.h" #include #include +#include +#include +#include "busybox.h" static int total_lines, total_words, total_chars, max_length; static int print_lines, print_words, print_chars, print_length; -void print_counts(int lines, int words, int chars, int length, - const char *name) +static void print_counts(int lines, int words, int chars, int length, + const char *name) { char const *space = ""; @@ -105,7 +107,7 @@ int wc_main(int argc, char **argv) { FILE *file; unsigned int num_files_counted = 0; - int opt; + int opt, status = EXIT_SUCCESS; total_lines = total_words = total_chars = max_length = 0; print_lines = print_words = print_chars = print_length = 0; @@ -125,7 +127,7 @@ int wc_main(int argc, char **argv) print_words = 1; break; default: - usage(wc_usage); + show_usage(); } } @@ -137,8 +139,10 @@ int wc_main(int argc, char **argv) return EXIT_SUCCESS; } else { while (optind < argc) { - file = xfopen(argv[optind], "r"); - wc_file(file, argv[optind]); + if ((file = wfopen(argv[optind], "r")) != NULL) + wc_file(file, argv[optind]); + else + status = EXIT_FAILURE; num_files_counted++; optind++; } @@ -148,5 +152,5 @@ int wc_main(int argc, char **argv) print_counts(total_lines, total_words, total_chars, max_length, "total"); - return EXIT_SUCCESS; + return status; }