From 7c8103e5d2e472a2f11f6d6c6660c2903167fb7b Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 6 Sep 2012 03:10:18 -0500 Subject: Posix compliance: wc shouldn't have trailing spaces (breaks aboriginal's mkinitr amfs script), when to print filenames was wrong, and it should have a "total" line when counting multiple arguments. --- toys/posix/wc.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'toys/posix/wc.c') diff --git a/toys/posix/wc.c b/toys/posix/wc.c index 17801188..9d11577c 100644 --- a/toys/posix/wc.c +++ b/toys/posix/wc.c @@ -26,6 +26,26 @@ config WC #include "toys.h" +DEFINE_GLOBALS( + unsigned long totals[3]; +) + +#define TT this.wc + +static void show_lengths(unsigned long *lengths, char *name) +{ + int i, nospace = 1; + for (i=0; i<3; i++) { + if (!toys.optflags || (toys.optflags&(1<1) show_lengths(TT.totals, "total"); } -- cgit v1.2.3