diff options
author | Rob Landley <rob@landley.net> | 2017-04-08 13:52:18 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2017-04-08 13:52:18 -0500 |
commit | fea6d56777a3063b5af8b262df2a4a2573142962 (patch) | |
tree | f4ee45653248d6dd2796eda2b300d53ddac43322 /toys | |
parent | a0d0af0f734aa1edd9336089c5da1b813e0ab125 (diff) | |
download | toybox-fea6d56777a3063b5af8b262df2a4a2573142962.tar.gz |
Fix the ls -m test (which is just a whitespace issue, but eh).
While we're at it, ls -m wordwrap was one column early.
Diffstat (limited to 'toys')
-rw-r--r-- | toys/posix/ls.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/toys/posix/ls.c b/toys/posix/ls.c index d2a2e466..da0a142d 100644 --- a/toys/posix/ls.c +++ b/toys/posix/ls.c @@ -388,7 +388,6 @@ static void listfiles(int dirfd, struct dirtree *indir) } // Loop through again to produce output. - memset(toybuf, ' ', 256); width = 0; for (ul = 0; ul<dtlen; ul++) { int ii; @@ -405,15 +404,17 @@ static void listfiles(int dirfd, struct dirtree *indir) // Handle padding and wrapping for display purposes entrylen(sort[next], len); if (ul) { - if (flags & FLAG_m) xputc(','); + int mm = !!(flags & FLAG_m); + + if (mm) xputc(','); if (flags & (FLAG_C|FLAG_x)) { if (!curcol) xputc('\n'); - } else if ((flags & FLAG_1) || width+2+*len > TT.screen_width) { + } else if ((flags & FLAG_1) || width+1+*len > TT.screen_width) { xputc('\n'); width = 0; } else { - printf(" "); - width += 2; + printf(" "+mm); + width += 2-mm; } } width += *len; @@ -498,7 +499,7 @@ static void listfiles(int dirfd, struct dirtree *indir) // Pad columns if (flags & (FLAG_C|FLAG_x)) { curcol = colsizes[curcol]-(*len)-totpad; - if (curcol < 255) printf("%s", toybuf+255-curcol); + if (curcol < 255) printf("%*c", curcol, ' '); } } |