ls: fix -p help text, improve comments and define names

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2011-05-12 18:40:59 +02:00
parent 75e77deab1
commit 4ad95e6b0e

View File

@ -51,14 +51,14 @@
//usage: "\n -d List directory entries instead of contents" //usage: "\n -d List directory entries instead of contents"
//usage: IF_FEATURE_LS_FOLLOWLINKS( //usage: IF_FEATURE_LS_FOLLOWLINKS(
//usage: "\n -L Follow symlinks" //usage: "\n -L Follow symlinks"
//usage: "\n -H Follow symlinks on command line only" //usage: "\n -H Follow symlinks on command line"
//usage: ) //usage: )
//usage: IF_FEATURE_LS_RECURSIVE( //usage: IF_FEATURE_LS_RECURSIVE(
//usage: "\n -R Recurse" //usage: "\n -R Recurse"
//usage: ) //usage: )
//usage: IF_FEATURE_LS_FILETYPES( //usage: IF_FEATURE_LS_FILETYPES(
//usage: "\n -p Append / to dir entries"
//usage: "\n -F Append indicator (one of */=@|) to entries" //usage: "\n -F Append indicator (one of */=@|) to entries"
//usage: "\n -p Append indicator (one of /=@|) to entries"
//usage: ) //usage: )
//usage: "\n -l Long listing format" //usage: "\n -l Long listing format"
//usage: "\n -i List inode numbers" //usage: "\n -i List inode numbers"
@ -137,9 +137,9 @@ LIST_SIZE = 1 << 7,
LIST_DATE_TIME = 1 << 8, LIST_DATE_TIME = 1 << 8,
LIST_FULLTIME = 1 << 9, LIST_FULLTIME = 1 << 9,
LIST_SYMLINK = 1 << 10, LIST_SYMLINK = 1 << 10,
LIST_FILETYPE = 1 << 11, LIST_FILETYPE = 1 << 11, /* show / suffix for dirs */
LIST_EXEC = 1 << 12, LIST_CLASSIFY = 1 << 12, /* requires LIST_FILETYPE, also show *,|,@,= suffixes */
LIST_MASK = (LIST_EXEC << 1) - 1, LIST_MASK = (LIST_CLASSIFY << 1) - 1,
/* what files will be displayed */ /* what files will be displayed */
DISP_DIRNAME = 1 << 13, /* 2 or more items? label directories */ DISP_DIRNAME = 1 << 13, /* 2 or more items? label directories */
@ -288,7 +288,7 @@ static const uint32_t opt_flags[] = {
SORT_VERSION, /* v */ SORT_VERSION, /* v */
#endif #endif
#if ENABLE_FEATURE_LS_FILETYPES #if ENABLE_FEATURE_LS_FILETYPES
LIST_FILETYPE | LIST_EXEC, /* F */ LIST_FILETYPE | LIST_CLASSIFY, /* F */
LIST_FILETYPE, /* p */ LIST_FILETYPE, /* p */
#endif #endif
#if ENABLE_FEATURE_LS_RECURSIVE #if ENABLE_FEATURE_LS_RECURSIVE
@ -396,8 +396,8 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
* 3/7:multiplexed char/block device) * 3/7:multiplexed char/block device)
* and we use 0 for unknown and 15 for executables (see below) */ * and we use 0 for unknown and 15 for executables (see below) */
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f) #define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)]) /* un fi chr - dir - blk - file - link - sock - - exe */
#define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)]) #define APPCHAR(mode) ("\0""|""\0""\0""/""\0""\0""\0""\0""\0""@""\0""=""\0""\0""\0" [TYPEINDEX(mode)])
/* 036 black foreground 050 black background /* 036 black foreground 050 black background
037 red foreground 051 red background 037 red foreground 051 red background
040 green foreground 052 green background 040 green foreground 052 green background
@ -408,7 +408,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
045 gray foreground 057 white background 045 gray foreground 057 white background
*/ */
#define COLOR(mode) ( \ #define COLOR(mode) ( \
/*un fi chr dir blk file link sock exe */ \ /*un fi chr - dir - blk - file - link - sock - - exe */ \
"\037\043\043\045\042\045\043\043\000\045\044\045\043\045\045\040" \ "\037\043\043\045\042\045\043\043\000\045\044\045\043\045\045\040" \
[TYPEINDEX(mode)]) [TYPEINDEX(mode)])
/* Select normal (0) [actually "reset all"] or bold (1) /* Select normal (0) [actually "reset all"] or bold (1)
@ -417,7 +417,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
* Note: coreutils 6.9 uses inverted red for setuid binaries. * Note: coreutils 6.9 uses inverted red for setuid binaries.
*/ */
#define ATTR(mode) ( \ #define ATTR(mode) ( \
/*un fi chr dir blk file link sock exe */ \ /*un fi chr - dir - blk - file- link- sock- - exe */ \
"\01\00\01\07\01\07\01\07\00\07\01\07\01\07\07\01" \ "\01\00\01\07\01\07\01\07\00\07\01\07\01\07\07\01" \
[TYPEINDEX(mode)]) [TYPEINDEX(mode)])
@ -444,7 +444,7 @@ static char append_char(mode_t mode)
return '\0'; return '\0';
if (S_ISDIR(mode)) if (S_ISDIR(mode))
return '/'; return '/';
if (!(all_fmt & LIST_EXEC)) if (!(all_fmt & LIST_CLASSIFY))
return '\0'; return '\0';
if (S_ISREG(mode) && (mode & (S_IXUSR | S_IXGRP | S_IXOTH))) if (S_ISREG(mode) && (mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
return '*'; return '*';