1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . C O M M A N D _ L I N E . R E M O V E --
9 -- Copyright (C) 1999-2009, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 package body Ada
.Command_Line
.Remove
is
34 -----------------------
35 -- Local Subprograms --
36 -----------------------
39 -- Initialize the Remove_Count and Remove_Args variables
45 procedure Initialize
is
47 if Remove_Args
= null then
48 Remove_Count
:= Argument_Count
;
49 Remove_Args
:= new Arg_Nums
(1 .. Argument_Count
);
51 for J
in Remove_Args
'Range loop
61 procedure Remove_Argument
(Number
: Positive) is
65 if Number
> Remove_Count
then
66 raise Constraint_Error
;
69 Remove_Count
:= Remove_Count
- 1;
71 for J
in Number
.. Remove_Count
loop
72 Remove_Args
(J
) := Remove_Args
(J
+ 1);
76 procedure Remove_Argument
(Argument
: String) is
78 for J
in reverse 1 .. Argument_Count
loop
79 if Argument
= Ada
.Command_Line
.Argument
(J
) then
85 ----------------------
86 -- Remove_Arguments --
87 ----------------------
89 procedure Remove_Arguments
(From
: Positive; To
: Natural) is
93 if From
> Remove_Count
94 or else To
> Remove_Count
96 raise Constraint_Error
;
100 Remove_Count
:= Remove_Count
- (To
- From
+ 1);
102 for J
in From
.. Remove_Count
loop
103 Remove_Args
(J
) := Remove_Args
(J
+ (To
- From
+ 1));
106 end Remove_Arguments
;
108 procedure Remove_Arguments
(Argument_Prefix
: String) is
110 for J
in reverse 1 .. Argument_Count
loop
112 Arg
: constant String := Argument
(J
);
115 if Arg
'Length >= Argument_Prefix
'Length
116 and then Arg
(1 .. Argument_Prefix
'Length) = Argument_Prefix
122 end Remove_Arguments
;
124 end Ada
.Command_Line
.Remove
;