/*
* wc.lex : A simple example of using FLEX
* to create a wc-like utility.
*
* See MISC/fastwc/ in the flex distribution for examples
* of how to write this scanner for maximum performance.
*/
int numchars = 0;
int numwords = 0;
int numlines = 0;
int totchars = 0;
int totwords = 0;
int totlines = 0;
/*
* additional C code start from here. This supplies
* all the argument processing etc.
*/
int main(int argc, char *argv[])
{
int loop,first=1;
int lflag = 0; /* 1 if we count # of lines */
int wflag = 0; /* 1 if we count # of words */
int cflag = 0; /* 1 if we count # of characters */
int fflag = 0; /* 1 if we have a file name */
for(loop=1; loop<argc; loop++){
if(argv[loop][0] == '-'){
switch(argv[loop][1]){
case 'l':
lflag = 1;
break;
case 'w':
wflag = 1;
break;
case 'c':
cflag = 1;
break;
default:
fprintf(stderr,"unknown option -%c\n",
argv[loop][1]);
}
}
}
if(lflag == 0 && wflag == 0 && cflag == 0){
lflag = wflag = cflag = 1; /* default to all on */
}