version 1.39, 2007/09/02 15:19:32 |
version 1.40, 2010/04/05 03:03:55 |
|
|
int Eflag; /* -E: interpret pattern as extended regexp */ |
int Eflag; /* -E: interpret pattern as extended regexp */ |
int Fflag; /* -F: interpret pattern as list of fixed strings */ |
int Fflag; /* -F: interpret pattern as list of fixed strings */ |
int Gflag; /* -G: interpret pattern as basic regexp */ |
int Gflag; /* -G: interpret pattern as basic regexp */ |
int Hflag; /* -H: if -R, follow explicitly listed symlinks */ |
|
int Lflag; /* -L: only show names of files with no matches */ |
int Lflag; /* -L: only show names of files with no matches */ |
int Pflag; /* -P: if -R, no symlinks are followed */ |
|
int Rflag; /* -R: recursively search directory trees */ |
int Rflag; /* -R: recursively search directory trees */ |
int Sflag; /* -S: if -R, follow all symlinks */ |
|
#ifndef NOZ |
#ifndef NOZ |
int Zflag; /* -Z: decompress input before processing */ |
int Zflag; /* -Z: decompress input before processing */ |
#endif |
#endif |
|
|
int iflag; /* -i: ignore case */ |
int iflag; /* -i: ignore case */ |
int lflag; /* -l: only show names of files with matches */ |
int lflag; /* -l: only show names of files with matches */ |
int nflag; /* -n: show line numbers in front of matching lines */ |
int nflag; /* -n: show line numbers in front of matching lines */ |
int oflag; /* -o: always print file name */ |
|
int qflag; /* -q: quiet mode (don't output anything) */ |
int qflag; /* -q: quiet mode (don't output anything) */ |
int sflag; /* -s: silent mode (ignore errors) */ |
int sflag; /* -s: silent mode (ignore errors) */ |
int vflag; /* -v: only show non-matching lines */ |
int vflag; /* -v: only show non-matching lines */ |
|
|
{ |
{ |
fprintf(stderr, |
fprintf(stderr, |
#ifdef NOZ |
#ifdef NOZ |
"usage: %s [-abcEFGHhIiLlnoPqRSsUVvwx] [-A num] [-B num] [-C[num]]\n" |
"usage: %s [-abcEFGhIiLlnqRsUVvwx] [-A num] [-B num] [-C[num]]\n" |
#else |
#else |
"usage: %s [-abcEFGHhIiLlnoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]\n" |
"usage: %s [-abcEFGhIiLlnqRsUVvwxZ] [-A num] [-B num] [-C[num]]\n" |
#endif |
#endif |
"\t[-e pattern] [-f file] [--binary-files=value] [--context[=num]]\n" |
"\t[-e pattern] [-f file] [--binary-files=value] [--context[=num]]\n" |
"\t[--line-buffered] [pattern] [file ...]\n", __progname); |
"\t[--line-buffered] [pattern] [file ...]\n", __progname); |
|
|
} |
} |
|
|
#ifdef NOZ |
#ifdef NOZ |
static char *optstr = "0123456789A:B:CEFGHILPSRUVabce:f:hilnoqrsuvwxy"; |
static char *optstr = "0123456789A:B:CEFGILRUVabce:f:hilnqrsuvwxy"; |
#else |
#else |
static char *optstr = "0123456789A:B:CEFGHILPSRUVZabce:f:hilnoqrsuvwxy"; |
static char *optstr = "0123456789A:B:CEFGILRUVZabce:f:hilnqrsuvwxy"; |
#endif |
#endif |
|
|
struct option long_options[] = |
struct option long_options[] = |
|
|
Eflag = Fflag = 0; |
Eflag = Fflag = 0; |
Gflag++; |
Gflag++; |
break; |
break; |
case 'H': |
|
Hflag++; |
|
break; |
|
case 'I': |
case 'I': |
binbehave = BIN_FILE_SKIP; |
binbehave = BIN_FILE_SKIP; |
break; |
break; |
|
|
lflag = 0; |
lflag = 0; |
Lflag = qflag = 1; |
Lflag = qflag = 1; |
break; |
break; |
case 'P': |
|
Pflag++; |
|
break; |
|
case 'S': |
|
Sflag++; |
|
break; |
|
case 'R': |
case 'R': |
case 'r': |
case 'r': |
Rflag++; |
Rflag++; |
oflag++; |
|
break; |
break; |
case 'U': |
case 'U': |
binbehave = BIN_FILE_BIN; |
binbehave = BIN_FILE_BIN; |
|
|
needpattern = 0; |
needpattern = 0; |
break; |
break; |
case 'h': |
case 'h': |
oflag = 0; |
|
hflag = 1; |
hflag = 1; |
break; |
break; |
case 'i': |
case 'i': |
|
|
case 'n': |
case 'n': |
nflag = 1; |
nflag = 1; |
break; |
break; |
case 'o': |
|
hflag = 0; |
|
oflag = 1; |
|
break; |
|
case 'q': |
case 'q': |
qflag = 1; |
qflag = 1; |
break; |
break; |
|
|
if (lbflag) |
if (lbflag) |
setlinebuf(stdout); |
setlinebuf(stdout); |
|
|
if ((argc == 0 || argc == 1) && !oflag) |
if ((argc == 0 || argc == 1) && !Rflag) |
hflag = 1; |
hflag = 1; |
|
|
if (argc == 0) |
if (argc == 0) |