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; IsHandled: array[0..50] of boolean;
URL: String; URL: String;
StrItem: PStringItem; StrItem: PStringItem;
Filename: String;
begin begin
FillChar(IsHandled{%H-}, 51, 0); 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 if LowerCase(ParamStrUTF8(X)) = '--ipcname' then begin
IsHandled[X] := True; IsHandled[X] := True;
if X < ParamCount then begin inc(X);
fServerName := ParamStrUTF8(X+1); if X <= ParamCount then begin
IsHandled[X+1] := True; fServerName := ParamStrUTF8(X);
IsHandled[X] := True;
inc(X);
end; end;
end; end else if LowerCase(ParamStrUTF8(X)) = '--context' then begin
if LowerCase(ParamStrUTF8(X)) = '--context' then begin
IsHandled[X] := True; IsHandled[X] := True;
if (X < ParamCount) then inc(X);
if TryStrToInt(ParamStrUTF8(X+1), fContext) then if (X <= ParamCount) then
IsHandled[X+1] := True; 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;
end; end;
// Loop through a second time for the url // Loop through a second time for the url
for X := 1 to ParamCount do for X := 1 to ParamCount do
if not IsHandled[X] then begin if not IsHandled[X] then begin
//DoOpenChm(ParamStrUTF8(X)); //DoOpenChm(ParamStrUTF8(X));
if Pos('://', ParamStrUTF8(X)) = 0 then URL:=ParamStrUTF8(X);
URL := 'file://'+ParamStrUTF8(X) if Pos('://', URL) = 0 then
else URL := 'file://'+URL;
URL := ParamStrUTF8(X); 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 := New(PStringItem);
StrItem^.FString := URL; StrItem^.FString := URL;
Application.QueueAsyncCall(TDataEvent(@LateOpenURL), {%H-}PtrUInt(StrItem)); Application.QueueAsyncCall(TDataEvent(@LateOpenURL), {%H-}PtrUInt(StrItem));