Small problem in ZMatchPattern.pas with * matchs

Code patches written by our users to solve certain "problems" that were not solved, yet.

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
radiotbo
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 10.05.2007, 02:26

Small problem in ZMatchPattern.pas with * matchs

Post 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;
Post Reply