summaryrefslogtreecommitdiff
path: root/package/busybox/busybox-1.18.2/busybox-1.18.2-wc.patch
blob: 558896d9b72de28577cc2873b96a1d49331d5021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--- busybox-1.18.2/coreutils/wc.c
+++ busybox-1.18.2-wc/coreutils/wc.c
@@ -81,11 +81,11 @@
  * column order in "wc -cmlwL" output:
  */
 enum {
-	WC_LINES    = 0,
-	WC_WORDS    = 1,
-	WC_UNICHARS = 2,
-	WC_CHARS    = 3,
-	WC_LENGTH   = 4,
+	WC_LINES    = 0, /* -l */
+	WC_WORDS    = 1, /* -w */
+	WC_UNICHARS = 2, /* -m */
+	WC_BYTES    = 3, /* -c */
+	WC_LENGTH   = 4, /* -L */
 	NUM_WCS     = 5,
 };
 
@@ -104,10 +104,10 @@ int wc_main(int argc UNUSED_PARAM, char 
 
 	init_unicode();
 
-	print_type = getopt32(argv, "lwcmL");
+	print_type = getopt32(argv, "lwmcL");
 
 	if (print_type == 0) {
-		print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS);
+		print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_BYTES);
 	}
 
 	argv += optind;
@@ -157,7 +157,7 @@ int wc_main(int argc UNUSED_PARAM, char 
 			}
 
 			/* Cater for -c and -m */
-			++counts[WC_CHARS];
+			++counts[WC_BYTES];
 			if (unicode_status != UNICODE_ON /* every byte is a new char */
 			 || (c & 0xc0) != 0x80 /* it isn't a 2nd+ byte of a Unicode char */
 			) {