[Toybox] [PATCH 1/2] ls: Add tests for `-C` and `-x` options

Andrew Ilijic ilijic.andrew at gmail.com
Mon Oct 28 18:51:06 PDT 2019


Hi Rob,

These two patches should work.
The code in "...Remove-trailing..." is different from what we discussed.
> -       if (curcol < 255) printf("%*c", curcol, ' ');
> +      // Use dtlen and ul to not print spaces when we are at the end
> +      if (curcol < 255 && ((dtlen - ul - 1) > 0)) printf("%*c", curcol, ' ');
Using `dtlen` and `ul` only deleted the last trailing space. If `-C` or `-x`
generates multiline output, every line except the last one would have
two trailing spaces. GNU `ls` does not have any trailing spaces. I tried
for a while to find a way to detect when we are on the last filename of
the line, and could not find one. I ended up putting the padding code
with the newline code. I had to add the two other variables to hold on
to the values of the previous iteration.

~Andrew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ls-Remove-trailing-whitespace-so-that-tests-pass.patch
Type: text/x-patch
Size: 2144 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20191028/24d6f50e/attachment-0006.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ls-Add-tests-for-C-and-x-options.patch
Type: text/x-patch
Size: 1109 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20191028/24d6f50e/attachment-0007.bin>


More information about the Toybox mailing list