amicommon: instead of a runtime check, check for OS2.0+ features at compile time in DOS

git-svn-id: trunk@44742 -
This commit is contained in:
Károly Balogh 2020-04-17 00:14:42 +00:00
parent 024ab0a854
commit db0deab026

View File

@ -1081,40 +1081,40 @@ Var
Res: Integer; Res: Integer;
begin begin
SetLength(EnvList, 0); SetLength(EnvList, 0);
{$if not defined(AMIGA_V1_0_ONLY) and not defined(AMIGA_V1_2_ONLY)}
// pr_LocalVars are introduced with OS2.0 // pr_LocalVars are introduced with OS2.0
{$ifdef AMIGA68k}
if PLibrary(AOS_ExecBase)^.lib_Version >= 36 then ThisProcess := PProcess(FindTask(nil)); //Get the pointer to our process
{$endif} LocalVars_List := @(ThisProcess^.pr_LocalVars); //get the list of pr_LocalVars as pointer
LocalVar_Node := pLocalVar(LocalVars_List^.mlh_head); //get the headnode of the LocalVars list
// loop through the localvar list
while ( Pointer(LocalVar_Node^.lv_node.ln_Succ) <> Pointer(LocalVars_List^.mlh_Tail)) do
begin begin
ThisProcess := PProcess(FindTask(nil)); //Get the pointer to our process // make sure the active node is valid instead of empty
LocalVars_List := @(ThisProcess^.pr_LocalVars); //get the list of pr_LocalVars as pointer If not(LocalVar_Node <> nil) then
LocalVar_Node := pLocalVar(LocalVars_List^.mlh_head); //get the headnode of the LocalVars list break;
// loop through the localvar list { - process the current node - }
while ( Pointer(LocalVar_Node^.lv_node.ln_Succ) <> Pointer(LocalVars_List^.mlh_Tail)) do If (LocalVar_Node^.lv_node.ln_Type = LV_Var) then
begin begin
// make sure the active node is valid instead of empty FillChar(Buffer[0], Length(Buffer), #0); // clear Buffer
If not(LocalVar_Node <> nil) then
break;
{ - process the current node - } // get active node's name environment variable value ino buffer and make sure it's local
If (LocalVar_Node^.lv_node.ln_Type = LV_Var) then TempLen := GetVar(LocalVar_Node^.lv_Node.ln_Name, @Buffer[0], BUFFER_SIZE, GVF_LOCAL_ONLY);
If TempLen <> -1 then
begin begin
FillChar(Buffer[0], Length(Buffer), #0); // clear Buffer SetLength(EnvList, Length(EnvList) + 1);
EnvList[High(EnvList)].Name := LocalVar_Node^.lv_Node.ln_Name;
// get active node's name environment variable value ino buffer and make sure it's local EnvList[High(EnvList)].Value := string(PChar(@Buffer[0]));
TempLen := GetVar(LocalVar_Node^.lv_Node.ln_Name, @Buffer[0], BUFFER_SIZE, GVF_LOCAL_ONLY); EnvList[High(EnvList)].Local := True;
If TempLen <> -1 then
begin
SetLength(EnvList, Length(EnvList) + 1);
EnvList[High(EnvList)].Name := LocalVar_Node^.lv_Node.ln_Name;
EnvList[High(EnvList)].Value := string(PChar(@Buffer[0]));
EnvList[High(EnvList)].Local := True;
end;
end; end;
LocalVar_Node := pLocalVar(LocalVar_Node^.lv_node.ln_Succ); //we need to get the next node
end; end;
LocalVar_Node := pLocalVar(LocalVar_Node^.lv_node.ln_Succ); //we need to get the next node
end; end;
{$endif not defined(AMIGA_V1_0_ONLY) and not defined(AMIGA_V1_2_ONLY)}
// search in env for all Variables // search in env for all Variables
FillChar(Anchor,sizeof(TAnchorPath),#0); FillChar(Anchor,sizeof(TAnchorPath),#0);
Res := MatchFirst('ENV:#?', @Anchor); Res := MatchFirst('ENV:#?', @Anchor);