Browse Source

* wildcard support for directory adding, this allows the use of units/*
in ppc386.cfg

peter 25 years ago
parent
commit
2085b5abde
2 changed files with 69 additions and 13 deletions
  1. 62 10
      compiler/globals.pas
  2. 7 3
      compiler/options.pas

+ 62 - 10
compiler/globals.pas

@@ -248,6 +248,7 @@ unit globals;
     Function  RemoveDir(d:string):boolean;
     Function  RemoveDir(d:string):boolean;
     Function  GetFileTime ( Var F : File) : Longint;
     Function  GetFileTime ( Var F : File) : Longint;
     Function  GetNamedFileTime ( Const F : String) : Longint;
     Function  GetNamedFileTime ( Const F : String) : Longint;
+    Function  SplitPath(const s:string):string;
     Function  SplitFileName(const s:string):string;
     Function  SplitFileName(const s:string):string;
     Function  SplitName(const s:string):string;
     Function  SplitName(const s:string):string;
     Function  SplitExtension(Const HStr:String):String;
     Function  SplitExtension(Const HStr:String):String;
@@ -848,6 +849,17 @@ implementation
       end;
       end;
 
 
 
 
+    Function SplitPath(const s:string):string;
+      var
+        i : longint;
+      begin
+        i:=Length(s);
+        while (i>0) and not(s[i] in ['/','\']) do
+         dec(i);
+        SplitPath:=Copy(s,1,i);
+      end;
+
+
     Function SplitFileName(const s:string):string;
     Function SplitFileName(const s:string):string;
       var
       var
         p : dirstr;
         p : dirstr;
@@ -998,9 +1010,28 @@ implementation
    procedure TSearchPathList.AddPath(s:string;addfirst:boolean);
    procedure TSearchPathList.AddPath(s:string;addfirst:boolean);
      var
      var
        j        : longint;
        j        : longint;
+       hs,hsd,
        CurrentDir,
        CurrentDir,
        CurrPath : string;
        CurrPath : string;
+       dir      : searchrec;
        hp       : PStringQueueItem;
        hp       : PStringQueueItem;
+
+       procedure addcurrpath;
+       begin
+         if addfirst then
+          begin
+            Delete(currPath);
+            Insert(currPath);
+          end
+         else
+          begin
+            { Check if already in path, then we don't add it }
+            hp:=Find(currPath);
+            if not assigned(hp) then
+             Concat(currPath);
+          end;
+       end;
+
      begin
      begin
        if s='' then
        if s='' then
         exit;
         exit;
@@ -1024,18 +1055,35 @@ implementation
              CurrPath:='.'+DirSep+Copy(CurrPath,length(CurrentDir)+1,255);
              CurrPath:='.'+DirSep+Copy(CurrPath,length(CurrentDir)+1,255);
           end;
           end;
          System.Delete(s,1,j);
          System.Delete(s,1,j);
-         if addfirst then
+         if pos('*',currpath)>0 then
           begin
           begin
-            Delete(currPath);
-            Insert(currPath);
+            if currpath[length(currpath)]=dirsep then
+             hs:=Copy(currpath,1,length(CurrPath)-1)
+            else
+             hs:=currpath;
+            hsd:=SplitPath(hs);
+            findfirst(hs,directory,dir);
+            while doserror=0 do
+             begin
+               if (dir.name<>'.') and
+                  (dir.name<>'..') and
+                  ((dir.attr and directory)<>0) then
+                begin
+                  currpath:=hsd+dir.name+dirsep;
+                  if not assigned(Find(currPath)) then
+                   AddCurrPath;
+                end;
+               findnext(dir);
+             end;
+{$ifdef Linux}
+            FindClose(dir);
+{$endif}
+{$ifdef Win32}
+            FindClose(dir);
+{$endif}
           end
           end
          else
          else
-          begin
-            { Check if already in path, then we don't add it }
-            hp:=Find(currPath);
-            if not assigned(hp) then
-             Concat(currPath);
-          end;
+          addcurrpath;
        until (s='');
        until (s='');
      end;
      end;
 
 
@@ -1423,7 +1471,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.43  2000-01-04 15:15:50  florian
+  Revision 1.44  2000-01-06 15:48:59  peter
+    * wildcard support for directory adding, this allows the use of units/*
+      in ppc386.cfg
+
+  Revision 1.43  2000/01/04 15:15:50  florian
     + added compiler switch $maxfpuregisters
     + added compiler switch $maxfpuregisters
     + fixed a small problem in secondvecn
     + fixed a small problem in secondvecn
 
 

+ 7 - 3
compiler/options.pas

@@ -1323,10 +1323,10 @@ begin
 {$endif Delphi}
 {$endif Delphi}
 {$ifdef linux}
 {$ifdef linux}
   UnitSearchPath.AddPath('/usr/lib/fpc/'+version_string+'/units/'+lower(target_info.short_name),false);
   UnitSearchPath.AddPath('/usr/lib/fpc/'+version_string+'/units/'+lower(target_info.short_name),false);
-  UnitSearchPath.AddPath('/usr/lib/fpc/'+version_string+'/rtl/'+lower(target_info.short_name),false);
+  UnitSearchPath.AddPath('/usr/lib/fpc/'+version_string+'/units/'+lower(target_info.short_name)+'/rtl',false);
 {$else}
 {$else}
   UnitSearchPath.AddPath(ExePath+'../units/'+lower(target_info.short_name),false);
   UnitSearchPath.AddPath(ExePath+'../units/'+lower(target_info.short_name),false);
-  UnitSearchPath.AddPath(ExePath+'../rtl/'+lower(target_info.short_name),false);
+  UnitSearchPath.AddPath(ExePath+'../units/'+lower(target_info.short_name)+'/rtl',false);
 {$endif}
 {$endif}
   UnitSearchPath.AddPath(ExePath,false);
   UnitSearchPath.AddPath(ExePath,false);
   { Add unit dir to the object and library path }
   { Add unit dir to the object and library path }
@@ -1360,7 +1360,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.45  1999-12-20 23:23:30  pierre
+  Revision 1.46  2000-01-06 15:48:59  peter
+    * wildcard support for directory adding, this allows the use of units/*
+      in ppc386.cfg
+
+  Revision 1.45  1999/12/20 23:23:30  pierre
    + $description $version
    + $description $version
 
 
   Revision 1.44  1999/12/20 21:42:36  pierre
   Revision 1.44  1999/12/20 21:42:36  pierre