diff options
author | Glenn L McGrath | 2001-11-21 10:26:28 +0000 |
---|---|---|
committer | Glenn L McGrath | 2001-11-21 10:26:28 +0000 |
commit | 74afa9aed1b099c6b0af881760a5de74be521f1f (patch) | |
tree | 67f8b33484ff0430fe8559bbb79bf2ab56f4d3ed /coreutils | |
parent | c29ab9709489a93ba5f740f3a47b96d3bc8ef705 (diff) | |
download | busybox-74afa9aed1b099c6b0af881760a5de74be521f1f.zip busybox-74afa9aed1b099c6b0af881760a5de74be521f1f.tar.gz |
When just counting chars of a file stat file instead of reading the whole file (Fixes Debian bug #103302)
Diffstat (limited to 'coreutils')
-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 94f1ee6..15c7692 100644 --- a/coreutils/wc.c +++ b/coreutils/wc.c @@ -143,11 +143,15 @@ int wc_main(int argc, char **argv) return EXIT_SUCCESS; } else { while (optind < argc) { - file = wfopen(argv[optind], "r"); - if (file != NULL) + if (print_type == print_chars) { + struct stat statbuf; + stat(argv[optind], &statbuf); + print_counts(0, 0, statbuf.st_size, 0, argv[optind]); + total_chars += statbuf.st_size; + } else { + file = xfopen(argv[optind], "r"); wc_file(file, argv[optind]); - else - status = EXIT_FAILURE; + } num_files_counted++; optind++; } |