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.and...@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
From b9f428d772c168df601271375ca137bd2ee4ebda Mon Sep 17 00:00:00 2001
From: Andrew Ilijic <ilijic.and...@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
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to