IDE: added safeguard against getting environmentstrings that start with '=' as can happen on windows. This fixes bug #1685 and #7699

git-svn-id: trunk@10331 -
This commit is contained in:
vincents 2006-12-14 20:24:04 +00:00
parent cffc736d63
commit a0507c6111

View File

@ -47,11 +47,15 @@ Begin
SysVarCount:=GetEnvironmentVariableCount;
for i:=0 to SysVarCount-1 do begin
Variable:=GetEnvironmentString(i+1);
e:=1;
while (e<=length(Variable)) and (Variable[e]<>'=') do inc(e);
Value:=copy(Variable,e+1,length(Variable)-e);
Variable:=LeftStr(Variable,e-1);
Result.Values[Variable]:=Value;
// On windows some (hidden) envirionment variables can be returned by
// GetEnvironmentString. These kind of variables start with a =
if (length(Variable)>0) and (Variable[1]<>'=') then begin
e:=1;
while (e<=length(Variable)) and (Variable[e]<>'=') do inc(e);
Value:=copy(Variable,e+1,length(Variable)-e);
Variable:=LeftStr(Variable,e-1);
Result.Values[Variable]:=Value;
end;
end;
end;