lhelp: ignore unknown options, skip missing files

git-svn-id: trunk@38056 -
This commit is contained in:
mattias 2012-07-27 12:15:48 +00:00
parent 6b91dca009
commit c899962a43

View File

@ -454,31 +454,48 @@ var
IsHandled: array[0..50] of boolean;
URL: String;
StrItem: PStringItem;
Filename: String;
begin
FillChar(IsHandled{%H-}, 51, 0);
for X := 1 to ParamCount do begin
X:=1;
while X<=ParamCount do begin
if LowerCase(ParamStrUTF8(X)) = '--ipcname' then begin
IsHandled[X] := True;
if X < ParamCount then begin
fServerName := ParamStrUTF8(X+1);
IsHandled[X+1] := True;
inc(X);
if X <= ParamCount then begin
fServerName := ParamStrUTF8(X);
IsHandled[X] := True;
inc(X);
end;
end;
if LowerCase(ParamStrUTF8(X)) = '--context' then begin
end else if LowerCase(ParamStrUTF8(X)) = '--context' then begin
IsHandled[X] := True;
if (X < ParamCount) then
if TryStrToInt(ParamStrUTF8(X+1), fContext) then
IsHandled[X+1] := True;
inc(X);
if (X <= ParamCount) then
if TryStrToInt(ParamStrUTF8(X), fContext) then begin
IsHandled[X] := True;
inc(X);
end;
end else begin
IsHandled[X]:=copy(ParamStrUTF8(X),1,1)='-'; // ignore other parameters
inc(X);
end;
end;
// Loop through a second time for the url
for X := 1 to ParamCount do
if not IsHandled[X] then begin
//DoOpenChm(ParamStrUTF8(X));
if Pos('://', ParamStrUTF8(X)) = 0 then
URL := 'file://'+ParamStrUTF8(X)
else
URL := ParamStrUTF8(X);
URL:=ParamStrUTF8(X);
if Pos('://', URL) = 0 then
URL := 'file://'+URL;
Filename:=URL;
if copy(Filename,1,length('file://'))='file://' then begin
System.Delete(Filename,1,length('file://'));
Filename:=SetDirSeparators(Filename);
if not FileExistsUTF8(Filename) then begin
debugln(['THelpForm.ReadCommandLineOptions file not found "',Filename,'"']);
continue;
end;
end;
StrItem := New(PStringItem);
StrItem^.FString := URL;
Application.QueueAsyncCall(TDataEvent(@LateOpenURL), {%H-}PtrUInt(StrItem));