[Toybox] [PATCH 2/2] ls: Remove trailing whitespace so that tests pass

Andrew Ilijic ilijic.andrew at gmail.com
Thu Oct 24 06:47:55 PDT 2019


For context see the mailing list link below.
https://www.mail-archive.com/toybox@lists.landley.net/msg05991.html

>From b9f428d772c168df601271375ca137bd2ee4ebda Mon Sep 17 00:00:00 2001
From: Andrew Ilijic <ilijic.andrew at gmail.com>
Date: Thu, 24 Oct 2019 09:16:46 -0400
Subject: [PATCH 2/2] ls: Remove trailing whitespace so that tests pass

Tests for `-C` & `-x` fail because of trailing white space. Removing
the trailing whitespace will allow the tests to pass.
---
 toys/posix/ls.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index d4c0211a..c7ee7864 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -523,7 +523,8 @@ 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("%*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, ' ');
     }
   }

--
2.11.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-ls-Remove-trailing-whitespace-so-that-tests-pass.patch
Type: text/x-patch
Size: 982 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20191024/d8e3c916/attachment.bin>


More information about the Toybox mailing list