From 9947a244d44edd3862694cce7a91e706b0cbd529 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 15 Jun 2006 22:11:10 +0000 Subject: [PATCH] =?utf8?q?Patch=20from=20Rich=20Felker:=20-=20duplicated?= =?utf8?q?=20format=20bit=2014=20forced=20LIST=5FEXEC=20always-on=20-=20-p?= =?utf8?q?=20option=20was=20behaving=20just=20like=20-F=20(SUSv3=20says=20?= =?utf8?q?-p=20only=20shows=20/=20for=20=C2=A0=20dirs,=20not=20other=20spe?= =?utf8?q?cial=20symbols)=20-=20tests=20for=20LIST=5FEXEC=20in=20color=20f?= =?utf8?q?unctions=20were=20nonsense=20(constant=20=C2=A0=20tests).=20i=20?= =?utf8?q?assume=20they=20were=20supposed=20to=20be=20(all=5Ffmt=20&=20LIS?= =?utf8?q?T=5FEXEC)=20=C2=A0=20however=20having=20coloring=20of=20executab?= =?utf8?q?le=20files=20depend=20on=20-F=20seems=20=C2=A0=20undesirable.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- coreutils/ls.c | 19 +++++++++---------- 1 file 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 { #define LIST_MASK ((LIST_EXEC << 1) - 1) /* what files will be displayed */ -/* TODO -- We may be able to make DISP_NORMAL 0 to save a bit slot. */ -#define DISP_NORMAL (1U<<14) /* show normal filenames */ #define DISP_DIRNAME (1U<<15) /* 2 or more items? label directories */ #define DISP_HIDDEN (1U<<16) /* show filenames starting with . */ #define DISP_DOT (1U<<17) /* show . and .. */ @@ -99,7 +97,7 @@ enum { #define DISP_RECURSIVE (1U<<19) /* show directory and everything below it */ #define DISP_ROWS (1U<<20) /* print across rows */ -#define DISP_MASK (((DISP_ROWS << 1) - 1) & ~(DISP_NORMAL - 1)) +#define DISP_MASK (((DISP_ROWS << 1) - 1) & ~(DISP_DIRNAME - 1)) #ifdef CONFIG_FEATURE_LS_SORTFILES /* how will the files be sorted */ @@ -254,8 +252,7 @@ static char fgcolor(mode_t mode) if (errno == ENOENT) { return '\037'; } - if (LIST_EXEC && S_ISREG(mode) - && (mode & (S_IXUSR | S_IXGRP | S_IXOTH))) + if (S_ISREG(mode) && (mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return COLOR(0xF000); /* File is executable ... */ return COLOR(mode); } @@ -263,8 +260,7 @@ static char fgcolor(mode_t mode) /*----------------------------------------------------------------------*/ static char bgcolor(mode_t mode) { - if (LIST_EXEC && S_ISREG(mode) - && (mode & (S_IXUSR | S_IXGRP | S_IXOTH))) + if (S_ISREG(mode) && (mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return ATTR(0xF000); /* File is executable ... */ return ATTR(mode); } @@ -276,8 +272,11 @@ static char append_char(mode_t mode) { if (!(all_fmt & LIST_FILETYPE)) return '\0'; - if ((all_fmt & LIST_EXEC) && S_ISREG(mode) - && (mode & (S_IXUSR | S_IXGRP | S_IXOTH))) + if (S_ISDIR(mode)) + return '/'; + if (!(all_fmt & LIST_EXEC)) + return '\0'; + if (S_ISREG(mode) && (mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return '*'; return APPCHAR(mode); } @@ -944,7 +943,7 @@ int ls_main(int argc, char **argv) char *color_opt; #endif - all_fmt = LIST_SHORT | DISP_NORMAL | STYLE_AUTO + all_fmt = LIST_SHORT | STYLE_AUTO #ifdef CONFIG_FEATURE_LS_TIMESTAMPS | TIME_MOD #endif -- 2.25.1