* fgrep -- print all lines containing any of a set of keywords
* 0 - ok, and some matches
instr
= nsucc
= need
= inct
= rflag
= numwords
= nfound
= 0;
www
= zalloc(MAXSIZ
, sizeof (*www
));
err("Can't get space for machines", 0);
for (q
=www
; q
<www
+MAXSIZ
; q
++) {
q
->inp
=0; q
->out
=0; q
->nst
=0; q
->link
=0; q
->fail
=0;
while (xargc
>0 && xargv
[0][0]=='-')
case 'r': /* return value only */
case 'n': /* number of answers needed */
fprintf(stderr
,"inct %d xargv.2. %o %d\n",inct
, xargv
[2],xargv
[2]);
write (2, "bad fgrep call\n", 15);
fprintf(stderr
, "before cgoto\n");
fprintf(stderr
, "before cfail\n");
fprintf(stderr
, "before execute instr %.20s\n", instr
? instr
: "");
fprintf(stderr
, "end of string %d %c %c %c\n", inct
, instr
[inct
-3],
instr
[inct
-2], instr
[inct
-1]);
fprintf(stderr
, "returning nsucc %d\n", nsucc
);
fprintf(stderr
, "fgrep done www %o\n",www
);
register struct words
*c
;
ccount
= instr
? inct
: 0;
if (need
== 0) need
= numwords
;
fprintf(stderr
, "in execute ccount %d inct %d\n",ccount
, inct
);
fprintf(stderr
, "down ccount\n");
fprintf(stderr
, "ex loop ccount %d instr %o\n",ccount
, instr
);
if (p
== &buf
[1024]) p
= buf
;
if ((ccount
= read(f
, p
, &buf
[1024] - p
)) <= 0) break;
else if ((ccount
= read(f
, p
, 512)) <= 0) break;
fprintf(stderr
, " normal read %d bytres\n", ccount
);
{char xx
[20]; sprintf(xx
, "they are %%.%ds\n", ccount
);
fprintf(stderr
, "roaming along in ex ch %c c %o\n",ch
,c
);
if (isupper(ch
)) ch
|= 040;
fprintf(stderr
, " found: nfound %d need %d\n",nfound
,need
);
fprintf(stderr
, "found, p %o nlp %o ccount %d buf %o buf[1024] %o\n",p
,nlp
,ccount
,buf
,buf
+1024);
fprintf(stderr
, "down ccount2\n");
if (p
== &buf
[1024]) p
= buf
;
if ((ccount
= read(f
, p
, &buf
[1024] - p
)) <= 0) break;
else if ((ccount
= read(f
, p
, 512)) <= 0) break;
fprintf(stderr
, " read %d bytes\n",ccount
);
{ char xx
[20]; sprintf(xx
, "they are %%.%ds\n", ccount
);
fprintf(stderr
, "p %o nlp %o buf %o\n",p
,nlp
,buf
);
{write (2, "XX\n", 3); write (2, nlp
, p
-nlp
); write (2, "XX\n", 3);}
if (p
> nlp
) write(1, nlp
, p
-nlp
);
write(1, nlp
, &buf
[1024] - nlp
);
write(1, buf
, p
-&buf
[0]);
if (p
[-1]!= '\n') write (1, "\n", 1);
fprintf(stderr
, "nr end loop p %o\n",p
);
register struct words
*s
;
fprintf(stderr
, " in for loop c now %o %c\n",c
, c
>' ' ? c
: ' ');
if ((c
= gch())==0) return;
if (s
->inp
== 0) goto enter
;
if (smax
>= &www
[MAXSIZ
- 1]) overflo();
if (smax
>= &www
[MAXSIZ
- 1]) overflo();
while ((c
= gch()) != '\n');
fprintf(stderr
, "next arg is %s xargc %d\n",s
,xargc
);
if (xargc
-- <=0) return(0);
for(flag
=0; flag
<1024; flag
++)
write(2,"wordlist too large\n", 19);
struct words
*queue
[QSIZE
];
struct words
**front
, **rear
;
register struct words
*s
;
if (rear
>= &queue
[QSIZE
- 1]) overflo();
if ((s
= s
->link
) != 0) {
if (front
== &queue
[QSIZE
-1])
if (rear
>= &queue
[QSIZE
-1])
if (front
== queue
) overflo();
if (++rear
== front
) overflo();
if (state
== 0) state
= www
;
if ((state
->nst
)->out
== 1) q
->out
= 1;
else if ((state
= state
->link
) != 0)