فهرست منبع

* new fixfilename, findfile for unix. Look first for lowercase, then
NormalCase and last for UPPERCASE names.

peter 24 سال پیش
والد
کامیت
a7fe3cb6b9
10فایلهای تغییر یافته به همراه251 افزوده شده و 125 حذف شده
  1. 8 4
      compiler/comprsrc.pas
  2. 19 15
      compiler/fmodule.pas
  3. 86 51
      compiler/globals.pas
  4. 22 14
      compiler/link.pas
  5. 11 5
      compiler/scandir.inc
  6. 8 7
      compiler/symtable.pas
  7. 9 9
      compiler/t_fbsd.pas
  8. 9 9
      compiler/t_linux.pas
  9. 7 3
      compiler/t_nwm.pas
  10. 72 8
      compiler/t_win32.pas

+ 8 - 4
compiler/comprsrc.pas

@@ -78,9 +78,9 @@ var
 begin
 begin
   resbin:='';
   resbin:='';
   if utilsdirectory<>'' then
   if utilsdirectory<>'' then
-   resbin:=FindFile(target_res.resbin+source_os.exeext,utilsdirectory,resfound)+target_res.resbin+source_os.exeext;
-  if resbin='' then
-   resbin:=FindExe(target_res.resbin,resfound);
+   resfound:=FindFile(target_res.resbin+source_os.exeext,utilsdirectory,resbin);
+  if not resfound then
+   resfound:=FindExe(target_res.resbin,resbin);
   { get also the path to be searched for the windres.h }
   { get also the path to be searched for the windres.h }
   fsplit(resbin,respath,n,e);
   fsplit(resbin,respath,n,e);
   if (not resfound) and not(cs_link_extern in aktglobalswitches) then
   if (not resfound) and not(cs_link_extern in aktglobalswitches) then
@@ -142,7 +142,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2000-12-25 00:07:25  peter
+  Revision 1.7  2001-02-20 21:41:17  peter
+    * new fixfilename, findfile for unix. Look first for lowercase, then
+      NormalCase and last for UPPERCASE names.
+
+  Revision 1.6  2000/12/25 00:07:25  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

+ 19 - 15
compiler/fmodule.pas

@@ -455,23 +455,24 @@ uses
          singlepathstring,
          singlepathstring,
          filename : string;
          filename : string;
 
 
-         Function UnitExists(const ext:string):boolean;
+         Function UnitExists(const ext:string;var foundfile:string):boolean;
          begin
          begin
            Message1(unit_t_unitsearch,Singlepathstring+filename+ext);
            Message1(unit_t_unitsearch,Singlepathstring+filename+ext);
-           UnitExists:=FileExists(Singlepathstring+FileName+ext);
+           UnitExists:=FindFile(FileName+ext,Singlepathstring,foundfile);
          end;
          end;
 
 
          Function PPUSearchPath(const s:string):boolean;
          Function PPUSearchPath(const s:string):boolean;
          var
          var
-           found   : boolean;
+           found : boolean;
+           hs    : string;
          begin
          begin
            Found:=false;
            Found:=false;
            singlepathstring:=FixPath(s,false);
            singlepathstring:=FixPath(s,false);
          { Check for PPU file }
          { Check for PPU file }
-           Found:=UnitExists(target_info.unitext);
+           Found:=UnitExists(target_info.unitext,hs);
            if Found then
            if Found then
             Begin
             Begin
-              SetFileName(SinglePathString+FileName,false);
+              SetFileName(hs,false);
               Found:=OpenPPU;
               Found:=OpenPPU;
             End;
             End;
            PPUSearchPath:=Found;
            PPUSearchPath:=Found;
@@ -481,6 +482,7 @@ uses
          var
          var
            found   : boolean;
            found   : boolean;
            ext     : string[8];
            ext     : string[8];
+           hs      : string;
          begin
          begin
            Found:=false;
            Found:=false;
            singlepathstring:=FixPath(s,false);
            singlepathstring:=FixPath(s,false);
@@ -489,13 +491,11 @@ uses
            do_compile:=true;
            do_compile:=true;
            recompile_reason:=rr_noppu;
            recompile_reason:=rr_noppu;
          {Check for .pp file}
          {Check for .pp file}
-           Found:=UnitExists(target_os.sourceext);
-           if Found then
-            Ext:=target_os.sourceext
-           else
+           Found:=UnitExists(target_os.sourceext,hs);
+           if not Found then
             begin
             begin
-            {Check for .pas}
-              Found:=UnitExists(target_os.pasext);
+              { Check for .pas }
+              Found:=UnitExists(target_os.pasext,hs);
               if Found then
               if Found then
                Ext:=target_os.pasext;
                Ext:=target_os.pasext;
             end;
             end;
@@ -503,9 +503,9 @@ uses
            if Found then
            if Found then
             begin
             begin
               sources_avail:=true;
               sources_avail:=true;
-            {Load Filenames when found}
-              mainsource:=StringDup(SinglePathString+FileName+Ext);
-              SetFileName(SinglePathString+FileName,false);
+              { Load Filenames when found }
+              mainsource:=StringDup(hs);
+              SetFileName(hs,false);
             end
             end
            else
            else
             sources_avail:=false;
             sources_avail:=false;
@@ -873,7 +873,11 @@ uses
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2000-12-25 00:07:25  peter
+  Revision 1.7  2001-02-20 21:41:15  peter
+    * new fixfilename, findfile for unix. Look first for lowercase, then
+      NormalCase and last for UPPERCASE names.
+
+  Revision 1.6  2000/12/25 00:07:25  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

+ 86 - 51
compiler/globals.pas

@@ -91,7 +91,7 @@ interface
        TSearchPathList = class(TStringList)
        TSearchPathList = class(TStringList)
          procedure AddPath(s:string;addfirst:boolean);
          procedure AddPath(s:string;addfirst:boolean);
          procedure AddList(list:TSearchPathList;addfirst:boolean);
          procedure AddList(list:TSearchPathList;addfirst:boolean);
-         function  FindFile(const f : string;var b : boolean) : string;
+         function  FindFile(const f : string;var foundfile:string):boolean;
        end;
        end;
 
 
     var
     var
@@ -254,8 +254,8 @@ interface
     function  FixFileName(const s:string):string;
     function  FixFileName(const s:string):string;
     procedure SplitBinCmd(const s:string;var bstr,cstr:string);
     procedure SplitBinCmd(const s:string;var bstr,cstr:string);
     procedure SynchronizeFileTime(const fn1,fn2:string);
     procedure SynchronizeFileTime(const fn1,fn2:string);
-    function  FindFile(const f : string;path : string;var b : boolean) : string;
-    function  FindExe(bin:string;var found:boolean):string;
+    function  FindFile(const f : string;path : string;var foundfile:string):boolean;
+    function  FindExe(const bin:string;var foundfile:string):boolean;
     function  GetShortName(const n:string):string;
     function  GetShortName(const n:string):string;
 
 
     Procedure Shell(const command:string);
     Procedure Shell(const command:string);
@@ -619,29 +619,19 @@ implementation
    function FixFileName(const s:string):string;
    function FixFileName(const s:string):string;
      var
      var
        i      : longint;
        i      : longint;
-      {$ifdef Linux}
-       NoPath : boolean;
-      {$endif Linux}
      begin
      begin
-      {$ifdef Linux}
-       NoPath:=true;
-      {$endif Linux}
        for i:=length(s) downto 1 do
        for i:=length(s) downto 1 do
         begin
         begin
           case s[i] of
           case s[i] of
-      {$ifdef Linux}
-       '/','\' : begin
-                   FixFileName[i]:='/';
-                   NoPath:=false; {Skip lowercasing path: 'X11'<>'x11' }
-                 end;
-      'A'..'Z' : if NoPath then
-                  FixFileName[i]:=char(byte(s[i])+32)
-                 else
-                  FixFileName[i]:=s[i];
-      {$else}
-           '/' : FixFileName[i]:='\';
-      'A'..'Z' : FixFileName[i]:=char(byte(s[i])+32);
-      {$endif}
+{$ifdef Unix}
+            '/','\' :
+              FixFileName[i]:='/';
+{$else Unix}
+           '/' :
+              FixFileName[i]:='\';
+           'A'..'Z' :
+              FixFileName[i]:=char(byte(s[i])+32);
+{$endif Unix}
           else
           else
            FixFileName[i]:=s[i];
            FixFileName[i]:=s[i];
           end;
           end;
@@ -805,23 +795,45 @@ implementation
      end;
      end;
 
 
 
 
-   function TSearchPathList.FindFile(const f : string;var b : boolean) : string;
+   function TSearchPathList.FindFile(const f : string;var foundfile:string):boolean;
      Var
      Var
        p : TStringListItem;
        p : TStringListItem;
      begin
      begin
-       FindFile:='';
-       b:=false;
+       FindFile:=false;
        p:=TStringListItem(first);
        p:=TStringListItem(first);
        while assigned(p) do
        while assigned(p) do
         begin
         begin
-          If FileExists(p.Str+f) then
+          {
+            Search order for case sensitive systems:
+             1. lowercase
+             2. NormalCase
+             3. UPPERCASE
+            None case sensitive only lowercase
+          }
+          FoundFile:=p.Str+Lower(f);
+          If FileExists(FoundFile) then
+           begin
+             FindFile:=true;
+             exit;
+           end;
+{$ifdef UNIX}
+          FoundFile:=p.Str+f;
+          If FileExists(FoundFile) then
            begin
            begin
-             FindFile:=p.Str;
-             b:=true;
+             FindFile:=true;
              exit;
              exit;
            end;
            end;
+          FoundFile:=p.Str+Upper(f);
+          If FileExists(FoundFile) then
+           begin
+             FindFile:=true;
+             exit;
+           end;
+{$endif UNIX}
           p:=TStringListItem(p.next);
           p:=TStringListItem(p.next);
         end;
         end;
+       { Return original filename if not found }
+       FoundFile:=f;
      end;
      end;
 
 
 
 
@@ -877,40 +889,61 @@ implementation
    end;
    end;
 
 
 
 
-   function FindFile(const f : string;path : string;var b : boolean) : string;
+   function FindFile(const f : string;path : string;var foundfile:string):boolean;
       Var
       Var
         singlepathstring : string;
         singlepathstring : string;
         i : longint;
         i : longint;
      begin
      begin
-     {$ifdef unix}
+{$ifdef Unix}
        for i:=1 to length(path) do
        for i:=1 to length(path) do
         if path[i]=':' then
         if path[i]=':' then
-       path[i]:=';';
-     {$endif}
-       b:=false;
-       FindFile:='';
+         path[i]:=';';
+{$endif Unix}
+       FindFile:=false;
        repeat
        repeat
-         i:=pos(';',path);
-         if i=0 then
+          i:=pos(';',path);
+          if i=0 then
            i:=256;
            i:=256;
-         singlepathstring:=FixPath(copy(path,1,i-1),false);
-         delete(path,1,i);
-         If FileExists (singlepathstring+f) then
+          singlepathstring:=FixPath(copy(path,1,i-1),false);
+          delete(path,1,i);
+          {
+            Search order for case sensitive systems:
+             1. lowercase
+             2. NormalCase
+             3. UPPERCASE
+            None case sensitive only lowercase
+          }
+          FoundFile:=singlepathstring+Lower(f);
+          If FileExists(FoundFile) then
            begin
            begin
-             FindFile:=singlepathstring;
-             b:=true;
+             FindFile:=true;
              exit;
              exit;
            end;
            end;
+{$ifdef UNIX}
+          FoundFile:=singlepathstring+f;
+          If FileExists(FoundFile) then
+           begin
+             FindFile:=true;
+             exit;
+           end;
+          FoundFile:=singlepathstring+Upper(f);
+          If FileExists(FoundFile) then
+           begin
+             FindFile:=true;
+             exit;
+           end;
+{$endif UNIX}
        until path='';
        until path='';
+       FoundFile:=f;
      end;
      end;
 
 
-   function FindExe(bin:string;var found:boolean):string;
+
+   function  FindExe(const bin:string;var foundfile:string):boolean;
    begin
    begin
-     bin:=FixFileName(AddExtension(bin,source_os.exeext));
 {$ifdef delphi}
 {$ifdef delphi}
-     FindExe:=FindFile(bin,'.;'+exepath+';'+dmisc.getenv('PATH'),found)+bin;
+     FindExe:=FindFile(FixFileName(AddExtension(bin,source_os.exeext)),'.;'+exepath+';'+dmisc.getenv('PATH'),foundfile);
 {$else delphi}
 {$else delphi}
-     FindExe:=FindFile(bin,'.;'+exepath+';'+dos.getenv('PATH'),found)+bin;
+     FindExe:=FindFile(FixFileName(AddExtension(bin,source_os.exeext)),'.;'+exepath+';'+dos.getenv('PATH'),foundfile);
 {$endif delphi}
 {$endif delphi}
    end;
    end;
 
 
@@ -1182,9 +1215,6 @@ implementation
      var
      var
        hs1 : namestr;
        hs1 : namestr;
        hs2 : extstr;
        hs2 : extstr;
-{$ifdef need_path_search}
-       b   : boolean;
-{$endif}
      begin
      begin
 {$ifdef delphi}
 {$ifdef delphi}
        exepath:=dmisc.getenv('PPC_EXEC_PATH');
        exepath:=dmisc.getenv('PPC_EXEC_PATH');
@@ -1200,10 +1230,11 @@ implementation
                (length(hs1) - length(source_os.exeext)+1) then
                (length(hs1) - length(source_os.exeext)+1) then
             hs1 := hs1 + source_os.exeext;
             hs1 := hs1 + source_os.exeext;
       {$ifdef delphi}
       {$ifdef delphi}
-          exepath := findfile(hs1,dmisc.getenv('PATH'),b);
+          findfile(hs1,dmisc.getenv('PATH'),exepath);
       {$else delphi}
       {$else delphi}
-          exepath := findfile(hs1,dos.getenv('PATH'),b);
+          findfile(hs1,dos.getenv('PATH'),exepath);
       {$endif delphi}
       {$endif delphi}
+          exepath:=SplitPath(exepath);
         end;
         end;
 {$endif need_path_search}
 {$endif need_path_search}
        exepath:=FixPath(exepath,false);
        exepath:=FixPath(exepath,false);
@@ -1310,7 +1341,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.27  2001-02-09 23:05:45  peter
+  Revision 1.28  2001-02-20 21:41:16  peter
+    * new fixfilename, findfile for unix. Look first for lowercase, then
+      NormalCase and last for UPPERCASE names.
+
+  Revision 1.27  2001/02/09 23:05:45  peter
     * default packenum=1 for tp7 mode
     * default packenum=1 for tp7 mode
 
 
   Revision 1.26  2001/02/05 20:47:00  peter
   Revision 1.26  2001/02/05 20:47:00  peter

+ 22 - 14
compiler/link.pas

@@ -255,9 +255,9 @@ begin
   FoundBin:='';
   FoundBin:='';
   Found:=false;
   Found:=false;
   if utilsdirectory<>'' then
   if utilsdirectory<>'' then
-   FoundBin:=FindFile(utilexe,utilsdirectory,Found)+utilexe;
+   Found:=FindFile(utilexe,utilsdirectory,Foundbin);
   if (not Found) then
   if (not Found) then
-   FoundBin:=FindExe(utilexe,Found);
+   Found:=FindExe(utilexe,Foundbin);
   if (not Found) and not(cs_link_extern in aktglobalswitches) then
   if (not Found) and not(cs_link_extern in aktglobalswitches) then
    begin
    begin
      Message1(exec_w_util_not_found,utilexe);
      Message1(exec_w_util_not_found,utilexe);
@@ -273,6 +273,7 @@ end;
 function TLinker.FindObjectFile(s:string;const unitpath:string) : string;
 function TLinker.FindObjectFile(s:string;const unitpath:string) : string;
 var
 var
   found : boolean;
   found : boolean;
+  foundfile : string;
 begin
 begin
   findobjectfile:='';
   findobjectfile:='';
   if s='' then
   if s='' then
@@ -294,24 +295,27 @@ begin
      6. exepath }
      6. exepath }
   found:=false;
   found:=false;
   if unitpath<>'' then
   if unitpath<>'' then
-   findobjectfile:=FindFile(s,unitpath,found)+s;
+   found:=FindFile(s,unitpath,foundfile);
   if (not found) then
   if (not found) then
-   findobjectfile:=FindFile(s,'.'+DirSep,found)+s;
+   found:=FindFile(s,'.'+DirSep,foundfile);
   if (not found) then
   if (not found) then
-   findobjectfile:=UnitSearchPath.FindFile(s,found)+s;
+   found:=UnitSearchPath.FindFile(s,foundfile);
   if (not found) then
   if (not found) then
-   findobjectfile:=current_module.localobjectsearchpath.FindFile(s,found)+s;
+   found:=current_module.localobjectsearchpath.FindFile(s,foundfile);
   if (not found) then
   if (not found) then
-   findobjectfile:=objectsearchpath.FindFile(s,found)+s;
+   found:=objectsearchpath.FindFile(s,foundfile);
   if (not found) then
   if (not found) then
-   findobjectfile:=FindFile(s,exepath,found)+s;
+   found:=FindFile(s,exepath,foundfile);
   if not(cs_link_extern in aktglobalswitches) and (not found) then
   if not(cs_link_extern in aktglobalswitches) and (not found) then
    Message1(exec_w_objfile_not_found,s);
    Message1(exec_w_objfile_not_found,s);
+  findobjectfile:=foundfile;
 end;
 end;
 
 
 
 
 { searches an library file }
 { searches an library file }
 function TLinker.FindLibraryFile(s:string;const ext:string;var found : boolean) : string;
 function TLinker.FindLibraryFile(s:string;const ext:string;var found : boolean) : string;
+var
+  foundfile : string;
 begin
 begin
   found:=false;
   found:=false;
   findlibraryfile:='';
   findlibraryfile:='';
@@ -330,14 +334,14 @@ begin
      2. local libary dir
      2. local libary dir
      3. global libary dir
      3. global libary dir
      4. exe path of the compiler }
      4. exe path of the compiler }
-  found:=false;
-  findlibraryfile:=FindFile(s,'.'+DirSep,found)+s;
+  found:=FindFile(s,'.'+DirSep,foundfile);
   if (not found) then
   if (not found) then
-   findlibraryfile:=current_module.locallibrarysearchpath.FindFile(s,found)+s;
+   found:=current_module.locallibrarysearchpath.FindFile(s,foundfile);
   if (not found) then
   if (not found) then
-   findlibraryfile:=librarysearchpath.FindFile(s,found)+s;
+   found:=librarysearchpath.FindFile(s,foundfile);
   if (not found) then
   if (not found) then
-   findlibraryfile:=FindFile(s,exepath,found)+s;
+   found:=FindFile(s,exepath,foundfile);
+  findlibraryfile:=foundfile;
 end;
 end;
 
 
 
 
@@ -543,7 +547,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.12  2001-01-12 19:19:44  peter
+  Revision 1.13  2001-02-20 21:41:17  peter
+    * new fixfilename, findfile for unix. Look first for lowercase, then
+      NormalCase and last for UPPERCASE names.
+
+  Revision 1.12  2001/01/12 19:19:44  peter
     * fixed searching for utils
     * fixed searching for utils
 
 
   Revision 1.11  2000/12/25 00:07:26  peter
   Revision 1.11  2000/12/25 00:07:26  peter

+ 11 - 5
compiler/scandir.inc

@@ -622,6 +622,7 @@ const
 
 
     procedure dir_include(t:tdirectivetoken);
     procedure dir_include(t:tdirectivetoken);
       var
       var
+        foundfile,
         hs    : string;
         hs    : string;
         path  : dirstr;
         path  : dirstr;
         name  : namestr;
         name  : namestr;
@@ -683,13 +684,14 @@ const
             2. local includepath
             2. local includepath
             3. global includepath }
             3. global includepath }
            found:=false;
            found:=false;
+           foundfile:='';
            if path<>'' then
            if path<>'' then
              path:=path+';';
              path:=path+';';
-           path:=FindFile(name+ext,path+current_scanner^.inputfile.path^+';.'+DirSep,found);
+           found:=FindFile(name+ext,path+current_scanner^.inputfile.path^+';.'+DirSep,foundfile);
            if (not found) then
            if (not found) then
-            path:=current_module.localincludesearchpath.FindFile(name+ext,found);
+            found:=current_module.localincludesearchpath.FindFile(name+ext,foundfile);
            if (not found) then
            if (not found) then
-            path:=includesearchpath.FindFile(name+ext,found);
+            found:=includesearchpath.FindFile(name+ext,foundfile);
          { save old postion and decrease linebreak }
          { save old postion and decrease linebreak }
            if c=newline then
            if c=newline then
             dec(current_scanner^.line_no);
             dec(current_scanner^.line_no);
@@ -697,7 +699,7 @@ const
          { shutdown current file }
          { shutdown current file }
            current_scanner^.tempcloseinputfile;
            current_scanner^.tempcloseinputfile;
          { load new file }
          { load new file }
-           hp:=do_openinputfile(path+name+ext);
+           hp:=do_openinputfile(foundfile);
            current_scanner^.addfile(hp);
            current_scanner^.addfile(hp);
            if not current_scanner^.openinputfile then
            if not current_scanner^.openinputfile then
             Message1(scan_f_cannot_open_includefile,hs);
             Message1(scan_f_cannot_open_includefile,hs);
@@ -1393,7 +1395,11 @@ const
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.17  2001-01-20 18:32:52  hajny
+  Revision 1.18  2001-02-20 21:41:18  peter
+    * new fixfilename, findfile for unix. Look first for lowercase, then
+      NormalCase and last for UPPERCASE names.
+
+  Revision 1.17  2001/01/20 18:32:52  hajny
     + APPTYPE support under OS/2, app_fs, GetEnvPChar for OS/2
     + APPTYPE support under OS/2, app_fs, GetEnvPChar for OS/2
 
 
   Revision 1.16  2001/01/13 00:09:21  peter
   Revision 1.16  2001/01/13 00:09:21  peter

+ 8 - 7
compiler/symtable.pas

@@ -1543,14 +1543,11 @@ implementation
               if (Source_Time=-1) then
               if (Source_Time=-1) then
                 begin
                 begin
                   if is_main then
                   if is_main then
-                    temp_dir:=unitsearchpath.FindFile(hs,main_found)
+                    main_found:=unitsearchpath.FindFile(hs,temp_dir)
                   else
                   else
-                    temp_dir:=includesearchpath.FindFile(hs,incfile_found);
+                    incfile_found:=includesearchpath.FindFile(hs,temp_dir);
                   if incfile_found or main_found then
                   if incfile_found or main_found then
-                   begin
-                     hs:=temp_dir+hs;
-                     Source_Time:=GetNamedFileTime(hs);
-                   end
+                    Source_Time:=GetNamedFileTime(temp_dir);
                 end;
                 end;
               if Source_Time=-1 then
               if Source_Time=-1 then
                begin
                begin
@@ -2372,7 +2369,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.24  2001-01-08 21:40:27  peter
+  Revision 1.25  2001-02-20 21:41:16  peter
+    * new fixfilename, findfile for unix. Look first for lowercase, then
+      NormalCase and last for UPPERCASE names.
+
+  Revision 1.24  2001/01/08 21:40:27  peter
     * fixed crash with unsupported token overloading
     * fixed crash with unsupported token overloading
 
 
   Revision 1.23  2000/12/25 00:07:30  peter
   Revision 1.23  2000/12/25 00:07:30  peter

+ 9 - 9
compiler/t_fbsd.pas

@@ -289,11 +289,9 @@ begin
   { try to add crti and crtbegin if linking to C }
   { try to add crti and crtbegin if linking to C }
   if linklibc then
   if linklibc then
    begin
    begin
-     s:=librarysearchpath.FindFile('crtbegin.o',found)+'crtbegin.o';
-     if found then
+     if librarysearchpath.FindFile('crtbegin.o',s) then
       LinkRes.AddFileName(s);
       LinkRes.AddFileName(s);
-     s:=librarysearchpath.FindFile('crti.o',found)+'crti.o';
-     if found then
+     if librarysearchpath.FindFile('crti.o',s) then
       LinkRes.AddFileName(s);
       LinkRes.AddFileName(s);
    end;
    end;
   { main objectfiles }
   { main objectfiles }
@@ -306,11 +304,9 @@ begin
   { objects which must be at the end }
   { objects which must be at the end }
   if linklibc then
   if linklibc then
    begin
    begin
-     s:=librarysearchpath.FindFile('crtend.o',found)+'crtend.o';
-     if found then
+     if librarysearchpath.FindFile('crtend.o',s) then
       LinkRes.AddFileName(s);
       LinkRes.AddFileName(s);
-     s:=librarysearchpath.FindFile('crtn.o',found)+'crtn.o';
-     if found then
+     if librarysearchpath.FindFile('crtn.o',s) then
       LinkRes.AddFileName(s);
       LinkRes.AddFileName(s);
    end;
    end;
   LinkRes.Add(')');
   LinkRes.Add(')');
@@ -449,7 +445,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2000-12-30 22:53:25  peter
+  Revision 1.7  2001-02-20 21:41:17  peter
+    * new fixfilename, findfile for unix. Look first for lowercase, then
+      NormalCase and last for UPPERCASE names.
+
+  Revision 1.6  2000/12/30 22:53:25  peter
     * export with the case provided in the exports section
     * export with the case provided in the exports section
 
 
   Revision 1.5  2000/12/25 00:07:30  peter
   Revision 1.5  2000/12/25 00:07:30  peter

+ 9 - 9
compiler/t_linux.pas

@@ -286,11 +286,9 @@ begin
   { try to add crti and crtbegin if linking to C }
   { try to add crti and crtbegin if linking to C }
   if linklibc then
   if linklibc then
    begin
    begin
-     s:=librarysearchpath.FindFile('crtbegin.o',found)+'crtbegin.o';
-     if found then
+     if librarysearchpath.FindFile('crtbegin.o',s) then
       LinkRes.AddFileName(s);
       LinkRes.AddFileName(s);
-     s:=librarysearchpath.FindFile('crti.o',found)+'crti.o';
-     if found then
+     if librarysearchpath.FindFile('crti.o',s) then
       LinkRes.AddFileName(s);
       LinkRes.AddFileName(s);
    end;
    end;
   { main objectfiles }
   { main objectfiles }
@@ -303,11 +301,9 @@ begin
   { objects which must be at the end }
   { objects which must be at the end }
   if linklibc then
   if linklibc then
    begin
    begin
-     s:=librarysearchpath.FindFile('crtend.o',found)+'crtend.o';
-     if found then
+     if librarysearchpath.FindFile('crtend.o',s) then
       LinkRes.AddFileName(s);
       LinkRes.AddFileName(s);
-     s:=librarysearchpath.FindFile('crtn.o',found)+'crtn.o';
-     if found then
+     if librarysearchpath.FindFile('crtn.o',s) then
       LinkRes.AddFileName(s);
       LinkRes.AddFileName(s);
    end;
    end;
   LinkRes.Add(')');
   LinkRes.Add(')');
@@ -447,7 +443,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.10  2000-12-30 22:53:25  peter
+  Revision 1.11  2001-02-20 21:41:17  peter
+    * new fixfilename, findfile for unix. Look first for lowercase, then
+      NormalCase and last for UPPERCASE names.
+
+  Revision 1.10  2000/12/30 22:53:25  peter
     * export with the case provided in the exports section
     * export with the case provided in the exports section
 
 
   Revision 1.9  2000/12/25 00:07:30  peter
   Revision 1.9  2000/12/25 00:07:30  peter

+ 7 - 3
compiler/t_nwm.pas

@@ -325,7 +325,7 @@ begin
            if i>0 then
            if i>0 then
             Delete(S,i,255);
             Delete(S,i,255);
            S := S + '.imp';
            S := S + '.imp';
-           S := librarysearchpath.FindFile(S,found)+S;
+           librarysearchpath.FindFile(S,s);
            LinkRes.Add('IMPORT @'+s);
            LinkRes.Add('IMPORT @'+s);
          end
          end
       end;
       end;
@@ -349,7 +349,7 @@ begin
            if i>0 then
            if i>0 then
             Delete(S,i,255);
             Delete(S,i,255);
            S := S + '.imp';
            S := S + '.imp';
-           S := librarysearchpath.FindFile(S,found)+S;
+           librarysearchpath.FindFile(S,s);
            LinkRes.Add('IMPORT @'+s);
            LinkRes.Add('IMPORT @'+s);
            LinkRes.Add('MODULE '+s2);
            LinkRes.Add('MODULE '+s2);
          end
          end
@@ -422,7 +422,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2000-12-25 00:07:30  peter
+  Revision 1.6  2001-02-20 21:41:16  peter
+    * new fixfilename, findfile for unix. Look first for lowercase, then
+      NormalCase and last for UPPERCASE names.
+
+  Revision 1.5  2000/12/25 00:07:30  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

+ 72 - 8
compiler/t_win32.pas

@@ -38,6 +38,7 @@ interface
       procedure importprocedure(const func,module:string;index:longint;const name:string);override;
       procedure importprocedure(const func,module:string;index:longint;const name:string);override;
       procedure importvariable(const varname,module:string;const name:string);override;
       procedure importvariable(const varname,module:string;const name:string);override;
       procedure generatelib;override;
       procedure generatelib;override;
+      procedure generatenasmlib;virtual;
       procedure generatesmartlib;override;
       procedure generatesmartlib;override;
     end;
     end;
 
 
@@ -48,6 +49,7 @@ interface
       procedure exportprocedure(hp : texported_item);override;
       procedure exportprocedure(hp : texported_item);override;
       procedure exportvar(hp : texported_item);override;
       procedure exportvar(hp : texported_item);override;
       procedure generatelib;override;
       procedure generatelib;override;
+      procedure generatenasmlib;virtual;
     end;
     end;
 
 
     tlinkerwin32=class(tlinker)
     tlinkerwin32=class(tlinker)
@@ -101,13 +103,13 @@ implementation
           1. Current dir
           1. Current dir
           2. Library Path
           2. Library Path
           3. windir,windir/system,windir/system32 }
           3. windir,windir/system,windir/system32 }
-        FoundDll:=FindFile(s,'.'+DirSep,found)+s;
+        Found:=FindFile(s,'.'+DirSep,founddll);
         if (not found) then
         if (not found) then
-         FoundDll:=includesearchpath.FindFile(s,found)+s;
+         Found:=includesearchpath.FindFile(s,founddll);
         if (not found) then
         if (not found) then
          begin
          begin
            sysdir:=FixPath(GetEnv('windir'),false);
            sysdir:=FixPath(GetEnv('windir'),false);
-           FoundDll:=FindFile(s,sysdir+';'+sysdir+'system'+DirSep+';'+sysdir+'system32'+DirSep,found)+s;
+           Found:=FindFile(s,sysdir+';'+sysdir+'system'+DirSep+';'+sysdir+'system32'+DirSep,founddll);
          end;
          end;
         if (not found) then
         if (not found) then
          begin
          begin
@@ -191,6 +193,33 @@ implementation
          hp1.imported_items.concat(hp2);
          hp1.imported_items.concat(hp2);
       end;
       end;
 
 
+    procedure timportlibwin32.generatenasmlib;
+      var
+         hp1 : timportlist;
+         hp2 : timported_item;
+         p : pchar;
+      begin
+         importssection.concat(tai_section.create(sec_code));
+         hp1:=timportlist(current_module.imports.first);
+         while assigned(hp1) do
+           begin
+             hp2:=timported_item(hp1.imported_items.first);
+             while assigned(hp2) do
+               begin
+                 if (aktoutputformat=as_i386_tasm) or
+                    (aktoutputformat=as_i386_masm) then
+                   p:=strpnew(#9+'EXTRN '+hp2.func^)
+                 else
+                   p:=strpnew(#9+'EXTERN '+hp2.func^);
+                 importssection.concat(tai_direct.create(p));
+                 p:=strpnew(#9+'import '+hp2.func^+' '+hp1.dllname^+' '+hp2.name^);
+                 importssection.concat(tai_direct.create(p));
+                 hp2:=timported_item(hp2.next);
+               end;
+             hp1:=timportlist(hp1.next);
+           end;
+      end;
+
 
 
     procedure timportlibwin32.generatesmartlib;
     procedure timportlibwin32.generatesmartlib;
       var
       var
@@ -200,6 +229,12 @@ implementation
          lidata4,lidata5 : pasmlabel;
          lidata4,lidata5 : pasmlabel;
          r : preference;
          r : preference;
       begin
       begin
+         if (aktoutputformat<>as_i386_asw) and
+            (aktoutputformat<>as_i386_pecoff) then
+          begin
+            generatenasmlib;
+            exit;
+          end;
          hp1:=timportlist(current_module.imports.first);
          hp1:=timportlist(current_module.imports.first);
          while assigned(hp1) do
          while assigned(hp1) do
            begin
            begin
@@ -305,6 +340,12 @@ implementation
          l1,l2,l3,l4 : pasmlabel;
          l1,l2,l3,l4 : pasmlabel;
          r : preference;
          r : preference;
       begin
       begin
+         if (aktoutputformat<>as_i386_asw) and
+            (aktoutputformat<>as_i386_pecoff) then
+          begin
+            generatenasmlib;
+            exit;
+          end;
          hp1:=timportlist(current_module.imports.first);
          hp1:=timportlist(current_module.imports.first);
          while assigned(hp1) do
          while assigned(hp1) do
            begin
            begin
@@ -490,6 +531,12 @@ implementation
          address_table,name_table_pointers,
          address_table,name_table_pointers,
          name_table,ordinal_table : TAAsmoutput;
          name_table,ordinal_table : TAAsmoutput;
       begin
       begin
+        if (aktoutputformat<>as_i386_asw) and
+           (aktoutputformat<>as_i386_pecoff) then
+         begin
+           generatenasmlib;
+           exit;
+         end;
 
 
          hp:=texported_item(current_module._exports.first);
          hp:=texported_item(current_module._exports.first);
          if not assigned(hp) then
          if not assigned(hp) then
@@ -637,6 +684,21 @@ implementation
          temtexport.free;
          temtexport.free;
       end;
       end;
 
 
+    procedure texportlibwin32.generatenasmlib;
+      var
+         hp : texported_item;
+         p : pchar;
+      begin
+         exportssection.concat(tai_section.create(sec_code));
+         hp:=texported_item(current_module._exports.first);
+         while assigned(hp) do
+           begin
+             p:=strpnew(#9+'export '+hp.sym^.mangledname+' '+hp.name^+' '+tostr(hp.index));
+             exportssection.concat(tai_direct.create(p));
+             hp:=texported_item(hp.next);
+           end;
+      end;
+
 
 
 {****************************************************************************
 {****************************************************************************
                               TLINKERWIN32
                               TLINKERWIN32
@@ -830,7 +892,6 @@ function TLinkerWin32.MakeExecutable:boolean;
 var
 var
   binstr,
   binstr,
   cmdstr  : string;
   cmdstr  : string;
-  found,
   success : boolean;
   success : boolean;
   i       : longint;
   i       : longint;
   AsBinStr     : string[80];
   AsBinStr     : string[80];
@@ -847,7 +908,7 @@ begin
   AppTypeStr:='';
   AppTypeStr:='';
   ImageBaseStr:='';
   ImageBaseStr:='';
   StripStr:='';
   StripStr:='';
-  AsBinStr:=FindExe('asw',found);
+  FindExe('asw',AsBinStr);
   if RelocSection then
   if RelocSection then
    { Using short form to avoid problems with 128 char limitation under Dos. }
    { Using short form to avoid problems with 128 char limitation under Dos. }
    RelocStr:='-b base.$$$';
    RelocStr:='-b base.$$$';
@@ -910,7 +971,6 @@ Function TLinkerWin32.MakeSharedLibrary:boolean;
 var
 var
   binstr,
   binstr,
   cmdstr  : string;
   cmdstr  : string;
-  found,
   success : boolean;
   success : boolean;
   i       : longint;
   i       : longint;
   AsBinStr     : string[80];
   AsBinStr     : string[80];
@@ -928,7 +988,7 @@ begin
   AppTypeStr:='';
   AppTypeStr:='';
   ImageBaseStr:='';
   ImageBaseStr:='';
   StripStr:='';
   StripStr:='';
-  AsBinStr:=FindExe('asw',found);
+  FindExe('asw',AsBinStr);
   if RelocSection then
   if RelocSection then
    { Using short form to avoid problems with 128 char limitation under Dos. }
    { Using short form to avoid problems with 128 char limitation under Dos. }
    RelocStr:='-b base.$$$';
    RelocStr:='-b base.$$$';
@@ -1194,7 +1254,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.9  2001-01-13 00:09:22  peter
+  Revision 1.10  2001-02-20 21:41:16  peter
+    * new fixfilename, findfile for unix. Look first for lowercase, then
+      NormalCase and last for UPPERCASE names.
+
+  Revision 1.9  2001/01/13 00:09:22  peter
     * made Pavel O. happy ;)
     * made Pavel O. happy ;)
 
 
   Revision 1.8  2000/12/30 22:53:25  peter
   Revision 1.8  2000/12/30 22:53:25  peter