Browse Source

* introduction "cleanpath" (=fexpand), fixfilename(paramstr(0)) + search $PREFIX/etc/fpc.cfg

marco 20 years ago
parent
commit
9dec5c3179
2 changed files with 24 additions and 4 deletions
  1. 14 1
      compiler/globals.pas
  2. 10 3
      compiler/options.pas

+ 14 - 1
compiler/globals.pas

@@ -306,6 +306,7 @@ interface
     function  FindFilePchar(const f : string;path : pchar;var foundfile:string):boolean;
     function  FindFilePchar(const f : string;path : pchar;var foundfile:string):boolean;
     function  FindExe(const bin: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;
+    function  cleanpath(const s:string):String;
 
 
     function Shell(const command:string): longint;
     function Shell(const command:string): longint;
     function  GetEnvPChar(const envname:string):pchar;
     function  GetEnvPChar(const envname:string):pchar;
@@ -1377,6 +1378,15 @@ implementation
       end;
       end;
 
 
 
 
+function  CleanPath(const s:string):String;
+{ Wrapper that encapsulate fexpand/expandfilename}
+begin
+{$IFDEF USE_SYSUTILS}
+ cleanpath:=ExpandFileName(s);
+{$else}
+ cleanpath:=fexpand(s);
+{$endif}
+end;
  {****************************************************************************
  {****************************************************************************
                                OS Dependent things
                                OS Dependent things
  ****************************************************************************}
  ****************************************************************************}
@@ -2135,7 +2145,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.153  2004-11-05 13:14:30  florian
+  Revision 1.154  2004-12-15 16:06:47  marco
+   * introduction "cleanpath" (=fexpand), fixfilename(paramstr(0)) + search $PREFIX/etc/fpc.cfg
+
+  Revision 1.153  2004/11/05 13:14:30  florian
     * fixed arm compilation
     * fixed arm compilation
 
 
   Revision 1.152  2004/10/31 21:45:02  peter
   Revision 1.152  2004/10/31 21:45:02  peter

+ 10 - 3
compiler/options.pas

@@ -227,7 +227,7 @@ var
 begin
 begin
   WriteLogo;
   WriteLogo;
   Lines:=4;
   Lines:=4;
-  Message1(option_usage,system.paramstr(0));
+  Message1(option_usage,FixFileName(system.paramstr(0)));
   lastident:=0;
   lastident:=0;
   p:=MessagePChar(option_help_pages);
   p:=MessagePChar(option_help_pages);
   while assigned(p) do
   while assigned(p) do
@@ -1654,7 +1654,7 @@ begin
 {$ENDIF USE_SYSUTILS}
 {$ENDIF USE_SYSUTILS}
 {$ifdef Unix}
 {$ifdef Unix}
   if configpath='' then
   if configpath='' then
-   configpath:='/etc/';
+   configpath:=CleanPath(FixPath(exepath+'../etc/',false));
 {$endif}
 {$endif}
   {
   {
     Order to read configuration file :
     Order to read configuration file :
@@ -1682,6 +1682,10 @@ begin
       if CfgFileExists(exepath+fn) then
       if CfgFileExists(exepath+fn) then
        foundfn:=exepath+fn
        foundfn:=exepath+fn
      else
      else
+{$else}
+      if CfgFileExists('/etc/'+fn) then
+       foundfn:='/etc'+fn
+     else     
 {$endif}
 {$endif}
       check_configfile:=false;
       check_configfile:=false;
    end;
    end;
@@ -2091,7 +2095,10 @@ finalization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.154  2004-11-22 19:34:58  peter
+  Revision 1.155  2004-12-15 16:06:47  marco
+   * introduction "cleanpath" (=fexpand), fixfilename(paramstr(0)) + search $PREFIX/etc/fpc.cfg
+
+  Revision 1.154  2004/11/22 19:34:58  peter
     * GetHeapStatus added, removed MaxAvail,MemAvail,HeapSize
     * GetHeapStatus added, removed MaxAvail,MemAvail,HeapSize
 
 
   Revision 1.153  2004/11/17 22:21:35  peter
   Revision 1.153  2004/11/17 22:21:35  peter