diff options
-rw-r--r-- | coreutils/wc.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/coreutils/wc.c b/coreutils/wc.c index 94f1ee610..15c7692af 100644 --- a/coreutils/wc.c +++ b/coreutils/wc.c | |||
@@ -143,11 +143,15 @@ int wc_main(int argc, char **argv) | |||
143 | return EXIT_SUCCESS; | 143 | return EXIT_SUCCESS; |
144 | } else { | 144 | } else { |
145 | while (optind < argc) { | 145 | while (optind < argc) { |
146 | file = wfopen(argv[optind], "r"); | 146 | if (print_type == print_chars) { |
147 | if (file != NULL) | 147 | struct stat statbuf; |
148 | stat(argv[optind], &statbuf); | ||
149 | print_counts(0, 0, statbuf.st_size, 0, argv[optind]); | ||
150 | total_chars += statbuf.st_size; | ||
151 | } else { | ||
152 | file = xfopen(argv[optind], "r"); | ||
148 | wc_file(file, argv[optind]); | 153 | wc_file(file, argv[optind]); |
149 | else | 154 | } |
150 | status = EXIT_FAILURE; | ||
151 | num_files_counted++; | 155 | num_files_counted++; |
152 | optind++; | 156 | optind++; |
153 | } | 157 | } |