[hackers] [sbase] wc: Make output POSIX compliant || sin

From: <git_AT_suckless.org>
Date: Fri, 6 Feb 2015 20:47:12 +0100 (CET)

commit f398e89a7cca91b576a3aaa938b4f6305cd56246
Author: sin <sin_AT_2f30.org>
Date: Fri Feb 6 19:46:37 2015 +0000

    wc: Make output POSIX compliant

diff --git a/wc.c b/wc.c
index f0bddcb..6316aea 100644
--- a/wc.c
+++ b/wc.c
_AT_@ -17,13 +17,14 @@ void
 output(const char *str, size_t nc, size_t nl, size_t nw)
 {
         int noflags = !cmode && !lflag && !wflag;
+ int first = 1;
 
         if (lflag || noflags)
- printf(" %5zu", nl);
+ printf("%*.zu", first ? (first = 0) : 7, nl);
         if (wflag || noflags)
- printf(" %5zu", nw);
+ printf("%*.zu", first ? (first = 0) : 7, nw);
         if (cmode || noflags)
- printf(" %5zu", nc);
+ printf("%*.zu", first ? (first = 0) : 7, nc);
         if (str)
                 printf(" %s", str);
         putchar('\n');
Received on Fri Feb 06 2015 - 20:47:12 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 06 2015 - 20:48:08 CET