/* wc.c - Word count * * Copyright 2011 Rob Landley * * See http://opengroup.org/onlinepubs/9699919799/utilities/wc.html USE_WC(NEWTOY(wc, USE_TOYBOX_I18N("m")"cwl", TOYFLAG_USR|TOYFLAG_BIN)) config WC bool "wc" default y help usage: wc -lwcm [FILE...] Count lines, words, and characters in input. -l show lines -w show words -c show bytes -m show characters By default outputs lines, words, bytes, and filename for each argument (or from stdin if none). Displays only either bytes or characters. */ #define FOR_wc #include "toys.h" GLOBALS( unsigned long totals[3]; ) 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; loopfiles(toys.optargs, do_wc); if (toys.optc>1) show_lengths(TT.totals, "total"); }