aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-06-15 22:11:10 +0000
committerRob Landley <rob@landley.net>2006-06-15 22:11:10 +0000
commit9947a244d44edd3862694cce7a91e706b0cbd529 (patch)
tree95f86862ac564a70e11638464763dbd1655ded7b
parent1761b9dabe9b1bd5ca5233e181fd8926ade5a390 (diff)
downloadbusybox-w32-9947a244d44edd3862694cce7a91e706b0cbd529.tar.gz
busybox-w32-9947a244d44edd3862694cce7a91e706b0cbd529.tar.bz2
busybox-w32-9947a244d44edd3862694cce7a91e706b0cbd529.zip
Patch from Rich Felker:
- duplicated format bit 14 forced LIST_EXEC always-on - -p option was behaving just like -F (SUSv3 says -p only shows / for   dirs, not other special symbols) - tests for LIST_EXEC in color functions were nonsense (constant   tests). i assume they were supposed to be (all_fmt & LIST_EXEC)   however having coloring of executable files depend on -F seems   undesirable.
-rw-r--r--coreutils/ls.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 9c0e8f17d..47acec603 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -90,8 +90,6 @@ enum {
90#define LIST_MASK ((LIST_EXEC << 1) - 1) 90#define LIST_MASK ((LIST_EXEC << 1) - 1)
91 91
92/* what files will be displayed */ 92/* what files will be displayed */
93/* TODO -- We may be able to make DISP_NORMAL 0 to save a bit slot. */
94#define DISP_NORMAL (1U<<14) /* show normal filenames */
95#define DISP_DIRNAME (1U<<15) /* 2 or more items? label directories */ 93#define DISP_DIRNAME (1U<<15) /* 2 or more items? label directories */
96#define DISP_HIDDEN (1U<<16) /* show filenames starting with . */ 94#define DISP_HIDDEN (1U<<16) /* show filenames starting with . */
97#define DISP_DOT (1U<<17) /* show . and .. */ 95#define DISP_DOT (1U<<17) /* show . and .. */
@@ -99,7 +97,7 @@ enum {
99#define DISP_RECURSIVE (1U<<19) /* show directory and everything below it */ 97#define DISP_RECURSIVE (1U<<19) /* show directory and everything below it */
100#define DISP_ROWS (1U<<20) /* print across rows */ 98#define DISP_ROWS (1U<<20) /* print across rows */
101 99
102#define DISP_MASK (((DISP_ROWS << 1) - 1) & ~(DISP_NORMAL - 1)) 100#define DISP_MASK (((DISP_ROWS << 1) - 1) & ~(DISP_DIRNAME - 1))
103 101
104#ifdef CONFIG_FEATURE_LS_SORTFILES 102#ifdef CONFIG_FEATURE_LS_SORTFILES
105/* how will the files be sorted */ 103/* how will the files be sorted */
@@ -254,8 +252,7 @@ static char fgcolor(mode_t mode)
254 if (errno == ENOENT) { 252 if (errno == ENOENT) {
255 return '\037'; 253 return '\037';
256 } 254 }
257 if (LIST_EXEC && S_ISREG(mode) 255 if (S_ISREG(mode) && (mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
258 && (mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
259 return COLOR(0xF000); /* File is executable ... */ 256 return COLOR(0xF000); /* File is executable ... */
260 return COLOR(mode); 257 return COLOR(mode);
261} 258}
@@ -263,8 +260,7 @@ static char fgcolor(mode_t mode)
263/*----------------------------------------------------------------------*/ 260/*----------------------------------------------------------------------*/
264static char bgcolor(mode_t mode) 261static char bgcolor(mode_t mode)
265{ 262{
266 if (LIST_EXEC && S_ISREG(mode) 263 if (S_ISREG(mode) && (mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
267 && (mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
268 return ATTR(0xF000); /* File is executable ... */ 264 return ATTR(0xF000); /* File is executable ... */
269 return ATTR(mode); 265 return ATTR(mode);
270} 266}
@@ -276,8 +272,11 @@ static char append_char(mode_t mode)
276{ 272{
277 if (!(all_fmt & LIST_FILETYPE)) 273 if (!(all_fmt & LIST_FILETYPE))
278 return '\0'; 274 return '\0';
279 if ((all_fmt & LIST_EXEC) && S_ISREG(mode) 275 if (S_ISDIR(mode))
280 && (mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 276 return '/';
277 if (!(all_fmt & LIST_EXEC))
278 return '\0';
279 if (S_ISREG(mode) && (mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
281 return '*'; 280 return '*';
282 return APPCHAR(mode); 281 return APPCHAR(mode);
283} 282}
@@ -944,7 +943,7 @@ int ls_main(int argc, char **argv)
944 char *color_opt; 943 char *color_opt;
945#endif 944#endif
946 945
947 all_fmt = LIST_SHORT | DISP_NORMAL | STYLE_AUTO 946 all_fmt = LIST_SHORT | STYLE_AUTO
948#ifdef CONFIG_FEATURE_LS_TIMESTAMPS 947#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
949 | TIME_MOD 948 | TIME_MOD
950#endif 949#endif