aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-12-19 05:43:44 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-12-19 05:43:44 +0100
commitd87815d5e0721176ee13776956f648e660c895d5 (patch)
treeeb73a216e86ca9e1c73316161f9e367a789cb1b3 /coreutils
parentf313746a6d7b992918386a5e6db1cfc8f4da30fd (diff)
downloadbusybox-w32-d87815d5e0721176ee13776956f648e660c895d5.tar.gz
busybox-w32-d87815d5e0721176ee13776956f648e660c895d5.tar.bz2
busybox-w32-d87815d5e0721176ee13776956f648e660c895d5.zip
ls: make -x force columnar output; remove unused parts of TRIGGER code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/ls.c73
1 files changed, 30 insertions, 43 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 8d1f91921..f515f9f8f 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -56,7 +56,7 @@ TERMINAL_WIDTH = 80, /* use 79 if terminal has linefold bug */
56COLUMN_GAP = 2, /* includes the file type char */ 56COLUMN_GAP = 2, /* includes the file type char */
57 57
58/* what is the overall style of the listing */ 58/* what is the overall style of the listing */
59STYLE_COLUMNS = 1 << 21, /* fill columns */ 59STYLE_COLUMNAR = 1 << 21, /* many records per line */
60STYLE_LONG = 2 << 21, /* one record per line, extended info */ 60STYLE_LONG = 2 << 21, /* one record per line, extended info */
61STYLE_SINGLE = 3 << 21, /* one record per line */ 61STYLE_SINGLE = 3 << 21, /* one record per line */
62STYLE_MASK = STYLE_SINGLE, 62STYLE_MASK = STYLE_SINGLE,
@@ -167,52 +167,45 @@ enum {
167 OPT_color = 1 << OPTBIT_color, 167 OPT_color = 1 << OPTBIT_color,
168}; 168};
169 169
170enum {
171 LIST_MASK_TRIGGER = 0,
172 STYLE_MASK_TRIGGER = STYLE_MASK,
173 DISP_MASK_TRIGGER = DISP_ROWS,
174 SORT_MASK_TRIGGER = SORT_MASK,
175};
176
177/* TODO: simple toggles may be stored as OPT_xxx bits instead */ 170/* TODO: simple toggles may be stored as OPT_xxx bits instead */
178static const unsigned opt_flags[] = { 171static const unsigned opt_flags[] = {
179 LIST_SHORT | STYLE_COLUMNS, /* C */ 172 LIST_SHORT | STYLE_COLUMNAR, /* C */
180 DISP_HIDDEN | DISP_DOT, /* a */ 173 DISP_HIDDEN | DISP_DOT, /* a */
181 DISP_NOLIST, /* d */ 174 DISP_NOLIST, /* d */
182 LIST_INO, /* i */ 175 LIST_INO, /* i */
183 LIST_LONG | STYLE_LONG, /* l - remember LS_DISP_HR in mask! */ 176 LIST_LONG | STYLE_LONG, /* l - remember LS_DISP_HR in mask! */
184 LIST_SHORT | STYLE_SINGLE, /* 1 */ 177 LIST_SHORT | STYLE_SINGLE, /* 1 */
185 0, /* g (don't show owner) - handled via OPT_g */ 178 0, /* g (don't show owner) - handled via OPT_g */
186 LIST_ID_NUMERIC, /* n */ 179 LIST_ID_NUMERIC, /* n */
187 LIST_BLOCKS, /* s */ 180 LIST_BLOCKS, /* s */
188 DISP_ROWS, /* x */ 181 LIST_SHORT | DISP_ROWS | STYLE_COLUMNAR, /* x */
189 0, /* Q (quote filename) - handled via OPT_Q */ 182 0, /* Q (quote filename) - handled via OPT_Q */
190 DISP_HIDDEN, /* A */ 183 DISP_HIDDEN, /* A */
191 ENABLE_SELINUX * LIST_CONTEXT, /* k (ignored if !SELINUX) */ 184 ENABLE_SELINUX * LIST_CONTEXT, /* k (ignored if !SELINUX) */
192#if ENABLE_FEATURE_LS_TIMESTAMPS 185#if ENABLE_FEATURE_LS_TIMESTAMPS
193 TIME_CHANGE | (ENABLE_FEATURE_LS_SORTFILES * SORT_CTIME), /* c */ 186 TIME_CHANGE | (ENABLE_FEATURE_LS_SORTFILES * SORT_CTIME), /* c */
194 LIST_FULLTIME, /* e */ 187 LIST_FULLTIME, /* e */
195 ENABLE_FEATURE_LS_SORTFILES * SORT_MTIME, /* t */ 188 ENABLE_FEATURE_LS_SORTFILES * SORT_MTIME, /* t */
196 TIME_ACCESS | (ENABLE_FEATURE_LS_SORTFILES * SORT_ATIME), /* u */ 189 TIME_ACCESS | (ENABLE_FEATURE_LS_SORTFILES * SORT_ATIME), /* u */
197#endif 190#endif
198#if ENABLE_FEATURE_LS_SORTFILES 191#if ENABLE_FEATURE_LS_SORTFILES
199 SORT_SIZE, /* S */ 192 SORT_SIZE, /* S */
200 SORT_EXT, /* X */ 193 SORT_EXT, /* X */
201 SORT_REVERSE, /* r */ 194 SORT_REVERSE, /* r */
202 SORT_VERSION, /* v */ 195 SORT_VERSION, /* v */
203#endif 196#endif
204#if ENABLE_FEATURE_LS_FILETYPES 197#if ENABLE_FEATURE_LS_FILETYPES
205 LIST_FILETYPE | LIST_EXEC, /* F */ 198 LIST_FILETYPE | LIST_EXEC, /* F */
206 LIST_FILETYPE, /* p */ 199 LIST_FILETYPE, /* p */
207#endif 200#endif
208#if ENABLE_FEATURE_LS_FOLLOWLINKS 201#if ENABLE_FEATURE_LS_FOLLOWLINKS
209 FOLLOW_LINKS, /* L */ 202 FOLLOW_LINKS, /* L */
210#endif 203#endif
211#if ENABLE_FEATURE_LS_RECURSIVE 204#if ENABLE_FEATURE_LS_RECURSIVE
212 DISP_RECURSIVE, /* R */ 205 DISP_RECURSIVE, /* R */
213#endif 206#endif
214#if ENABLE_FEATURE_HUMAN_READABLE 207#if ENABLE_FEATURE_HUMAN_READABLE
215 LS_DISP_HR, /* h */ 208 LS_DISP_HR, /* h */
216#endif 209#endif
217#if ENABLE_SELINUX 210#if ENABLE_SELINUX
218 LIST_MODEBITS|LIST_NLINKS|LIST_CONTEXT|LIST_SIZE|LIST_DATE_TIME, /* K */ 211 LIST_MODEBITS|LIST_NLINKS|LIST_CONTEXT|LIST_SIZE|LIST_DATE_TIME, /* K */
@@ -547,7 +540,7 @@ static unsigned calc_name_len(const char *name)
547 540
548 541
549/* Return the number of used columns. 542/* Return the number of used columns.
550 * Note that only STYLE_COLUMNS uses return value. 543 * Note that only STYLE_COLUMNAR uses return value.
551 * STYLE_SINGLE and STYLE_LONG don't care. 544 * STYLE_SINGLE and STYLE_LONG don't care.
552 * coreutils 7.2 also supports: 545 * coreutils 7.2 also supports:
553 * ls -b (--escape) = octal escapes (although it doesn't look like working) 546 * ls -b (--escape) = octal escapes (although it doesn't look like working)
@@ -581,7 +574,7 @@ static unsigned print_name(const char *name)
581} 574}
582 575
583/* Return the number of used columns. 576/* Return the number of used columns.
584 * Note that only STYLE_COLUMNS uses return value, 577 * Note that only STYLE_COLUMNAR uses return value,
585 * STYLE_SINGLE and STYLE_LONG don't care. 578 * STYLE_SINGLE and STYLE_LONG don't care.
586 */ 579 */
587static NOINLINE unsigned list_single(const struct dnode *dn) 580static NOINLINE unsigned list_single(const struct dnode *dn)
@@ -739,7 +732,7 @@ static void showfiles(struct dnode **dn, unsigned nfiles)
739 unsigned i, ncols, nrows, row, nc; 732 unsigned i, ncols, nrows, row, nc;
740 unsigned column = 0; 733 unsigned column = 0;
741 unsigned nexttab = 0; 734 unsigned nexttab = 0;
742 unsigned column_width = 0; /* used only by STYLE_COLUMNS */ 735 unsigned column_width = 0; /* used only by STYLE_COLUMNAR */
743 736
744 if (all_fmt & STYLE_LONG) { /* STYLE_LONG or STYLE_SINGLE */ 737 if (all_fmt & STYLE_LONG) { /* STYLE_LONG or STYLE_SINGLE */
745 ncols = 1; 738 ncols = 1;
@@ -1005,21 +998,15 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
1005 if (opt & (1 << i)) { 998 if (opt & (1 << i)) {
1006 unsigned flags = opt_flags[i]; 999 unsigned flags = opt_flags[i];
1007 1000
1008 if (flags & LIST_MASK_TRIGGER) 1001 if (flags & STYLE_MASK)
1009 all_fmt &= ~LIST_MASK;
1010 if (flags & STYLE_MASK_TRIGGER)
1011 all_fmt &= ~STYLE_MASK; 1002 all_fmt &= ~STYLE_MASK;
1012 if (flags & SORT_MASK_TRIGGER) 1003 if (flags & SORT_MASK)
1013 all_fmt &= ~SORT_MASK; 1004 all_fmt &= ~SORT_MASK;
1014 if (flags & DISP_MASK_TRIGGER)
1015 all_fmt &= ~DISP_MASK;
1016 if (flags & TIME_MASK) 1005 if (flags & TIME_MASK)
1017 all_fmt &= ~TIME_MASK; 1006 all_fmt &= ~TIME_MASK;
1007
1018 if (flags & LIST_CONTEXT) 1008 if (flags & LIST_CONTEXT)
1019 all_fmt |= STYLE_SINGLE; 1009 all_fmt |= STYLE_SINGLE;
1020 /* huh?? opt cannot be 'l' */
1021 //if (LS_DISP_HR && opt == 'l')
1022 // all_fmt &= ~LS_DISP_HR;
1023 all_fmt |= flags; 1010 all_fmt |= flags;
1024 } 1011 }
1025 } 1012 }
@@ -1066,7 +1053,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
1066 1053
1067 /* choose a display format if one was not already specified by an option */ 1054 /* choose a display format if one was not already specified by an option */
1068 if (!(all_fmt & STYLE_MASK)) 1055 if (!(all_fmt & STYLE_MASK))
1069 all_fmt |= (isatty(STDOUT_FILENO) ? STYLE_COLUMNS : STYLE_SINGLE); 1056 all_fmt |= (isatty(STDOUT_FILENO) ? STYLE_COLUMNAR : STYLE_SINGLE);
1070 1057
1071 argv += optind; 1058 argv += optind;
1072 if (!argv[0]) 1059 if (!argv[0])