summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2006-07-26 14:06:57 +0000
committerJim Meyering <jim@meyering.net>2006-07-26 14:06:57 +0000
commitd2c6ae7fbc6c26e45fe33882c673897602afc0d2 (patch)
tree230eb291643bcf85a84df446d54d8d48ce15b9b9 /src
parent2465b478fd0952f68aaede95f6b2a0e1d0149f74 (diff)
downloadcoreutils-d2c6ae7fbc6c26e45fe33882c673897602afc0d2.tar.xz
* src/ls.c (print_color_indicator): Test for S_IFREG first, rather
than having the code test for all of the other types first. Hoist the set-uid/gid-testing code "up" into this new block. Classify any other type of file (e.g., S_TYPEISSHM, etc.) as C_ORPHAN, not as C_FILE. * doc/coreutils.texi (What information is listed): Mention that missing pieces of information are marked with "?". From Paul Eggert.
Diffstat (limited to 'src')
-rw-r--r--src/ls.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/ls.c b/src/ls.c
index 5ad5bfe2c..85a4bc7e7 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -3832,7 +3832,7 @@ static void
print_color_indicator (const char *name, mode_t mode, int linkok,
bool stat_ok, enum filetype filetype)
{
- int type = C_FILE;
+ int type;
struct color_ext_type *ext; /* Color extension */
size_t len; /* Length of name */
@@ -3847,7 +3847,17 @@ print_color_indicator (const char *name, mode_t mode, int linkok,
}
else
{
- if (S_ISDIR (mode))
+ if (S_ISREG (mode))
+ {
+ type = C_FILE;
+ if ((mode & S_ISUID) != 0)
+ type = C_SETUID;
+ else if ((mode & S_ISGID) != 0)
+ type = C_SETGID;
+ else if ((mode & S_IXUGO) != 0)
+ type = C_EXEC;
+ }
+ else if (S_ISDIR (mode))
{
if ((mode & S_ISVTX) && (mode & S_IWOTH))
type = C_STICKY_OTHER_WRITABLE;
@@ -3872,16 +3882,9 @@ print_color_indicator (const char *name, mode_t mode, int linkok,
else if (S_ISDOOR (mode))
type = C_DOOR;
else
- type = C_ORPHAN;
-
- if (type == C_FILE)
{
- if ((mode & S_ISUID) != 0)
- type = C_SETUID;
- else if ((mode & S_ISGID) != 0)
- type = C_SETGID;
- else if ((mode & S_IXUGO) != 0)
- type = C_EXEC;
+ /* Classify a file of some other type as C_ORPHAN. */
+ type = C_ORPHAN;
}
}