From d2937162b04be57962fff60b5e1e8c52e9c3ffe3 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 27 Aug 2016 23:27:45 -0500 Subject: Make "LC_ALL=C ls -Cs --color" produce the same output on toybox and ubuntu. (Two spaces padding between columns, and -k is hardwired on.) --- toys/posix/ls.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/toys/posix/ls.c b/toys/posix/ls.c index 73c4b7b3..a336ba1a 100644 --- a/toys/posix/ls.c +++ b/toys/posix/ls.c @@ -18,12 +18,12 @@ config LS what to show: -a all files including .hidden -b escape nongraphic chars -c use ctime for timestamps -d directory, not contents - -i inode number -k block sizes in kilobytes - -p put a '/' after dir names -q unprintable chars as '?' - -s storage used (512 byte units) -u use access time for timestamps - -A list all files but . and .. -H follow command line symlinks - -L follow symlinks -R recursively list files in subdirs - -F append /dir *exe @sym |FIFO -Z security context + -i inode number -p put a '/' after dir names + -q unprintable chars as '?' -s storage used (1024 byte units) + -u use access time for timestamps -A list all files but . and .. + -H follow command line symlinks -L follow symlinks + -R recursively list in subdirs -F append /dir *exe @sym |FIFO + -Z security context output formats: -1 list one file per line -C columns (sorted vertically) @@ -222,7 +222,7 @@ static int filter(struct dirtree *new) if (flags & FLAG_u) new->st.st_mtime = new->st.st_atime; if (flags & FLAG_c) new->st.st_mtime = new->st.st_ctime; - if (flags & FLAG_k) new->st.st_blocks = (new->st.st_blocks + 1) / 2; + new->st.st_blocks >>= 1; if (flags & (FLAG_a|FLAG_f)) return DIRTREE_SAVE; if (!(flags & FLAG_A) && new->name[0]=='.') return 0; @@ -378,7 +378,7 @@ static void listfiles(int dirfd, struct dirtree *indir) memset(colsizes, 0, columns*sizeof(unsigned)); for (ul=0; ul colsizes[c]) { @@ -413,12 +413,12 @@ static void listfiles(int dirfd, struct dirtree *indir) if (flags & FLAG_m) xputc(','); if (flags & (FLAG_C|FLAG_x)) { if (!curcol) xputc('\n'); - } else if ((flags & FLAG_1) || width+1+*len > TT.screen_width) { + } else if ((flags & FLAG_1) || width+2+*len > TT.screen_width) { xputc('\n'); width = 0; } else { - xputc(' '); - width++; + printf(" "); + width += 2; } } width += *len; -- cgit v1.2.3