wc: optionally support very large files in wc
authorDenis Vlasenko <vda.linux@googlemail.com>
Fri, 29 Sep 2006 23:41:59 +0000 (23:41 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Fri, 29 Sep 2006 23:41:59 +0000 (23:41 -0000)
coreutils/Config.in
coreutils/wc.c

index 20b5955d4b58f08cb55cf01e096489fbc7e11dca..6598a8d9c0816374ff6dda7236962cfc43115a9c 100644 (file)
@@ -704,6 +704,13 @@ config CONFIG_WC
          wc is used to print the number of bytes, words, and lines,
          in specified files.
 
+config CONFIG_FEATURE_WC_LARGE
+       bool "Support very large files in wc"
+       default n
+       depends on CONFIG_WC
+       help
+         Use "unsigned long long" in wc for count variables
+
 config CONFIG_WHO
        bool "who"
        default n
index 78a5105da17661450c804760817307abdde77c5c..6ddac4dec47989b853d124f31fd8db57845d2b81 100644 (file)
 #define isspace_given_isprint(c) ((c) == ' ')
 #endif
 
-//#define COUNT_T unsigned long long
-//#define COUNT_FMT "llu"
+#if ENABLE_FEATURE_WC_LARGE
+#define COUNT_T unsigned long long
+#define COUNT_FMT "llu"
+#else
 #define COUNT_T unsigned
 #define COUNT_FMT "u"
+#endif
 
 enum {
        WC_LINES        = 0,
@@ -82,7 +85,7 @@ int wc_main(int argc, char **argv)
        int c;
        char status = EXIT_SUCCESS;
        char in_word;
-       char print_type;
+       unsigned print_type;
 
        print_type = bb_getopt_ulflags(argc, argv, "lwcL");
 
@@ -115,6 +118,8 @@ int wc_main(int argc, char **argv)
                in_word = 0;
 
                do {
+                       /* Our -w doesn't match GNU wc exactly... oh well */
+
                        ++counts[WC_CHARS];
                        c = getc(fp);
                        if (isprint(c)) {