mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 20:29:14 +02:00
parent
6ab9435e44
commit
f1a7d07f8e
@ -2591,9 +2591,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function isMatch(inputstr,wilds : string; CWild, CinputWord: integer;MaxInputword,maxwilds : word) : Boolean;
|
Function isMatch(level : Integer; inputstr,wilds : string; CWild, CinputWord: integer;MaxInputword,maxwilds : word; Out EOS : Boolean) : Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
EOS:=False;
|
||||||
Result:=True;
|
Result:=True;
|
||||||
repeat
|
repeat
|
||||||
if Wilds[CWild] = '*' then { handling of '*' }
|
if Wilds[CWild] = '*' then { handling of '*' }
|
||||||
@ -2609,10 +2610,12 @@ begin
|
|||||||
Repeat
|
Repeat
|
||||||
while (inputStr[CinputWord]<>Wilds[CWild]) and (CinputWord <= MaxinputWord) do
|
while (inputStr[CinputWord]<>Wilds[CWild]) and (CinputWord <= MaxinputWord) do
|
||||||
inc(CinputWord);
|
inc(CinputWord);
|
||||||
Result:=isMatch(inputstr,wilds,CWild, CinputWord,MaxInputword,maxwilds);
|
Result:=isMatch(Level+1,inputstr,wilds,CWild, CinputWord,MaxInputword,maxwilds,EOS);
|
||||||
if not Result then
|
if not Result then
|
||||||
Inc(cInputWord);
|
Inc(cInputWord);
|
||||||
Until Result or (CinputWord>=MaxinputWord);
|
Until Result or (CinputWord>=MaxinputWord);
|
||||||
|
if Result and EOS then
|
||||||
|
Exit;
|
||||||
Continue;
|
Continue;
|
||||||
end;
|
end;
|
||||||
if Wilds[CWild] = '?' then { equal to '?' }
|
if Wilds[CWild] = '?' then { equal to '?' }
|
||||||
@ -2632,9 +2635,17 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
Exit;
|
Exit;
|
||||||
until (CinputWord > MaxinputWord) or (CWild > MaxWilds);
|
until (CinputWord > MaxinputWord) or (CWild > MaxWilds);
|
||||||
{ no completed evaluation }
|
{ no completed evaluation, we need to check what happened }
|
||||||
if (CinputWord <= MaxinputWord) or (CWild <= MaxWilds) then
|
if (CinputWord < MaxinputWord) or (CWild < MaxWilds) then
|
||||||
Result:=false;
|
Result:=false
|
||||||
|
else if (CWild>Maxwilds) then
|
||||||
|
EOS:=False
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
EOS:=Wilds[CWild]='*';
|
||||||
|
if not EOS then
|
||||||
|
Result:=False;
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function isWild(inputStr, Wilds: string; ignoreCase: boolean): boolean;
|
function isWild(inputStr, Wilds: string; ignoreCase: boolean): boolean;
|
||||||
@ -2642,6 +2653,8 @@ function isWild(inputStr, Wilds: string; ignoreCase: boolean): boolean;
|
|||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
MaxinputWord, MaxWilds: integer; { Length of inputStr and Wilds }
|
MaxinputWord, MaxWilds: integer; { Length of inputStr and Wilds }
|
||||||
|
eos : Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
if Wilds = inputStr then
|
if Wilds = inputStr then
|
||||||
@ -2667,7 +2680,7 @@ begin
|
|||||||
inputStr:=AnsiUpperCase(inputStr);
|
inputStr:=AnsiUpperCase(inputStr);
|
||||||
Wilds:=AnsiUpperCase(Wilds);
|
Wilds:=AnsiUpperCase(Wilds);
|
||||||
end;
|
end;
|
||||||
Result:=isMatch(inputStr,wilds,1,1,MaxinputWord, MaxWilds);
|
Result:=isMatch(1,inputStr,wilds,1,1,MaxinputWord, MaxWilds,EOS);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user