mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 01:59:18 +02:00
parent
46a0eced9e
commit
27b1fb0439
@ -1770,10 +1770,55 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Function isMatch(inputstr,wilds : string; CWild, CinputWord: integer;MaxInputword,maxwilds : word) : Boolean;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=True;
|
||||||
|
repeat
|
||||||
|
if Wilds[CWild] = '*' then { handling of '*' }
|
||||||
|
begin
|
||||||
|
inc(CWild);
|
||||||
|
while Wilds[CWild] = '?' do { equal to '?' }
|
||||||
|
begin
|
||||||
|
{ goto next letter }
|
||||||
|
inc(CWild);
|
||||||
|
inc(CinputWord);
|
||||||
|
end;
|
||||||
|
{ increase until a match }
|
||||||
|
Repeat
|
||||||
|
while (inputStr[CinputWord]<>Wilds[CWild]) and (CinputWord <= MaxinputWord) do
|
||||||
|
inc(CinputWord);
|
||||||
|
Result:=isMatch(inputstr,wilds,CWild, CinputWord,MaxInputword,maxwilds);
|
||||||
|
if not Result then
|
||||||
|
Inc(cInputWord);
|
||||||
|
Until Result or (CinputWord>=MaxinputWord);
|
||||||
|
Continue;
|
||||||
|
end;
|
||||||
|
if Wilds[CWild] = '?' then { equal to '?' }
|
||||||
|
begin
|
||||||
|
{ goto next letter }
|
||||||
|
inc(CWild);
|
||||||
|
inc(CinputWord);
|
||||||
|
Continue;
|
||||||
|
end;
|
||||||
|
if inputStr[CinputWord] = Wilds[CWild] then { equal letters }
|
||||||
|
begin
|
||||||
|
{ goto next letter }
|
||||||
|
inc(CWild);
|
||||||
|
inc(CinputWord);
|
||||||
|
Continue;
|
||||||
|
end;
|
||||||
|
Result:=false;
|
||||||
|
Exit;
|
||||||
|
until (CinputWord > MaxinputWord) or (CWild > MaxWilds);
|
||||||
|
{ no completed evaluation }
|
||||||
|
if (CinputWord <= MaxinputWord) or (CWild <= MaxWilds) then
|
||||||
|
Result:=false;
|
||||||
|
end;
|
||||||
|
|
||||||
function isWild(inputStr, Wilds: string; ignoreCase: boolean): boolean;
|
function isWild(inputStr, Wilds: string; ignoreCase: boolean): boolean;
|
||||||
|
|
||||||
var
|
var
|
||||||
CWild, CinputWord: integer; { counter for positions }
|
|
||||||
i: integer;
|
i: integer;
|
||||||
MaxinputWord, MaxWilds: integer; { Length of inputStr and Wilds }
|
MaxinputWord, MaxWilds: integer; { Length of inputStr and Wilds }
|
||||||
begin
|
begin
|
||||||
@ -1801,45 +1846,7 @@ begin
|
|||||||
inputStr:=AnsiUpperCase(inputStr);
|
inputStr:=AnsiUpperCase(inputStr);
|
||||||
Wilds:=AnsiUpperCase(Wilds);
|
Wilds:=AnsiUpperCase(Wilds);
|
||||||
end;
|
end;
|
||||||
CinputWord:=1;
|
Result:=isMatch(inputStr,wilds,1,1,MaxinputWord, MaxWilds);
|
||||||
CWild:=1;
|
|
||||||
repeat
|
|
||||||
if Wilds[CWild] = '*' then { handling of '*' }
|
|
||||||
begin
|
|
||||||
inc(CWild);
|
|
||||||
while Wilds[CWild] = '?' do { equal to '?' }
|
|
||||||
begin
|
|
||||||
{ goto next letter }
|
|
||||||
inc(CWild);
|
|
||||||
inc(CinputWord);
|
|
||||||
end;
|
|
||||||
{ increase until a match }
|
|
||||||
while (inputStr[CinputWord] <> Wilds[CWild]) and
|
|
||||||
(CinputWord <= MaxinputWord) do
|
|
||||||
inc(CinputWord);
|
|
||||||
Continue;
|
|
||||||
end;
|
|
||||||
if Wilds[CWild] = '?' then { equal to '?' }
|
|
||||||
begin
|
|
||||||
{ goto next letter }
|
|
||||||
inc(CWild);
|
|
||||||
inc(CinputWord);
|
|
||||||
Continue;
|
|
||||||
end;
|
|
||||||
if inputStr[CinputWord] = Wilds[CWild] then { equal letters }
|
|
||||||
begin
|
|
||||||
{ goto next letter }
|
|
||||||
inc(CWild);
|
|
||||||
inc(CinputWord);
|
|
||||||
Continue;
|
|
||||||
end;
|
|
||||||
Result:=false;
|
|
||||||
Exit;
|
|
||||||
until (CinputWord > MaxinputWord) or (CWild > MaxWilds);
|
|
||||||
{ no completed evaluation }
|
|
||||||
if (CinputWord <= MaxinputWord) or
|
|
||||||
(CWild <= MaxWilds) then
|
|
||||||
Result:=false;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user