mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 10:45:08 +02:00
* Replace environment variables placed between dollar signs in fpc.cfg
with the value of the environment variable. git-svn-id: trunk@16945 -
This commit is contained in:
parent
80ec9bb7bc
commit
db6bc3bd00
@ -719,6 +719,10 @@ implementation
|
||||
****************************************************************************}
|
||||
|
||||
procedure DefaultReplacements(var s:ansistring);
|
||||
var
|
||||
envstr: string;
|
||||
envvalue: pchar;
|
||||
i: integer;
|
||||
begin
|
||||
{ Replace some macros }
|
||||
Replace(s,'$FPCVERSION',version_string);
|
||||
@ -730,6 +734,29 @@ implementation
|
||||
Replace(s,'$FPCTARGET',target_os_string)
|
||||
else
|
||||
Replace(s,'$FPCTARGET',target_full_string);
|
||||
{ Replace environment variables between dollar signs }
|
||||
i := pos('$',s);
|
||||
while i>0 do
|
||||
begin
|
||||
envstr:=copy(s,i+1,length(s)-i);
|
||||
i:=pos('$',envstr);
|
||||
if i>0 then
|
||||
begin
|
||||
envstr := copy(envstr,1,i-1);
|
||||
envvalue := GetEnvPChar(envstr);
|
||||
if assigned(envvalue) then
|
||||
begin
|
||||
Replace(s,'$'+envstr+'$',envvalue);
|
||||
// Look if there is another env.var in the string
|
||||
i:=pos('$',s);
|
||||
end
|
||||
else
|
||||
// if the env.var is not set, do not replace the env.variable
|
||||
// and stop looking for more env.var within the string
|
||||
i := 0;
|
||||
FreeEnvPChar(envvalue);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user