Browse Source

--- Merging r35877 into '.':
U packages/fcl-base/src/custapp.pp
--- Recording mergeinfo for merge of r35877 into '.':
U .
--- Merging r35893 into '.':
G packages/fcl-base/src/custapp.pp
--- Recording mergeinfo for merge of r35893 into '.':
G .
--- Merging r35894 into '.':
U packages/fcl-base/examples/testapp.pp
--- Recording mergeinfo for merge of r35894 into '.':
G .

# revisions: 35877,35893,35894

git-svn-id: branches/fixes_3_0@36001 -

marco 8 years ago
parent
commit
0c5b0520d7
2 changed files with 10 additions and 9 deletions
  1. 5 3
      packages/fcl-base/examples/testapp.pp
  2. 5 6
      packages/fcl-base/src/custapp.pp

+ 5 - 3
packages/fcl-base/examples/testapp.pp

@@ -6,9 +6,9 @@ program testapp;
 uses custapp,classes;
 
 Const
-  ShortOpts = 'abc:d:012';
-  Longopts : Array[1..6] of String = (
-    'add:','append','delete:','verbose','create:','file:');
+  ShortOpts = 'iabc:d:012';
+  Longopts : Array[1..7] of String = (
+    'insensitive','add:','append','delete:','verbose','create:','file:');
 
 Type
   TTestApp = Class(TCustomApplication)
@@ -23,6 +23,7 @@ Var
   Opts,FN,Args : TStrings;
 
 begin
+  CaseSensitiveOptions:=not HasOption('i','insensitive'); 
   Writeln('Exe name            : ',ExeName);
   Writeln('Help file           : ',HelpFile);
   Writeln('Terminated          : ',Terminated);
@@ -60,6 +61,7 @@ begin
     Writeln('Option append found: ',HasOption('append'));
     Writeln('Option a or append found: ',HasOption('a','append'));
     Writeln('-----------------------');
+    Opts.Clear;
     GetEnvironmentList(Opts,True);
     Writeln('Found ',Opts.Count,' environment variables');
     For I:=0 to Opts.Count-1 do

+ 5 - 6
packages/fcl-base/src/custapp.pp

@@ -362,15 +362,14 @@ end;
 
 procedure TCustomApplication.Terminate;
 begin
-  Terminate(0);
+  Terminate(ExitCode);
 end;
 
 procedure TCustomApplication.Terminate(AExitCode : Integer) ;
 
 begin
   FTerminated:=True;
-  If (AExitCode<>0) then
-    ExitCode:=AExitCode;
+  ExitCode:=AExitCode;
 end;
 
 function TCustomApplication.GetOptionAtIndex(AIndex : Integer; IsLong: Boolean): String;
@@ -649,15 +648,15 @@ begin
           J:=2;
           While ((Result='') or AllErrors) and (J<=L) do
             begin
-            P:=Pos(O[J],ShortOptions);
+            P:=Pos(O[J],SO);
             If (P=0) or (O[j]=':') then
               AddToResult(Format(SErrInvalidOption,[I,O[J]]))
             else
               begin
-              If (P<Length(ShortOptions)) and (Shortoptions[P+1]=':') then
+              If (P<Length(SO)) and (SO[P+1]=':') then
                 begin
                 // Required argument
-                If ((P+1)=Length(ShortOptions)) or (Shortoptions[P+2]<>':') Then
+                If ((P+1)=Length(SO)) or (SO[P+2]<>':') Then
                   If (J<L) or not haveArg then // Must be last in multi-opt !!
                     AddToResult(Format(SErrOptionNeeded,[I,O[J]]));
                 O:=O[j]; // O is added to arguments.