]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
* src/ls.c (print_color_indicator): Test for S_IFREG first, rather
authorJim Meyering <jim@meyering.net>
Wed, 26 Jul 2006 14:06:57 +0000 (14:06 +0000)
committerJim Meyering <jim@meyering.net>
Wed, 26 Jul 2006 14:06:57 +0000 (14:06 +0000)
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.

ChangeLog
doc/ChangeLog
doc/coreutils.texi
src/ls.c

index 26f21e0f7030dad0939934327d10cf36289eeb4c..5346af715460b6ea3c241cd276075d51d33d7dc3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-07-26  Jim Meyering  <jim@meyering.net>
+
+       * 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.
+
 2006-07-26  Jim Meyering  <jim@meyering.net>
 
        Checking in a change from Paul.
index 22490068d210697d021a30e5e1a0f5a101721206..97d4ca1cc670dcd59ad150df411e8ec0757c8180 100644 (file)
@@ -1,3 +1,8 @@
+2006-07-26  Jim Meyering  <jim@meyering.net>
+
+       * coreutils.texi (What information is listed): Mention that missing
+       pieces of information are marked with "?".  From Paul Eggert.
+
 2006-07-25  Paul Eggert  <eggert@cs.ucla.edu>
 
        * perm.texi (Directory Setuid and Setgid): Explain that this is a
index dacac7df9ed5230746e2e510a007a285b2ba390e..64accb03cb4ed2d3b45244b8719bdada2c712905 100644 (file)
@@ -5795,7 +5795,8 @@ uniquely identifies each file within a particular file system.)
 In addition to the name of each file, print the file type, file mode bits,
 number of hard links, owner name, group name, size, and
 timestamp (@pxref{Formatting file timestamps}), normally
-the modification time.
+the modification time.  Print question marks for information that
+cannot be determined.
 
 Normally the size is printed as a byte count without punctuation, but
 this can be overridden (@pxref{Block size}).  For example, @option{-h}
index 5ad5bfe2cf2822294ddc2f4b1f15f92910b01044..85a4bc7e7145516e15d8a4ac98bc39a6f95b2b09 100644 (file)
--- 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;
        }
     }