@@ -39,7 +39,7 @@ interface
3939
4040procedure WriteHelp ;
4141{ $IFNDEF FPC}
42- function ParseCmdLineParams (out aInputFile: string): Boolean;
42+ function ParseCmdLineParams (out aInputFile: string): Boolean;
4343{ $ENDIF}
4444
4545
@@ -66,7 +66,7 @@ procedure WriteHelp;
6666end ;
6767
6868{ $IFNDEF FPC}
69- function ArrayContains (const aArray: array of string; const aValue: string): Boolean;
69+ function ArrayContains (const aArray: array of string; const aValue: string): Boolean;
7070var
7171 iValue: string;
7272begin
@@ -81,41 +81,50 @@ function ArrayContains (const aArray: array of string; const aValue: string): Bo
8181 end ;
8282end ;
8383
84- function ParseCmdLineParams (out aInputFile: string): Boolean;
84+ function ParseCmdLineParams (out aInputFile: string): Boolean;
8585var
8686 I: Integer;
8787begin
8888 Result := False;
8989 aInputFile := ' ' ;
9090
9191 // 0 is the exe path, so we start at 1
92+ { $IFNDEF LINUX}
9293 for I := 1 to ParamCount do
94+ { $ELSE}
95+ for I := 1 to ParamCount + 1 do
96+ { $ENDIF}
9397 begin
94- if ArrayContains (cOptionHelp, ParamStr(I)) then
98+ if ArrayContains(cOptionHelp, ParamStr(I)) then
9599 begin
96100 WriteHelp;
97- exit;
98- end
99- else if ArrayContains (cOptionVersion, ParamStr(I)) then
100- begin
101- WriteLn(Format(rsGeneratorVersion, [ cVersion ]));
102- exit;
101+ Exit;
103102 end
104- else if ArrayContains (cOptionInput, ParamStr(I)) then
105- begin
106- // must be followed by the user's specified input file
107- if (I+1 ) <= ParamCount then
108- aInputFile := ExpandFileName (ParamStr (I+1 ));
109- if not TFile.Exists (aInputFile) then
110- WriteLn(Format(rsErrorMessage, [ Format(rsNoInputFile, [aInputFile]) ]))
111- else
103+ else
104+ if ArrayContains(cOptionVersion, ParamStr(I)) then
112105 begin
113- Result := True ;
106+ WriteLn(Format(rsGeneratorVersion, [ cVersion ])) ;
114107 exit;
115- end ;
116- end
117- else
118- WriteLn(Format(rsErrorMessage, [ rsMissingInputFlag ]));
108+ end
109+ else
110+ if ArrayContains(cOptionInput, ParamStr(I)) then
111+ begin
112+ // must be followed by the user's specified input file
113+ if (I+1 ) <= ParamCount then
114+ aInputFile := ExpandFileName (ParamStr (I+1 ));
115+ if (aInputFile = ' ' ) or (not TFile.Exists (aInputFile)) then
116+ begin
117+ WriteLn(Format(rsErrorMessage, [ Format(rsNoInputFile, [aInputFile]) ]));
118+ Exit;
119+ end
120+ else
121+ begin
122+ Result := True;
123+ Exit;
124+ end ;
125+ end
126+ else
127+ WriteLn(Format(rsErrorMessage, [ rsMissingInputFlag ]));
119128 end ;
120129end ;
121130{ $ENDIF}
0 commit comments