AROS: Copy WBArgs to argv so its available for Objpas.ParamStr()

git-svn-id: trunk@30886 -
This commit is contained in:
marcus 2015-05-19 16:56:20 +00:00
parent 5b3b1c7dea
commit ff56b81ad3

View File

@ -141,7 +141,7 @@ begin
//
if AOS_wbMsg <> nil then
begin
// forbid -> Amiga RKM Libraries Manual
// forbid -> Amiga RKM Libraries Manual
Forbid();
// Reply WBStartupMessage
ReplyMsg(AOS_wbMsg);
@ -150,6 +150,50 @@ begin
HaltProc(ExitCode);
end;
function GetWBArgsNum: Integer;
var
startup: PWBStartup;
begin
GetWBArgsNum := 0;
Startup := nil;
Startup := PWBStartup(AOS_wbMsg);
if Startup <> nil then
begin
Result := Startup^.sm_NumArgs - 1;
end;
end;
function GetWBArg(Idx: Integer): string;
var
startup: PWBStartup;
wbarg: PWBArgList;
Path: array[0..254] of Char;
strPath: string;
Len: Integer;
begin
GetWBArg := '';
FillChar(Path[0],255,#0);
Startup := PWBStartup(AOS_wbMsg);
if Startup <> nil then
begin
//if (Idx >= 0) and (Idx < Startup^.sm_NumArgs) then
begin
wbarg := Startup^.sm_ArgList;
if NameFromLock(wbarg^[Idx + 1].wa_Lock,@Path[0],255) then
begin
Len := 0;
while (Path[Len] <> #0) and (Len < 254) do
Inc(Len);
if Len > 0 then
if (Path[Len - 1] <> ':') and (Path[Len - 1] <> '/') then
Path[Len] := '/';
strPath := Path;
end;
Result := strPath + wbarg^[Idx + 1].wa_Name;
end;
end;
end;
{ Generates correct argument array on startup }
procedure GenerateArgs;
var
@ -175,6 +219,7 @@ var
Start: Word;
Ende: Word;
LocalIndex: Word;
i: Integer;
P : PChar;
{$H+}
Temp : string;
@ -192,7 +237,14 @@ begin
{ check if we're started from Workbench }
if AOS_wbMsg <> nil then
begin
ArgC := 0;
ArgC := GetWBArgsNum + 1;
for i := 1 to ArgC - 1 do
begin
Temp := GetWBArg(i);
AllocArg(i, Length(Temp));
Move(Temp[1], Argv[i]^, Length(Temp));
Argv[i][Length(Temp)] := #0;
end;
Exit;
end;
@ -215,7 +267,7 @@ begin
begin
while (p[count]<>#0) and (p[count]<>'"') and (p[count]<>LineEnding) do
begin
Inc(Count)
Inc(Count)
end;
end else
begin
@ -239,7 +291,7 @@ begin
end;
if inQuotes and (p[count] = '"') then
Inc(Count);
inQuotes := False;
inQuotes := False;
end;
argc:=localindex;
end;
@ -297,50 +349,6 @@ end;
ParamStr/Randomize
*****************************************************************************}
function GetWBArgsNum: Integer;
var
startup: PWBStartup;
begin
GetWBArgsNum := 0;
Startup := nil;
Startup := PWBStartup(AOS_wbMsg);
if Startup <> nil then
begin
Result := Startup^.sm_NumArgs - 1;
end;
end;
function GetWBArg(Idx: Integer): string;
var
startup: PWBStartup;
wbarg: PWBArgList;
Path: array[0..254] of Char;
strPath: string;
Len: Integer;
begin
GetWBArg := '';
FillChar(Path[0],255,#0);
Startup := PWBStartup(AOS_wbMsg);
if Startup <> nil then
begin
//if (Idx >= 0) and (Idx < Startup^.sm_NumArgs) then
begin
wbarg := Startup^.sm_ArgList;
if NameFromLock(wbarg^[Idx + 1].wa_Lock,@Path[0],255) then
begin
Len := 0;
while (Path[Len] <> #0) and (Len < 254) do
Inc(Len);
if Len > 0 then
if (Path[Len - 1] <> ':') and (Path[Len - 1] <> '/') then
Path[Len] := '/';
strPath := Path;
end;
Result := strPath + wbarg^[Idx + 1].wa_Name;
end;
end;
end;
{ number of args }
function paramcount : longint;
begin
@ -401,12 +409,12 @@ begin
AOS_UtilityBase := OpenLibrary('utility.library', 0);
if AOS_UtilityBase = nil then
Halt(1);
{ Creating the memory pool for growing heap }
ASYS_heapPool := CreatePool(MEMF_ANY or MEMF_SEM_PROTECTED, growheapsize2, growheapsize1);
if ASYS_heapPool = nil then
Halt(1);
if AOS_wbMsg = nil then begin
StdInputHandle := THandle(dosInput);
StdOutputHandle := THandle(dosOutput);