/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1992-2011 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* David Korn
* AT&T Bell Laboratories
*
* count the number of bytes, words, and lines in a file
*/
static const char usage[] =
"[-?\n@(#)$Id: wc (AT&T Research) 2009-11-28 $\n]"
"[+NAME?wc - print the number of bytes, words, and lines in files]"
"[+DESCRIPTION?\bwc\b reads one or more input files and, by default, "
"for each file writes a line containing the number of newlines, "
"\aword\as, and bytes contained in each file followed by the "
"file name to standard output in that order. A \aword\a is "
"defined to be a non-zero length string delimited by \bisspace\b(3) "
"characters.]"
"[+?If more than one file is specified, \bwc\b writes a total count "
"for all of the named files with \btotal\b written instead "
"of the file name.]"
"[+?By default, \bwc\b writes all three counts. Options can specified "
"so that only certain counts are written. The options \b-c\b "
"and \b-m\b are mutually exclusive.]"
"[+?If no \afile\a is given, or if the \afile\a is \b-\b, \bwc\b "
"reads from standard input and no filename is written to standard "
"output. The start of the file is defined as the current offset.]"
"[l:lines?List the line counts.]"
"[w:words?List the word counts.]"
"[c:bytes|chars:chars?List the byte counts.]"
"[m|C:multibyte-chars?List the character counts.]"
"[q:quiet?Suppress invalid multibyte character warnings.]"
"[L:longest-line|max-line-length?List the longest line length; the newline,"
"if any, is not counted in the length.]"
"[N!:utf8?For \bUTF-8\b locales \b--noutf8\b disables \bUTF-8\b "
"optimzations and relies on the native \bmbtowc\b(3).]"
"\n"
"\n[file ...]\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?All files processed successfully.]"
"[+>0?One or more files failed to open or could not be read.]"
"}"
"[+SEE ALSO?\bcat\b(1), \bisspace\b(3)]"
;
#include <cmd.h>
#include <wc.h>
#include <ls.h>
{
if (mode&WC_LONGEST)
if (name)
}
int
{
register char *cp;
register int mode=0, n;
for (;;)
{
{
case 'c':
continue;
case 'l':
continue;
case 'L':
mode |= WC_LONGEST;
continue;
case 'N':
continue;
case 'm':
case 'C':
continue;
case 'q':
continue;
case 'w':
continue;
case ':':
break;
case '?':
break;
}
break;
}
if (error_info.errors)
{
if (!mbwide())
}
argv++;
n = 0;
do
{
{
continue;
}
if (cp)
n++;
{
}
else
if (n > 1)
{
}
}