j=creLength-1;
i=endMatch?textLen-1:creLength-1;
for(;;)
{
for (;j>=0; i--,j--)
{
while (!MatchChar(text[i],j))
{
// It did not match so let's
// increment our text index
// by the skip distance
i+=(creLength-j > skip[text[i]]) ?
creLength-j:skip[text[i]] ;
// Set j to last char in pattern
j = creLength-1;
// If we index past the end of the
// text then no match
// If the match must be at the
// beginning of the buffer and i
// is greater than the start of
// text plus the pattern length,
// then there is no match
if (i >= textLen ||
(beginMatch==true && i-j>lead))
return NULL;
}
}
// point i to the first char in the
// matching text
i++;
if (beginMatch==true && i>lead)
return NULL;
// Do we have any more partial patterns
// to look for
if (nextRegEx != NULL)
{
if(nextRegEx->Match(text+i+creLength,
textLen-i-creLength, nextMatchLen)
== NULL)
{
i+=creLength;
j = creLength-1;
if (i >= textLen ||
(beginMatch==true && i-j>lead))
return NULL;
}
else
{
matchLen+=nextMatchLen;
break;
}
}
else
break;
}