|
@@ -1770,39 +1770,10 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-function isWild(inputStr, Wilds: string; ignoreCase: boolean): boolean;
|
|
|
+Function isMatch(inputstr,wilds : string; CWild, CinputWord: integer;MaxInputword,maxwilds : word) : Boolean;
|
|
|
|
|
|
-var
|
|
|
- CWild, CinputWord: integer; { counter for positions }
|
|
|
- i: integer;
|
|
|
- MaxinputWord, MaxWilds: integer; { Length of inputStr and Wilds }
|
|
|
begin
|
|
|
- Result:=true;
|
|
|
- if Wilds = inputStr then
|
|
|
- Exit;
|
|
|
- { delete '**', because '**' = '*' }
|
|
|
- i:=Pos('**', Wilds);
|
|
|
- while i > 0 do
|
|
|
- begin
|
|
|
- Delete(Wilds, i, 1);
|
|
|
- i:=Pos('**', Wilds);
|
|
|
- end;
|
|
|
- if Wilds = '*' then { for fast end, if Wilds only '*' }
|
|
|
- Exit;
|
|
|
- MaxinputWord:=Length(inputStr);
|
|
|
- MaxWilds:=Length(Wilds);
|
|
|
- if (MaxWilds = 0) or (MaxinputWord = 0) then
|
|
|
- begin
|
|
|
- Result:=false;
|
|
|
- Exit;
|
|
|
- end;
|
|
|
- if ignoreCase then { upcase all letters }
|
|
|
- begin
|
|
|
- inputStr:=AnsiUpperCase(inputStr);
|
|
|
- Wilds:=AnsiUpperCase(Wilds);
|
|
|
- end;
|
|
|
- CinputWord:=1;
|
|
|
- CWild:=1;
|
|
|
+ Result:=True;
|
|
|
repeat
|
|
|
if Wilds[CWild] = '*' then { handling of '*' }
|
|
|
begin
|
|
@@ -1814,9 +1785,13 @@ begin
|
|
|
inc(CinputWord);
|
|
|
end;
|
|
|
{ increase until a match }
|
|
|
- while (inputStr[CinputWord] <> Wilds[CWild]) and
|
|
|
- (CinputWord <= MaxinputWord) do
|
|
|
- inc(CinputWord);
|
|
|
+ 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 '?' }
|
|
@@ -1837,9 +1812,41 @@ begin
|
|
|
Exit;
|
|
|
until (CinputWord > MaxinputWord) or (CWild > MaxWilds);
|
|
|
{ no completed evaluation }
|
|
|
- if (CinputWord <= MaxinputWord) or
|
|
|
- (CWild <= MaxWilds) then
|
|
|
+ if (CinputWord <= MaxinputWord) or (CWild <= MaxWilds) then
|
|
|
+ Result:=false;
|
|
|
+end;
|
|
|
+
|
|
|
+function isWild(inputStr, Wilds: string; ignoreCase: boolean): boolean;
|
|
|
+
|
|
|
+var
|
|
|
+ i: integer;
|
|
|
+ MaxinputWord, MaxWilds: integer; { Length of inputStr and Wilds }
|
|
|
+begin
|
|
|
+ Result:=true;
|
|
|
+ if Wilds = inputStr then
|
|
|
+ Exit;
|
|
|
+ { delete '**', because '**' = '*' }
|
|
|
+ i:=Pos('**', Wilds);
|
|
|
+ while i > 0 do
|
|
|
+ begin
|
|
|
+ Delete(Wilds, i, 1);
|
|
|
+ i:=Pos('**', Wilds);
|
|
|
+ end;
|
|
|
+ if Wilds = '*' then { for fast end, if Wilds only '*' }
|
|
|
+ Exit;
|
|
|
+ MaxinputWord:=Length(inputStr);
|
|
|
+ MaxWilds:=Length(Wilds);
|
|
|
+ if (MaxWilds = 0) or (MaxinputWord = 0) then
|
|
|
+ begin
|
|
|
Result:=false;
|
|
|
+ Exit;
|
|
|
+ end;
|
|
|
+ if ignoreCase then { upcase all letters }
|
|
|
+ begin
|
|
|
+ inputStr:=AnsiUpperCase(inputStr);
|
|
|
+ Wilds:=AnsiUpperCase(Wilds);
|
|
|
+ end;
|
|
|
+ Result:=isMatch(inputStr,wilds,1,1,MaxinputWord, MaxWilds);
|
|
|
end;
|
|
|
|
|
|
|