forgot to remove some debugging noise
[oweals/busybox.git] / wc.c
diff --git a/wc.c b/wc.c
index ca5b3680a70967b8b938faeef6e3d55b201049b3..f2d33d6f355f2c1155c273f5f2c360cf7b0a30eb 100644 (file)
--- a/wc.c
+++ b/wc.c
  *
  */
 
-#include "internal.h"
 #include <stdio.h>
 #include <getopt.h>
+#include <stdlib.h>
+#include "busybox.h"
 
 static int total_lines, total_words, total_chars, max_length;
 static int print_lines, print_words, print_chars, print_length;
@@ -105,7 +106,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 +126,7 @@ int wc_main(int argc, char **argv)
                                print_words = 1;
                                break;
                        default:
-                               usage(wc_usage);
+                               show_usage();
                        }
        }
 
@@ -134,14 +135,13 @@ int wc_main(int argc, char **argv)
 
        if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
                wc_file(stdin, "");
-               exit(TRUE);
+               return EXIT_SUCCESS;
        } else {
                while (optind < argc) {
-                       file = fopen(argv[optind], "r");
-                       if (file == NULL) {
-                               fatalError(argv[optind]);
-                       }
-                       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++;
                }
@@ -151,5 +151,5 @@ int wc_main(int argc, char **argv)
                print_counts(total_lines, total_words, total_chars,
                                         max_length, "total");
 
-       return ;
+       return status;
 }