aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2018-07-06 13:02:09 -0700
committerRob Landley <rob@landley.net>2018-07-09 15:39:44 -0500
commit0bce1bdafb1b5ad35c459fa3cf2ba0cdf74c7c16 (patch)
tree82bbc450da96b8e39128cf2d829735de00e18528 /toys
parent489a74ee60d8e1b696345e36fcc5ee58e5f0cdab (diff)
downloadtoybox-0bce1bdafb1b5ad35c459fa3cf2ba0cdf74c7c16.tar.gz
Fix wc column widths.
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/wc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/toys/posix/wc.c b/toys/posix/wc.c
index 69c5f382..acd0b3a0 100644
--- a/toys/posix/wc.c
+++ b/toys/posix/wc.c
@@ -33,9 +33,13 @@ GLOBALS(
static void show_lengths(unsigned long *lengths, char *name)
{
- int i, space = 7, first = 1;
+ int i, space, first = 1;
+
+ // POSIX says there should never be leading spaces, but accepts that
+ // traditional implementations use 7 spaces, unless only one file
+ // is being counted, when there should be no leading spaces.
+ space = (toys.optc != 1) ? 7 : 0;
- for (i = 0; i<4; i++) if (toys.optflags == (1<<i)) space = 0;
for (i = 0; i<4; i++) {
if (toys.optflags&(1<<i)) {
printf(" %*ld"+first, space, lengths[i]);