aboutsummaryrefslogtreecommitdiff
path: root/coreutils/wc.c
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2001-11-21 10:26:28 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2001-11-21 10:26:28 +0000
commit74afa9aed1b099c6b0af881760a5de74be521f1f (patch)
tree67f8b33484ff0430fe8559bbb79bf2ab56f4d3ed /coreutils/wc.c
parentc29ab9709489a93ba5f740f3a47b96d3bc8ef705 (diff)
downloadbusybox-w32-74afa9aed1b099c6b0af881760a5de74be521f1f.tar.gz
busybox-w32-74afa9aed1b099c6b0af881760a5de74be521f1f.tar.bz2
busybox-w32-74afa9aed1b099c6b0af881760a5de74be521f1f.zip
When just counting chars of a file stat file instead of reading the whole file (Fixes Debian bug #103302)
Diffstat (limited to 'coreutils/wc.c')
-rw-r--r--coreutils/wc.c12
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 }