summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2010-12-19 07:06:44 +0100
committerDenys Vlasenko2010-12-19 07:06:44 +0100
commit2f7d9e8903029b1b5e51a15f9cb0dcb6ca17c3ac (patch)
tree91a8a24915d4c80e8f9e44c391b6fc70ce7d25a8
parent163d86435729cc53d6d4088129f2cde106dd1318 (diff)
downloadbusybox-2f7d9e8903029b1b5e51a15f9cb0dcb6ca17c3ac.zip
busybox-2f7d9e8903029b1b5e51a15f9cb0dcb6ca17c3ac.tar.gz
ls: print a space after each column. Closes bug 2941
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/ls.c83
-rw-r--r--include/usage.src.h61
2 files changed, 72 insertions, 72 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 02e26be..7bc7b28 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -29,6 +29,70 @@
* [2009-03]
* ls sorts listing now, and supports almost all options.
*/
+
+//usage:#define ls_trivial_usage
+//usage: "[-1AaCxd"
+//usage: IF_FEATURE_LS_FOLLOWLINKS("L")
+//usage: IF_FEATURE_LS_RECURSIVE("R")
+//usage: IF_FEATURE_LS_FILETYPES("Fp") "lins"
+//usage: IF_FEATURE_LS_TIMESTAMPS("e")
+//usage: IF_FEATURE_HUMAN_READABLE("h")
+//usage: IF_FEATURE_LS_SORTFILES("rSXv")
+//usage: IF_FEATURE_LS_TIMESTAMPS("ctu")
+//usage: IF_SELINUX("kKZ") "]"
+//usage: IF_FEATURE_AUTOWIDTH(" -w WIDTH") " [FILE]..."
+//usage:#define ls_full_usage "\n\n"
+//usage: "List directory contents\n"
+//usage: "\nOptions:"
+//usage: "\n -1 List in a single column"
+//usage: "\n -A Don't list . and .."
+//usage: "\n -a Don't hide entries starting with ."
+//usage: "\n -C List by columns"
+//usage: "\n -x List by lines"
+//usage: "\n -d List directory entries instead of contents"
+//usage: IF_FEATURE_LS_FOLLOWLINKS(
+//usage: "\n -L List entries pointed to by symlinks"
+//usage: )
+//usage: IF_FEATURE_LS_RECURSIVE(
+//usage: "\n -R Recurse"
+//usage: )
+//usage: IF_FEATURE_LS_FILETYPES(
+//usage: "\n -F Append indicator (one of */=@|) to entries"
+//usage: "\n -p Append indicator (one of /=@|) to entries"
+//usage: )
+//usage: "\n -l Long listing format"
+//usage: "\n -i List inode numbers"
+//usage: "\n -n List numeric UIDs and GIDs instead of names"
+//usage: "\n -s List the size of each file, in blocks"
+//usage: IF_FEATURE_LS_TIMESTAMPS(
+//usage: "\n -e List full date and time"
+//usage: )
+//usage: IF_FEATURE_HUMAN_READABLE(
+//usage: "\n -h List sizes in human readable format (1K 243M 2G)"
+//usage: )
+//usage: IF_FEATURE_LS_SORTFILES(
+//usage: "\n -r Sort in reverse order"
+//usage: "\n -S Sort by file size"
+//usage: "\n -X Sort by extension"
+//usage: "\n -v Sort by version"
+//usage: )
+//usage: IF_FEATURE_LS_TIMESTAMPS(
+//usage: "\n -c With -l: sort by ctime"
+//usage: "\n -t With -l: sort by modification time"
+//usage: "\n -u With -l: sort by access time"
+//usage: )
+//usage: IF_SELINUX(
+//usage: "\n -k List security context"
+//usage: "\n -K List security context in long format"
+//usage: "\n -Z List security context and permission"
+//usage: )
+//usage: IF_FEATURE_AUTOWIDTH(
+//usage: "\n -w N Assume the terminal is N columns wide"
+//usage: )
+//usage: IF_FEATURE_LS_COLOR(
+//usage: "\n --color[={always,never,auto}] Control coloring"
+//usage: )
+
#include "libbb.h"
#include "unicode.h"
@@ -53,7 +117,6 @@
enum {
TERMINAL_WIDTH = 80, /* use 79 if terminal has linefold bug */
-COLUMN_GAP = 2, /* includes the file type char */
/* what is the overall style of the listing */
STYLE_COLUMNAR = 1 << 21, /* many records per line */
@@ -241,7 +304,6 @@ struct globals {
smallint exit_code;
unsigned all_fmt;
#if ENABLE_FEATURE_AUTOWIDTH
- unsigned tabstops; // = COLUMN_GAP;
unsigned terminal_width; // = TERMINAL_WIDTH;
#endif
#if ENABLE_FEATURE_LS_TIMESTAMPS
@@ -258,11 +320,9 @@ enum { show_color = 0 };
#define exit_code (G.exit_code )
#define all_fmt (G.all_fmt )
#if ENABLE_FEATURE_AUTOWIDTH
-# define tabstops (G.tabstops )
# define terminal_width (G.terminal_width)
#else
enum {
- tabstops = COLUMN_GAP,
terminal_width = TERMINAL_WIDTH,
};
#endif
@@ -270,7 +330,6 @@ enum {
#define INIT_G() do { \
/* we have to zero it out because of NOEXEC */ \
memset(&G, 0, sizeof(G)); \
- IF_FEATURE_AUTOWIDTH(tabstops = COLUMN_GAP;) \
IF_FEATURE_AUTOWIDTH(terminal_width = TERMINAL_WIDTH;) \
IF_FEATURE_LS_TIMESTAMPS(time(&current_time_t);) \
} while (0)
@@ -732,8 +791,8 @@ static NOINLINE unsigned list_single(const struct dnode *dn)
static void showfiles(struct dnode **dn, unsigned nfiles)
{
unsigned i, ncols, nrows, row, nc;
- unsigned column = 0;
- unsigned nexttab = 0;
+ unsigned column;
+ unsigned nexttab;
unsigned column_width = 0; /* used only by STYLE_COLUMNAR */
if (all_fmt & STYLE_LONG) { /* STYLE_LONG or STYLE_SINGLE */
@@ -745,7 +804,7 @@ static void showfiles(struct dnode **dn, unsigned nfiles)
if (column_width < len)
column_width = len;
}
- column_width += tabstops +
+ column_width += 1 +
IF_SELINUX( ((all_fmt & LIST_CONTEXT) ? 33 : 0) + )
((all_fmt & LIST_INO) ? 8 : 0) +
((all_fmt & LIST_BLOCKS) ? 5 : 0);
@@ -761,6 +820,8 @@ static void showfiles(struct dnode **dn, unsigned nfiles)
ncols = 1;
}
+ column = 0;
+ nexttab = 0;
for (row = 0; row < nrows; row++) {
for (nc = 0; nc < ncols; nc++) {
/* reach into the array based on the column and row */
@@ -771,8 +832,8 @@ static void showfiles(struct dnode **dn, unsigned nfiles)
if (i < nfiles) {
if (column > 0) {
nexttab -= column;
- printf("%*s", nexttab, "");
- column += nexttab;
+ printf("%*s ", nexttab, "");
+ column += nexttab + 1;
}
nexttab = column + column_width;
column += list_single(dn[i]);
@@ -993,7 +1054,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
/* -T NUM, -w NUM: */
IF_FEATURE_AUTOWIDTH(":T+:w+");
opt = getopt32(argv, ls_options
- IF_FEATURE_AUTOWIDTH(, &tabstops, &terminal_width)
+ IF_FEATURE_AUTOWIDTH(, NULL, &terminal_width)
IF_FEATURE_LS_COLOR(, &color_opt)
);
for (i = 0; opt_flags[i] != (1U<<31); i++) {
diff --git a/include/usage.src.h b/include/usage.src.h
index 64f2c90..cd37a89 100644
--- a/include/usage.src.h
+++ b/include/usage.src.h
@@ -2173,67 +2173,6 @@ INSERT
"\n -h Print banner page too" \
"\n -V Verbose" \
-#define ls_trivial_usage \
- "[-1Aa" IF_FEATURE_LS_TIMESTAMPS("c") "Cd" \
- IF_FEATURE_LS_TIMESTAMPS("e") IF_FEATURE_LS_FILETYPES("F") "iln" \
- IF_FEATURE_LS_FILETYPES("p") IF_FEATURE_LS_FOLLOWLINKS("L") \
- IF_FEATURE_LS_RECURSIVE("R") IF_FEATURE_LS_SORTFILES("rS") "s" \
- IF_FEATURE_AUTOWIDTH("T") IF_FEATURE_LS_TIMESTAMPS("tu") \
- IF_FEATURE_LS_SORTFILES("v") IF_FEATURE_AUTOWIDTH("w") "x" \
- IF_FEATURE_LS_SORTFILES("X") IF_FEATURE_HUMAN_READABLE("h") "k" \
- IF_SELINUX("K") "] [FILE]..."
-#define ls_full_usage "\n\n" \
- "List directory contents\n" \
- "\nOptions:" \
- "\n -1 List in a single column" \
- "\n -A Don't list . and .." \
- "\n -a Don't hide entries starting with ." \
- "\n -C List by columns" \
- IF_FEATURE_LS_TIMESTAMPS( \
- "\n -c With -l: sort by ctime") \
- IF_FEATURE_LS_COLOR( \
- "\n --color[={always,never,auto}] Control coloring") \
- "\n -d List directory entries instead of contents" \
- IF_FEATURE_LS_TIMESTAMPS( \
- "\n -e List full date and time") \
- IF_FEATURE_LS_FILETYPES( \
- "\n -F Append indicator (one of */=@|) to entries") \
- "\n -i List inode numbers" \
- "\n -l Long listing format" \
- "\n -n List numeric UIDs and GIDs instead of names" \
- IF_FEATURE_LS_FILETYPES( \
- "\n -p Append indicator (one of /=@|) to entries") \
- IF_FEATURE_LS_FOLLOWLINKS( \
- "\n -L List entries pointed to by symlinks") \
- IF_FEATURE_LS_RECURSIVE( \
- "\n -R Recurse") \
- IF_FEATURE_LS_SORTFILES( \
- "\n -r Sort in reverse order") \
- IF_FEATURE_LS_SORTFILES( \
- "\n -S Sort by file size") \
- "\n -s List the size of each file, in blocks" \
- IF_FEATURE_AUTOWIDTH( \
- "\n -T N Assume tabstop every N columns") \
- IF_FEATURE_LS_TIMESTAMPS( \
- "\n -t With -l: sort by modification time") \
- IF_FEATURE_LS_TIMESTAMPS( \
- "\n -u With -l: sort by access time") \
- IF_FEATURE_LS_SORTFILES( \
- "\n -v Sort by version") \
- IF_FEATURE_AUTOWIDTH( \
- "\n -w N Assume the terminal is N columns wide") \
- "\n -x List by lines" \
- IF_FEATURE_LS_SORTFILES( \
- "\n -X Sort by extension") \
- IF_FEATURE_HUMAN_READABLE( \
- "\n -h List sizes in human readable format (1K 243M 2G)") \
- IF_SELINUX( \
- "\n -k List security context") \
- IF_SELINUX( \
- "\n -K List security context in long format") \
- IF_SELINUX( \
- "\n -Z List security context and permission") \
-
#define lsattr_trivial_usage \
"[-Radlv] [FILE]..."
#define lsattr_full_usage "\n\n" \