mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-22 11:49:23 +02:00
* get paramstr(0) only if really needed
git-svn-id: trunk@43898 -
This commit is contained in:
parent
22806e31c3
commit
3335104da2
@ -425,12 +425,26 @@ end;}
|
||||
var
|
||||
execpathstr : shortstring;
|
||||
|
||||
procedure SysInitExecPath;
|
||||
var
|
||||
i : longint;
|
||||
begin
|
||||
execpathstr[0]:=#0;
|
||||
i:=Fpreadlink('/proc/self/exe',@execpathstr[1],high(execpathstr));
|
||||
{ it must also be an absolute filename, linux 2.0 points to a memory
|
||||
location so this will skip that }
|
||||
if (i>0) and (execpathstr[1]='/') then
|
||||
execpathstr[0]:=char(i);
|
||||
end;
|
||||
|
||||
function paramstr(l: longint) : string;
|
||||
begin
|
||||
{ stricly conforming POSIX applications }
|
||||
{ have the executing filename as argv[0] }
|
||||
if l=0 then
|
||||
begin
|
||||
if execpathstr='' then
|
||||
SysInitExecPath;
|
||||
paramstr := execpathstr;
|
||||
end
|
||||
else if (l < argc) then
|
||||
@ -600,19 +614,6 @@ begin
|
||||
FpSigAction(SIGILL,@oldsigill,nil);
|
||||
end;
|
||||
|
||||
|
||||
procedure SysInitExecPath;
|
||||
var
|
||||
i : longint;
|
||||
begin
|
||||
execpathstr[0]:=#0;
|
||||
i:=Fpreadlink('/proc/self/exe',@execpathstr[1],high(execpathstr));
|
||||
{ it must also be an absolute filename, linux 2.0 points to a memory
|
||||
location so this will skip that }
|
||||
if (i>0) and (execpathstr[1]='/') then
|
||||
execpathstr[0]:=char(i);
|
||||
end;
|
||||
|
||||
function GetProcessID: SizeUInt;
|
||||
begin
|
||||
GetProcessID := SizeUInt (fpGetPID);
|
||||
@ -690,8 +691,6 @@ begin
|
||||
initunicodestringmanager;
|
||||
{ Setup stdin, stdout and stderr }
|
||||
SysInitStdIO;
|
||||
{ Arguments }
|
||||
SysInitExecPath;
|
||||
{ Reset IO Error }
|
||||
InOutRes:=0;
|
||||
{ threading }
|
||||
|
Loading…
Reference in New Issue
Block a user