1 ------------------------------------------------------------------------------
3 -- GNAT RUNTIME COMPONENTS --
5 -- A D A . C O M M A N D _ L I N E . R E M O V E --
11 -- Copyright (C) 1999 Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
34 ------------------------------------------------------------------------------
36 package body Ada
.Command_Line
.Remove
is
38 -----------------------
39 -- Local Subprograms --
40 -----------------------
43 -- Initialize the Remove_Count and Remove_Args variables.
49 procedure Initialize
is
51 if Remove_Args
= null then
52 Remove_Count
:= Argument_Count
;
53 Remove_Args
:= new Arg_Nums
(1 .. Argument_Count
);
55 for J
in Remove_Args
'Range loop
65 procedure Remove_Argument
(Number
: in Positive) is
69 if Number
> Remove_Count
then
70 raise Constraint_Error
;
73 Remove_Count
:= Remove_Count
- 1;
75 for J
in Number
.. Remove_Count
loop
76 Remove_Args
(J
) := Remove_Args
(J
+ 1);
80 procedure Remove_Argument
(Argument
: String) is
82 for J
in reverse 1 .. Argument_Count
loop
83 if Argument
= Ada
.Command_Line
.Argument
(J
) then
89 ----------------------
90 -- Remove_Arguments --
91 ----------------------
93 procedure Remove_Arguments
(From
: Positive; To
: Natural) is
97 if From
> Remove_Count
98 or else To
> Remove_Count
100 raise Constraint_Error
;
104 Remove_Count
:= Remove_Count
- (To
- From
+ 1);
106 for J
in From
.. Remove_Count
loop
107 Remove_Args
(J
) := Remove_Args
(J
+ (To
- From
+ 1));
110 end Remove_Arguments
;
112 procedure Remove_Arguments
(Argument_Prefix
: String) is
114 for J
in reverse 1 .. Argument_Count
loop
116 Arg
: constant String := Argument
(J
);
119 if Arg
'Length >= Argument_Prefix
'Length
120 and then Arg
(1 .. Argument_Prefix
'Length) = Argument_Prefix
126 end Remove_Arguments
;
128 end Ada
.Command_Line
.Remove
;