Browse Source

# revisions: 33258,33299,33300,33305,33330,33340,33343

git-svn-id: branches/fixes_3_0@33800 -
marco 9 years ago
parent
commit
01aa4d5c3c

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

@@ -2538,9 +2538,10 @@ begin
     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
+  EOS:=False;
   Result:=True;
   repeat
     if Wilds[CWild] = '*' then { handling of '*' }
@@ -2556,10 +2557,12 @@ begin
       Repeat
         while (inputStr[CinputWord]<>Wilds[CWild]) and (CinputWord <= MaxinputWord) do
           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
           Inc(cInputWord);
       Until Result or (CinputWord>=MaxinputWord);
+      if Result and EOS then
+        Exit;
       Continue;
       end;
     if Wilds[CWild] = '?' then { equal to '?' }
@@ -2579,9 +2582,17 @@ begin
     Result:=false;
     Exit;
   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;
 
 function isWild(inputStr, Wilds: string; ignoreCase: boolean): boolean;
@@ -2589,6 +2600,8 @@ function isWild(inputStr, Wilds: string; ignoreCase: boolean): boolean;
 var
   i: integer;
   MaxinputWord, MaxWilds: integer; { Length of inputStr and Wilds }
+  eos : Boolean;
+
 begin
   Result:=true;
   if Wilds = inputStr then
@@ -2614,7 +2627,7 @@ begin
     inputStr:=AnsiUpperCase(inputStr);
     Wilds:=AnsiUpperCase(Wilds);
     end;
-  Result:=isMatch(inputStr,wilds,1,1,MaxinputWord, MaxWilds);  
+  Result:=isMatch(1,inputStr,wilds,1,1,MaxinputWord, MaxWilds,EOS);
 end;
 
 

+ 1 - 0
rtl/objpas/rtlconst.inc

@@ -302,6 +302,7 @@ ResourceString
   SInvalidUnicodeCodePointSequence = 'Invalid unicode code point sequence';
   SClassCantBeConstructed       = 'Class %s can not be constructed';
   SErrStatusCallBackRequired    = 'Thread status report handler cannot be empty.';
+  SErrFindNeedsSortedList       = 'Cannot use find on unsorted list';
 
 { ---------------------------------------------------------------------
     Keysim Names

+ 8 - 0
rtl/objpas/sysutils/disk.inc

@@ -13,6 +13,14 @@
 
  **********************************************************************}
 
+function GetDriveIDFromLetter(Const ADrive : PathStr) : Byte;
+
+begin
+  if length(ADrive)=0 then
+    Result:=0
+  else
+    Result := (Ord(ADrive[1]))-64;
+end;
 
 {$push}
 {$i-}

+ 2 - 0
rtl/objpas/sysutils/diskh.inc

@@ -21,9 +21,11 @@ Function SetCurrentDir (Const NewDir : RawByteString) : Boolean;
 Function CreateDir (Const NewDir : RawByteString) : Boolean;
 Function RemoveDir (Const Dir : RawByteString) : Boolean;
 Function ForceDirectories(Const Dir: RawByteString): Boolean;
+Function GetDriveIDFromLetter(Const ADrive : RawByteString) : Byte;
 
 Function SetCurrentDir (Const NewDir : UnicodeString) : Boolean;
 Function CreateDir (Const NewDir : UnicodeString) : Boolean;
 Function RemoveDir (Const Dir : UnicodeString) : Boolean;
 Function ForceDirectories(Const Dir: UnicodeString): Boolean;
+Function GetDriveIDFromLetter(Const ADrive : UnicodeString) : Byte;
 

+ 1 - 1
rtl/objpas/sysutils/sysstr.inc

@@ -1460,7 +1460,7 @@ Begin
         if Negative then
           System.Delete(Result, 1, 1);
         P := Pos('.', Result);
-        If P <> 0 Then Result[P] := DS;
+        If P <> 0 Then Result[P] := DS else P := Length(Result)+1;
         Dec(P, 3);
         While (P > 1) Do
         Begin

+ 1 - 0
rtl/objpas/sysutils/sysutilh.inc

@@ -214,6 +214,7 @@ type
 
    EArgumentException = class(Exception);
    EArgumentOutOfRangeException = class(EArgumentException);
+   EArgumentNilException = class(EArgumentException);
 
    ENoConstructException = class(Exception);
 

+ 1 - 1
rtl/unix/sysutils.pp

@@ -871,7 +871,7 @@ Type
     DirPtr     : Pointer;     {directory pointer for reading directory}
     SearchSpec : RawbyteString;
     SearchType : Byte;        {0=normal, 1=open will close, 2=only 1 file}
-    SearchAttr : Byte;        {attribute we are searching for}
+    SearchAttr : Longint;     {attribute we are searching for}
   End;
   PUnixFindData = ^TUnixFindData;