diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-29 23:41:59 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-29 23:41:59 +0000 |
| commit | 70210168fcb1fb9bdbcd6fe92509cd9b1ef46eb9 (patch) | |
| tree | 6a277dce1252ee2625563c718fdc60b4c3a5a91f /coreutils | |
| parent | 3ed001ff2631ad6911096148f47a2719a5b6d4f4 (diff) | |
| download | busybox-w32-70210168fcb1fb9bdbcd6fe92509cd9b1ef46eb9.tar.gz busybox-w32-70210168fcb1fb9bdbcd6fe92509cd9b1ef46eb9.tar.bz2 busybox-w32-70210168fcb1fb9bdbcd6fe92509cd9b1ef46eb9.zip | |
wc: optionally support very large files in wc
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/Config.in | 7 | ||||
| -rw-r--r-- | coreutils/wc.c | 11 |
2 files changed, 15 insertions, 3 deletions
diff --git a/coreutils/Config.in b/coreutils/Config.in index 20b5955d4..6598a8d9c 100644 --- a/coreutils/Config.in +++ b/coreutils/Config.in | |||
| @@ -704,6 +704,13 @@ config CONFIG_WC | |||
| 704 | wc is used to print the number of bytes, words, and lines, | 704 | wc is used to print the number of bytes, words, and lines, |
| 705 | in specified files. | 705 | in specified files. |
| 706 | 706 | ||
| 707 | config CONFIG_FEATURE_WC_LARGE | ||
| 708 | bool "Support very large files in wc" | ||
| 709 | default n | ||
| 710 | depends on CONFIG_WC | ||
| 711 | help | ||
| 712 | Use "unsigned long long" in wc for count variables | ||
| 713 | |||
| 707 | config CONFIG_WHO | 714 | config CONFIG_WHO |
| 708 | bool "who" | 715 | bool "who" |
| 709 | default n | 716 | default n |
diff --git a/coreutils/wc.c b/coreutils/wc.c index 78a5105da..6ddac4dec 100644 --- a/coreutils/wc.c +++ b/coreutils/wc.c | |||
| @@ -55,10 +55,13 @@ | |||
| 55 | #define isspace_given_isprint(c) ((c) == ' ') | 55 | #define isspace_given_isprint(c) ((c) == ' ') |
| 56 | #endif | 56 | #endif |
| 57 | 57 | ||
| 58 | //#define COUNT_T unsigned long long | 58 | #if ENABLE_FEATURE_WC_LARGE |
| 59 | //#define COUNT_FMT "llu" | 59 | #define COUNT_T unsigned long long |
| 60 | #define COUNT_FMT "llu" | ||
| 61 | #else | ||
| 60 | #define COUNT_T unsigned | 62 | #define COUNT_T unsigned |
| 61 | #define COUNT_FMT "u" | 63 | #define COUNT_FMT "u" |
| 64 | #endif | ||
| 62 | 65 | ||
| 63 | enum { | 66 | enum { |
| 64 | WC_LINES = 0, | 67 | WC_LINES = 0, |
| @@ -82,7 +85,7 @@ int wc_main(int argc, char **argv) | |||
| 82 | int c; | 85 | int c; |
| 83 | char status = EXIT_SUCCESS; | 86 | char status = EXIT_SUCCESS; |
| 84 | char in_word; | 87 | char in_word; |
| 85 | char print_type; | 88 | unsigned print_type; |
| 86 | 89 | ||
| 87 | print_type = bb_getopt_ulflags(argc, argv, "lwcL"); | 90 | print_type = bb_getopt_ulflags(argc, argv, "lwcL"); |
| 88 | 91 | ||
| @@ -115,6 +118,8 @@ int wc_main(int argc, char **argv) | |||
| 115 | in_word = 0; | 118 | in_word = 0; |
| 116 | 119 | ||
| 117 | do { | 120 | do { |
| 121 | /* Our -w doesn't match GNU wc exactly... oh well */ | ||
| 122 | |||
| 118 | ++counts[WC_CHARS]; | 123 | ++counts[WC_CHARS]; |
| 119 | c = getc(fp); | 124 | c = getc(fp); |
| 120 | if (isprint(c)) { | 125 | if (isprint(c)) { |
