Browse Source

* Refactor: add utility routine to handle command-line changes

Michael VAN CANNEYT 2 years ago
parent
commit
c6effbd676
1 changed files with 13 additions and 6 deletions
  1. 13 6
      compiler/utils/fpc.pp

+ 13 - 6
compiler/utils/fpc.pp

@@ -258,6 +258,14 @@ program fpc;
      ppccommandlinelen : longint;
      i : longint;
      errorvalue     : Longint;
+
+     Procedure AddToCommandLine(S : String);
+
+     begin
+       PPCCommandLine [PPCCommandLineLen] := S;
+       Inc(PPCCommandLineLen);
+     end;
+
   begin
      setlength(ppccommandline,paramcount);
      ppccommandlinelen:=0;
@@ -269,8 +277,7 @@ program fpc;
      if ParamCount = 0 then
        begin
          SetLength (PPCCommandLine, 1);
-         PPCCommandLine [PPCCommandLineLen] := '-?F' + ParamStr (0);
-         Inc (PPCCommandLineLen);
+         AddToCommandLine('-?F' + ParamStr (0));
        end
      else
       for i:=1 to paramcount do
@@ -305,12 +312,11 @@ program fpc;
               else
                 begin
                   if pos('-h',s)=1 then
-                    ppccommandline[ppccommandlinelen] := '-hF' + ParamStr (0)
+                    AddToCommandLine('-hF'+ParamStr(0))
                   else if pos('-?',s)=1 then
-                    ppccommandline[ppccommandlinelen] := '-?F' + ParamStr (0)
+                    AddToCommandLine('-?F'+ParamStr(0))
                   else
-                    ppccommandline[ppccommandlinelen]:=s;
-                  inc(ppccommandlinelen);
+                    AddToCommandLine(S);
                 end;
             end;
        end;
@@ -330,3 +336,4 @@ program fpc;
        error(ppcbin+' returned an error exitcode');
      halt(errorvalue);
   end.
+