# HG changeset patch # User Rob Landley # Date 1346919018 18000 # Node ID 5cb41d56f9d3e227b1a3ac83ad10a33d65002b63 # Parent 12cf7e635f82d3f9951983ab899dbf8a36e62cb1 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. diff -r 12cf7e635f82 -r 5cb41d56f9d3 toys/posix/wc.c --- a/toys/posix/wc.c Mon Sep 03 21:25:46 2012 -0500 +++ b/toys/posix/wc.c Thu Sep 06 03:10:18 2012 -0500 @@ -26,6 +26,26 @@ #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"); }