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 if AOS_wbMsg <> nil then
begin begin
// forbid -> Amiga RKM Libraries Manual // forbid -> Amiga RKM Libraries Manual
Forbid(); Forbid();
// Reply WBStartupMessage // Reply WBStartupMessage
ReplyMsg(AOS_wbMsg); ReplyMsg(AOS_wbMsg);
@ -150,6 +150,50 @@ begin
HaltProc(ExitCode); HaltProc(ExitCode);
end; 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 } { Generates correct argument array on startup }
procedure GenerateArgs; procedure GenerateArgs;
var var
@ -175,6 +219,7 @@ var
Start: Word; Start: Word;
Ende: Word; Ende: Word;
LocalIndex: Word; LocalIndex: Word;
i: Integer;
P : PChar; P : PChar;
{$H+} {$H+}
Temp : string; Temp : string;
@ -192,7 +237,14 @@ begin
{ check if we're started from Workbench } { check if we're started from Workbench }
if AOS_wbMsg <> nil then if AOS_wbMsg <> nil then
begin 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; Exit;
end; end;
@ -215,7 +267,7 @@ begin
begin begin
while (p[count]<>#0) and (p[count]<>'"') and (p[count]<>LineEnding) do while (p[count]<>#0) and (p[count]<>'"') and (p[count]<>LineEnding) do
begin begin
Inc(Count) Inc(Count)
end; end;
end else end else
begin begin
@ -239,7 +291,7 @@ begin
end; end;
if inQuotes and (p[count] = '"') then if inQuotes and (p[count] = '"') then
Inc(Count); Inc(Count);
inQuotes := False; inQuotes := False;
end; end;
argc:=localindex; argc:=localindex;
end; end;
@ -297,50 +349,6 @@ end;
ParamStr/Randomize 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 } { number of args }
function paramcount : longint; function paramcount : longint;
begin begin
@ -401,12 +409,12 @@ begin
AOS_UtilityBase := OpenLibrary('utility.library', 0); AOS_UtilityBase := OpenLibrary('utility.library', 0);
if AOS_UtilityBase = nil then if AOS_UtilityBase = nil then
Halt(1); Halt(1);
{ Creating the memory pool for growing heap } { Creating the memory pool for growing heap }
ASYS_heapPool := CreatePool(MEMF_ANY or MEMF_SEM_PROTECTED, growheapsize2, growheapsize1); ASYS_heapPool := CreatePool(MEMF_ANY or MEMF_SEM_PROTECTED, growheapsize2, growheapsize1);
if ASYS_heapPool = nil then if ASYS_heapPool = nil then
Halt(1); Halt(1);
if AOS_wbMsg = nil then begin if AOS_wbMsg = nil then begin
StdInputHandle := THandle(dosInput); StdInputHandle := THandle(dosInput);
StdOutputHandle := THandle(dosOutput); StdOutputHandle := THandle(dosOutput);