Page 1 of 1

Small problem in ZMatchPattern.pas with * matchs

Posted: 10.05.2007, 02:42
by radiotbo
I think there is a bug in ZMatchPattern.pas that makes a false negative match.

For example you have the text: "Hello baby"
and a Pattern like "*y*"

It only happen when the match char is at the last position of the text.

I send the fix version of ZMatchPattern.pas only one line needed in function MatchAfterStar(Pattern, Text: string): Integer;

At the end of the function

Inc(T);
if (T-1 > TLen) or (P > PLen) then
// if (T > TLen) or (P > PLen) then
begin
Result := MATCH_ABORT;
Exit;
end;
until Result <> 0;