Remove some compile time warnings about duplicate definitions.
[official-gcc.git] / gcc / ada / a-colire.adb
blob8188ae742a645dd42425d1f220f56c50c9782689
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUNTIME COMPONENTS --
4 -- --
5 -- A D A . C O M M A N D _ L I N E . R E M O V E --
6 -- --
7 -- B o d y --
8 -- --
9 -- $Revision: 1.1 $
10 -- --
11 -- Copyright (C) 1999 Free Software Foundation, Inc. --
12 -- --
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. --
23 -- --
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. --
30 -- --
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). --
33 -- --
34 ------------------------------------------------------------------------------
36 package body Ada.Command_Line.Remove is
38 -----------------------
39 -- Local Subprograms --
40 -----------------------
42 procedure Initialize;
43 -- Initialize the Remove_Count and Remove_Args variables.
45 ----------------
46 -- Initialize --
47 ----------------
49 procedure Initialize is
50 begin
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
56 Remove_Args (J) := J;
57 end loop;
58 end if;
59 end Initialize;
61 ---------------------
62 -- Remove_Argument --
63 ---------------------
65 procedure Remove_Argument (Number : in Positive) is
66 begin
67 Initialize;
69 if Number > Remove_Count then
70 raise Constraint_Error;
71 end if;
73 Remove_Count := Remove_Count - 1;
75 for J in Number .. Remove_Count loop
76 Remove_Args (J) := Remove_Args (J + 1);
77 end loop;
78 end Remove_Argument;
80 procedure Remove_Argument (Argument : String) is
81 begin
82 for J in reverse 1 .. Argument_Count loop
83 if Argument = Ada.Command_Line.Argument (J) then
84 Remove_Argument (J);
85 end if;
86 end loop;
87 end Remove_Argument;
89 ----------------------
90 -- Remove_Arguments --
91 ----------------------
93 procedure Remove_Arguments (From : Positive; To : Natural) is
94 begin
95 Initialize;
97 if From > Remove_Count
98 or else To > Remove_Count
99 then
100 raise Constraint_Error;
101 end if;
103 if To >= From then
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));
108 end loop;
109 end if;
110 end Remove_Arguments;
112 procedure Remove_Arguments (Argument_Prefix : String) is
113 begin
114 for J in reverse 1 .. Argument_Count loop
115 declare
116 Arg : constant String := Argument (J);
118 begin
119 if Arg'Length >= Argument_Prefix'Length
120 and then Arg (1 .. Argument_Prefix'Length) = Argument_Prefix
121 then
122 Remove_Argument (J);
123 end if;
124 end;
125 end loop;
126 end Remove_Arguments;
128 end Ada.Command_Line.Remove;