1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2005, 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 2, 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
29 package body Switch
is
35 procedure Bad_Switch
(Switch
: Character) is
37 Osint
.Fail
("invalid switch: ", (1 => Switch
));
40 -------------------------
41 -- Is_Front_End_Switch --
42 -------------------------
44 function Is_Front_End_Switch
(Switch_Chars
: String) return Boolean is
45 Ptr
: constant Positive := Switch_Chars
'First;
47 return Is_Switch
(Switch_Chars
)
49 (Switch_Chars
(Ptr
+ 1) = 'I'
50 or else (Switch_Chars
'Length >= 5
51 and then Switch_Chars
(Ptr
+ 1 .. Ptr
+ 4) = "gnat")
52 or else (Switch_Chars
'Length >= 5
53 and then Switch_Chars
(Ptr
+ 2 .. Ptr
+ 4) = "RTS"));
54 end Is_Front_End_Switch
;
60 function Is_Switch
(Switch_Chars
: String) return Boolean is
62 return Switch_Chars
'Length > 1
63 and then Switch_Chars
(Switch_Chars
'First) = '-';
66 ------------------------
72 (Switch_Chars
: String;
81 if Ptr
> Max
or else Switch_Chars
(Ptr
) not in '0' .. '9' then
82 Osint
.Fail
("missing numeric value for switch: ", (1 => Switch
));
85 while Ptr
<= Max
and then Switch_Chars
(Ptr
) in '0' .. '9' loop
86 Result
:= Result
* 10 +
87 Character'Pos (Switch_Chars
(Ptr
)) - Character'Pos ('0');
90 if Result
> Switch_Max_Value
then
92 ("numeric value out of range for switch: ", (1 => Switch
));
103 (Switch_Chars
: String;
105 Ptr
: in out Integer;
112 Scan_Nat
(Switch_Chars
, Max
, Ptr
, Temp
, Switch
);
115 Osint
.Fail
("numeric value out of range for switch: ", (1 => Switch
));