Browse Source

* Fix bug ID #29393

git-svn-id: trunk@33299 -
michael 9 years ago
parent
commit
f1a7d07f8e
1 changed files with 19 additions and 6 deletions
  1. 19 6
      packages/rtl-objpas/src/inc/strutils.pp

+ 19 - 6
packages/rtl-objpas/src/inc/strutils.pp

@@ -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 }
-  if (CinputWord <= MaxinputWord) or (CWild <= MaxWilds) then
-    Result:=false;
+  { no completed evaluation, we need to check what happened }
+  if (CinputWord < MaxinputWord) or (CWild < MaxWilds) then
+    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;