* Copyright (c) 1991 The Regents of the University of California.
* %sccs.include.proprietary.c%
"@(#) Copyright (c) 1991 The Regents of the University of California.\n\
static char sccsid
[] = "@(#)old.fgrep.c 4.5 (Berkeley) %G%";
* fgrep -- print all lines containing any of a set of keywords
* 0 - ok, and some matches
int bflag
, cflag
, fflag
, lflag
, nflag
, vflag
, xflag
, yflag
;
while (--argc
> 0 && (++argv
)[0][0]=='-')
fprintf(stderr
, "fgrep: unknown flag\n");
wordf
= fopen(*argv
, "r");
fprintf(stderr
, "fgrep: can't open %s\n", *argv
);
else while (--argc
>= 0) {
exit(retcode
!= 0 ? retcode
: nsucc
== 0);
# define ccomp(a,b) (yflag ? lca(a)==lca(b) : a==b)
# define lca(x) (isupper(x) ? tolower(x) : x)
register struct words
*c
;
if ((f
= open(file
, 0)) < 0) {
fprintf(stderr
, "fgrep: can't open %s\n", file
);
if (fstat(f
, &stb
) > 0 && stb
.st_blksize
> 0)
blksize
= stb
.st_blksize
;
buf
= (char *)malloc(2*blksize
);
fprintf(stderr
, "egrep: no memory for %s\n", file
);
if (p
== &buf
[2*blksize
]) p
= buf
;
if ((ccount
= read(f
, p
, &buf
[2*blksize
] - p
)) <= 0) break;
else if ((ccount
= read(f
, p
, blksize
)) <= 0) break;
if (ccomp(c
->inp
, *p
)) {
if (p
== &buf
[2*blksize
]) p
= buf
;
if ((ccount
= read(f
, p
, &buf
[2*blksize
] - p
)) <= 0) break;
else if ((ccount
= read(f
, p
, blksize
)) <= 0) break;
if ( (vflag
&& (failed
== 0 || xflag
== 0)) || (vflag
== 0 && xflag
&& failed
) )
if (nfile
> 1 && hflag
|| oflag
) printf("%s:", file
);
if (bflag
) printf("%ld:", (blkno
-ccount
-1)/DEV_BSIZE
);
if (nflag
) printf("%ld:", lnum
);
while (nlp
< &buf
[2*blksize
]) putchar(*nlp
++);
while (nlp
< p
) putchar(*nlp
++);
if ((c
= *argptr
++) == '\0')
register struct words
*s
;
if (s
->inp
== 0) goto nenter
;
if (smax
>= &w
[MAXSIZ
-1]) overflo();
if (s
->inp
== 0) goto enter
;
if (smax
>= &w
[MAXSIZ
- 1]) overflo();
if (smax
>= &w
[MAXSIZ
- 1]) overflo();
} while ((c
= getargc()) != '\n' && c
!=EOF
);
if (smax
>= &w
[MAXSIZ
-1]) overflo();
fprintf(stderr
, "wordlist too large\n");
struct words
*queue
[QSIZE
];
struct words
**front
, **rear
;
register struct words
*s
;
init
: if ((s
->inp
) != 0) {
if (rear
>= &queue
[QSIZE
- 1]) overflo();
if ((s
= s
->link
) != 0) {
if (front
== &queue
[QSIZE
-1])
cloop
: if ((c
= s
->inp
) != 0) {
if (rear
>= &queue
[QSIZE
-1])
if (front
== queue
) overflo();
if (++rear
== front
) overflo();
qloop
: q
->fail
= state
->nst
;
if ((state
->nst
)->out
== 1) q
->out
= 1;
if ((q
= q
->link
) != 0) goto qloop
;
else if ((state
= state
->link
) != 0)