mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 22:46:01 +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
|
var
|
||||||
execpathstr : shortstring;
|
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;
|
function paramstr(l: longint) : string;
|
||||||
begin
|
begin
|
||||||
{ stricly conforming POSIX applications }
|
{ stricly conforming POSIX applications }
|
||||||
{ have the executing filename as argv[0] }
|
{ have the executing filename as argv[0] }
|
||||||
if l=0 then
|
if l=0 then
|
||||||
begin
|
begin
|
||||||
|
if execpathstr='' then
|
||||||
|
SysInitExecPath;
|
||||||
paramstr := execpathstr;
|
paramstr := execpathstr;
|
||||||
end
|
end
|
||||||
else if (l < argc) then
|
else if (l < argc) then
|
||||||
@ -600,19 +614,6 @@ begin
|
|||||||
FpSigAction(SIGILL,@oldsigill,nil);
|
FpSigAction(SIGILL,@oldsigill,nil);
|
||||||
end;
|
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;
|
function GetProcessID: SizeUInt;
|
||||||
begin
|
begin
|
||||||
GetProcessID := SizeUInt (fpGetPID);
|
GetProcessID := SizeUInt (fpGetPID);
|
||||||
@ -690,8 +691,6 @@ begin
|
|||||||
initunicodestringmanager;
|
initunicodestringmanager;
|
||||||
{ Setup stdin, stdout and stderr }
|
{ Setup stdin, stdout and stderr }
|
||||||
SysInitStdIO;
|
SysInitStdIO;
|
||||||
{ Arguments }
|
|
||||||
SysInitExecPath;
|
|
||||||
{ Reset IO Error }
|
{ Reset IO Error }
|
||||||
InOutRes:=0;
|
InOutRes:=0;
|
||||||
{ threading }
|
{ threading }
|
||||||
|
Loading…
Reference in New Issue
Block a user