* envstr now returns empty string when index out of bounds

This commit is contained in:
olle 2004-07-25 22:46:14 +00:00
parent 107ae4d266
commit 3f4eb52fec
2 changed files with 33 additions and 24 deletions

View File

@ -819,20 +819,23 @@ Var
i : longint;
p : ppchar;
Begin
p:=envp; {defined in system}
i:=1;
while (i<Index) and (p^<>nil) do
begin
inc(i);
inc(p);
end;
if p=nil then
if Index <= 0 then
envstr:=''
else
begin
envstr:=strpas(p^) + '=' + strpas(p^+strlen(p^)+1)
p:=envp; {defined in system}
i:=1;
while (i<Index) and (p^<>nil) do
begin
inc(i);
inc(p);
end;
if p=nil then
envstr:=''
else
envstr:=strpas(p^) + '=' + strpas(p^+strlen(p^)+1);
end;
End;
end;
function c_getenv(varname: PChar): PChar; {TODO perhaps move to a separate inc file.}

View File

@ -691,25 +691,28 @@ Begin
End;
Function EnvStr (Index: longint): String;
Var
i : longint;
p : ppchar;
Begin
p:=envp; {defined in syslinux}
i:=1;
while (i<Index) and (p^<>nil) do
begin
inc(i);
inc(p);
end;
if p=nil then
envstr:=''
if Index <= 0 then
envstr:=''
else
envstr:=strpas(p^)
End;
begin
p:=envp; {defined in syslinux}
i:=1;
while (i<Index) and (p^<>nil) do
begin
inc(i);
inc(p);
end;
if p=nil then
envstr:=''
else
envstr:=strpas(p^)
end;
end;
Function GetEnv(EnvVar: String): String;
@ -833,7 +836,10 @@ End.
{
$Log$
Revision 1.32 2004-03-14 18:42:39 peter
Revision 1.33 2004-07-25 22:46:34 olle
* envstr now returns empty string when index out of bounds
Revision 1.32 2004/03/14 18:42:39 peter
* reset searchrec info in findfirst
Revision 1.31 2004/03/04 22:15:16 marco