[PATCH] ls: remove redundant constants LIST_FILENAME and LIST_SHORT.

James Youngman jay at gnu.org
Sun Dec 19 23:14:40 UTC 2010


LIST_FILENAME is always true and LIST_SHORT affects nothing.
---
 coreutils/ls.c |   41 ++++++++++++++++++++---------------------
 1 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/coreutils/ls.c b/coreutils/ls.c
index d27c36d..899ae3d 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -135,10 +135,10 @@ LIST_ID_NAME    = 1 << 4,
 LIST_ID_NUMERIC = 1 << 5,
 LIST_CONTEXT    = 1 << 6,
 LIST_SIZE       = 1 << 7,
-//LIST_DEV        = 1 << 8, - unused, synonym to LIST_SIZE
+// Bit 8 is currently unused.
 LIST_DATE_TIME  = 1 << 9,
 LIST_FULLTIME   = 1 << 10,
-LIST_FILENAME   = 1 << 11,
+// Bit 11 is currently unused.
 LIST_SYMLINK    = 1 << 12,
 LIST_FILETYPE   = 1 << 13,
 LIST_EXEC       = 1 << 14,
@@ -177,9 +177,8 @@ SORT_EXT        = 6 << 26,      /* sort by file name extension */
 SORT_DIR        = 7 << 26,      /* sort by file or directory */
 SORT_MASK       = (7 << 26) * ENABLE_FEATURE_LS_SORTFILES,
 
-LIST_SHORT      = LIST_FILENAME,
 LIST_LONG       = LIST_MODEBITS | LIST_NLINKS | LIST_ID_NAME | LIST_SIZE | \
-                  LIST_DATE_TIME | LIST_FILENAME | LIST_SYMLINK,
+                  LIST_DATE_TIME | LIST_SYMLINK,
 };
 
 /* -Cadil1  Std options, busybox always supports */
@@ -265,16 +264,16 @@ enum {
 
 /* TODO: simple toggles may be stored as OPT_xxx bits instead */
 static const uint32_t opt_flags[] = {
-	LIST_SHORT | STYLE_COLUMNAR, /* C */
+	STYLE_COLUMNAR,		     /* C */
 	DISP_HIDDEN | DISP_DOT,      /* a */
 	DISP_NOLIST,                 /* d */
 	LIST_INO,                    /* i */
 	LIST_LONG | STYLE_LONG,      /* l */
-	LIST_SHORT | STYLE_SINGLE,   /* 1 */
+	STYLE_SINGLE,                /* 1 */
 	0,                           /* g (don't show owner) - handled via OPT_g */
 	LIST_ID_NUMERIC,             /* n */
 	LIST_BLOCKS,                 /* s */
-	LIST_SHORT | DISP_ROWS | STYLE_COLUMNAR, /* x */
+	DISP_ROWS | STYLE_COLUMNAR,  /* x */
 	0,                           /* Q (quote filename) - handled via OPT_Q */
 	DISP_HIDDEN,                 /* A */
 	ENABLE_SELINUX * LIST_CONTEXT, /* k (ignored if !SELINUX) */
@@ -711,7 +710,7 @@ static NOINLINE unsigned list_single(const struct dnode *dn)
 					(int) dn->dstat.st_uid,
 					(int) dn->dstat.st_gid);
 	}
-	if (all_fmt & (LIST_SIZE /*|LIST_DEV*/ )) {
+	if (all_fmt & LIST_SIZE) {
 		if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
 			column += printf("%4u, %3u ",
 					(int) major(dn->dstat.st_rdev),
@@ -759,20 +758,20 @@ static NOINLINE unsigned list_single(const struct dnode *dn)
 		freecon(dn->sid);
 	}
 #endif
-	if (all_fmt & LIST_FILENAME) {
+
 #if ENABLE_FEATURE_LS_COLOR
-		if (show_color) {
-			info.st_mode = 0; /* for fgcolor() */
-			lstat(dn->fullname, &info);
-			printf("\033[%u;%um", bold(info.st_mode),
-					fgcolor(info.st_mode));
-		}
+        if (show_color) {
+                info.st_mode = 0; /* for fgcolor() */
+                lstat(dn->fullname, &info);
+                printf("\033[%u;%um", bold(info.st_mode),
+                       fgcolor(info.st_mode));
+        }
 #endif
-		column += print_name(dn->name);
-		if (show_color) {
-			printf("\033[0m");
-		}
-	}
+        column += print_name(dn->name);
+        if (show_color) {
+                printf("\033[0m");
+        }
+
 	if (all_fmt & LIST_SYMLINK) {
 		if (S_ISLNK(dn->dstat.st_mode) && lpath) {
 			printf(" -> ");
@@ -1043,7 +1042,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
 
 	init_unicode();
 
-	all_fmt = LIST_SHORT | (ENABLE_FEATURE_LS_SORTFILES * SORT_NAME);
+	all_fmt = ENABLE_FEATURE_LS_SORTFILES * SORT_NAME;
 
 #if ENABLE_FEATURE_AUTOWIDTH
 	/* obtain the terminal width */
-- 
1.7.2.3



More information about the busybox mailing list