char *search( pat, text )
char *pat, *text;
{ short st, **states;
automata a;
if( pat[0] == EOS ) return( text );
a = stringautom(pat);
states = a->nextst;
for( st=0; st < a->st; st++ ) states[st][EOS] = -1;
st = 0;
while( (st = states[st][*text++ & (MAXCHAR-1)]) >= 0 );
if( *(text-1) == EOS )
return( NULL );
else return( text - a->final[-st] );
}
|