When just counting chars of a file stat file instead of reading the whole file (Fixes Debian bug #103302)
This commit is contained in:
parent
c29ab97094
commit
74afa9aed1
@ -143,11 +143,15 @@ int wc_main(int argc, char **argv)
|
|||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
while (optind < argc) {
|
while (optind < argc) {
|
||||||
file = wfopen(argv[optind], "r");
|
if (print_type == print_chars) {
|
||||||
if (file != NULL)
|
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]);
|
wc_file(file, argv[optind]);
|
||||||
else
|
}
|
||||||
status = EXIT_FAILURE;
|
|
||||||
num_files_counted++;
|
num_files_counted++;
|
||||||
optind++;
|
optind++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user