]> git.pld-linux.org Git - packages/busybox.git/blame - busybox-1.14.2-ls.patch
- up to 1.14.2
[packages/busybox.git] / busybox-1.14.2-ls.patch
CommitLineData
8eece0a4
AM
1diff -urpN busybox-1.14.2/coreutils/ls.c busybox-1.14.2-ls/coreutils/ls.c
2--- busybox-1.14.2/coreutils/ls.c 2009-06-22 00:40:29.000000000 +0200
3+++ busybox-1.14.2-ls/coreutils/ls.c 2009-07-03 12:46:16.000000000 +0200
4@@ -144,8 +144,7 @@ static const char ls_options[] ALIGN1 =
5 USE_FEATURE_LS_FOLLOWLINKS("L") /* 1, 24 */
6 USE_FEATURE_LS_RECURSIVE("R") /* 1, 25 */
7 USE_FEATURE_HUMAN_READABLE("h") /* 1, 26 */
8- USE_SELINUX("K") /* 1, 27 */
9- USE_SELINUX("Z") /* 1, 28 */
10+ USE_SELINUX("KZ") /* 2, 28 */
11 USE_FEATURE_AUTOWIDTH("T:w:") /* 2, 30 */
12 ;
13 enum {
14@@ -162,6 +161,16 @@ enum {
15 OPT_Q = (1 << 10),
16 //OPT_A = (1 << 11),
17 //OPT_k = (1 << 12),
18+ OPTBIT_color = 13
19+ + 4 * ENABLE_FEATURE_LS_TIMESTAMPS
20+ + 4 * ENABLE_FEATURE_LS_SORTFILES
21+ + 2 * ENABLE_FEATURE_LS_FILETYPES
22+ + 1 * ENABLE_FEATURE_LS_FOLLOWLINKS
23+ + 1 * ENABLE_FEATURE_LS_RECURSIVE
24+ + 1 * ENABLE_FEATURE_HUMAN_READABLE
25+ + 2 * ENABLE_SELINUX
26+ + 2 * ENABLE_FEATURE_AUTOWIDTH,
27+ OPT_color = 1 << OPTBIT_color,
28 };
29
30 enum {
31@@ -889,16 +898,6 @@ static int list_single(const struct dnod
32 }
33
34
35-/* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
36-#if ENABLE_FEATURE_LS_COLOR
37-/* long option entry used only for --color, which has no short option
38- * equivalent */
39-static const char ls_color_opt[] ALIGN1 =
40- "color\0" Optional_argument "\xff" /* no short equivalent */
41- ;
42-#endif
43-
44-
45 int ls_main(int argc UNUSED_PARAM, char **argv)
46 {
47 struct dnode **dnd;
48@@ -911,8 +910,25 @@ int ls_main(int argc UNUSED_PARAM, char
49 int dnfiles;
50 int dndirs;
51 int i;
52+#if ENABLE_FEATURE_LS_COLOR
53+ /* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
54+ /* coreutils 6.10:
55+ * # ls --color=BOGUS
56+ * ls: invalid argument 'BOGUS' for '--color'
57+ * Valid arguments are:
58+ * 'always', 'yes', 'force'
59+ * 'never', 'no', 'none'
60+ * 'auto', 'tty', 'if-tty'
61+ * (and substrings: "--color=alwa" work too)
62+ */
63+ static const char ls_longopts[] ALIGN1 =
64+ "color\0" Optional_argument "\xff"; /* no short equivalent */
65+ static const char color_str[] ALIGN1 =
66+ "always\0""yes\0""force\0"
67+ "auto\0""tty\0""if-tty\0";
68 /* need to initialize since --color has _an optional_ argument */
69- USE_FEATURE_LS_COLOR(const char *color_opt = "always";)
70+ const char *color_opt = color_str; /* "always" */
71+#endif
72
73 INIT_G();
74
75@@ -927,7 +943,7 @@ int ls_main(int argc UNUSED_PARAM, char
76 #endif
77
78 /* process options */
79- USE_FEATURE_LS_COLOR(applet_long_options = ls_color_opt;)
80+ USE_FEATURE_LS_COLOR(applet_long_options = ls_longopts;)
81 #if ENABLE_FEATURE_AUTOWIDTH
82 opt_complementary = "T+:w+"; /* -T N, -w N */
83 opt = getopt32(argv, ls_options, &tabstops, &terminal_width
84@@ -966,13 +982,20 @@ int ls_main(int argc UNUSED_PARAM, char
85 if (!p || (p[0] && strcmp(p, "none") != 0))
86 show_color = 1;
87 }
88- if (opt & (1 << i)) { /* next flag after short options */
89- if (strcmp("always", color_opt) == 0)
90- show_color = 1;
91- else if (strcmp("never", color_opt) == 0)
92+ if (opt & OPT_color) {
93+ if (color_opt[0] == 'n')
94 show_color = 0;
95- else if (strcmp("auto", color_opt) == 0 && isatty(STDOUT_FILENO))
96- show_color = 1;
97+ else switch (index_in_substrings(color_str, color_opt)) {
98+ case 3:
99+ case 4:
100+ case 5:
101+ if (isatty(STDOUT_FILENO)) {
102+ case 0:
103+ case 1:
104+ case 2:
105+ show_color = 1;
106+ }
107+ }
108 }
109 #endif
110
111diff -urpN busybox-1.14.2/testsuite/ls/ls-1-works busybox-1.14.2-ls/testsuite/ls/ls-1-works
112--- busybox-1.14.2/testsuite/ls/ls-1-works 2009-06-22 00:32:00.000000000 +0200
113+++ busybox-1.14.2-ls/testsuite/ls/ls-1-works 2009-07-02 14:28:45.000000000 +0200
114@@ -1,4 +1,4 @@
115 [ -n "$d" ] || d=..
116-ls -1 "$d" > logfile.gnu
117-busybox ls -1 "$d" > logfile.bb
118-cmp logfile.gnu logfile.bb
119+LC_ALL=C ls -1 "$d" > logfile.gnu
120+LC_ALL=C busybox ls -1 "$d" > logfile.bb
121+diff -ubw logfile.gnu logfile.bb
122diff -urpN busybox-1.14.2/testsuite/ls/ls-h-works busybox-1.14.2-ls/testsuite/ls/ls-h-works
123--- busybox-1.14.2/testsuite/ls/ls-h-works 2009-06-22 00:32:00.000000000 +0200
124+++ busybox-1.14.2-ls/testsuite/ls/ls-h-works 2009-07-02 14:28:45.000000000 +0200
125@@ -1,4 +1,4 @@
126 [ -n "$d" ] || d=..
127-ls -h "$d" > logfile.gnu
128-busybox ls -h "$d" > logfile.bb
129-cmp logfile.gnu logfile.bb
130+LC_ALL=C ls -h "$d" > logfile.gnu
131+LC_ALL=C busybox ls -h "$d" > logfile.bb
132+diff -ubw logfile.gnu logfile.bb
133diff -urpN busybox-1.14.2/testsuite/ls/ls-l-works busybox-1.14.2-ls/testsuite/ls/ls-l-works
134--- busybox-1.14.2/testsuite/ls/ls-l-works 2009-06-22 00:32:00.000000000 +0200
135+++ busybox-1.14.2-ls/testsuite/ls/ls-l-works 2009-07-02 14:28:45.000000000 +0200
136@@ -1,4 +1,4 @@
137 [ -n "$d" ] || d=..
138 LC_ALL=C ls -l "$d" > logfile.gnu
139-busybox ls -l "$d" > logfile.bb
140-diff -w logfile.gnu logfile.bb
141+LC_ALL=C busybox ls -l "$d" > logfile.bb
142+diff -ubw logfile.gnu logfile.bb
143diff -urpN busybox-1.14.2/testsuite/ls/ls-s-works busybox-1.14.2-ls/testsuite/ls/ls-s-works
144--- busybox-1.14.2/testsuite/ls/ls-s-works 2009-06-22 00:32:00.000000000 +0200
145+++ busybox-1.14.2-ls/testsuite/ls/ls-s-works 2009-07-02 14:28:45.000000000 +0200
146@@ -1,4 +1,4 @@
147 [ -n "$d" ] || d=..
148 LC_ALL=C ls -1s "$d" > logfile.gnu
149-busybox ls -1s "$d" > logfile.bb
150-cmp logfile.gnu logfile.bb
151+LC_ALL=C busybox ls -1s "$d" > logfile.bb
152+diff -ubw logfile.gnu logfile.bb
This page took 0.049119 seconds and 4 git commands to generate.