diff options
author | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-11-21 10:26:28 +0000 |
---|---|---|
committer | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-11-21 10:26:28 +0000 |
commit | 4ffde9be906afd2c0a3f74835dc607070d41e44c (patch) | |
tree | 67f8b33484ff0430fe8559bbb79bf2ab56f4d3ed /coreutils/wc.c | |
parent | b6f6aa32a5348df1761e8a6f33126902d586a399 (diff) | |
download | busybox-w32-4ffde9be906afd2c0a3f74835dc607070d41e44c.tar.gz busybox-w32-4ffde9be906afd2c0a3f74835dc607070d41e44c.tar.bz2 busybox-w32-4ffde9be906afd2c0a3f74835dc607070d41e44c.zip |
When just counting chars of a file stat file instead of reading the whole file (Fixes Debian bug #103302)
git-svn-id: svn://busybox.net/trunk/busybox@3770 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'coreutils/wc.c')
-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 | } |