1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 1992-2001, Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
26 ------------------------------------------------------------------------------
28 package body Switch
is
30 -------------------------
31 -- Is_Front_End_Switch --
32 -------------------------
34 function Is_Front_End_Switch
(Switch_Chars
: String) return Boolean is
35 Ptr
: constant Positive := Switch_Chars
'First;
38 return Is_Switch
(Switch_Chars
)
40 (Switch_Chars
(Ptr
+ 1) = 'I'
41 or else (Switch_Chars
'Length >= 5
42 and then Switch_Chars
(Ptr
+ 1 .. Ptr
+ 4) = "gnat")
43 or else (Switch_Chars
'Length >= 5
44 and then Switch_Chars
(Ptr
+ 1 .. Ptr
+ 4) = "fRTS"));
45 end Is_Front_End_Switch
;
51 function Is_Switch
(Switch_Chars
: String) return Boolean is
53 return Switch_Chars
'Length > 1
54 and then Switch_Chars
(Switch_Chars
'First) = '-';
57 ------------------------
63 (Switch_Chars
: String;
71 if Ptr
> Max
or else Switch_Chars
(Ptr
) not in '0' .. '9' then
72 raise Missing_Switch_Value
;
75 while Ptr
<= Max
and then Switch_Chars
(Ptr
) in '0' .. '9' loop
76 Result
:= Result
* 10 +
77 Character'Pos (Switch_Chars
(Ptr
)) - Character'Pos ('0');
80 if Result
> Switch_Max_Value
then
81 raise Bad_Switch_Value
;
91 (Switch_Chars
: String;
97 Scan_Nat
(Switch_Chars
, Max
, Ptr
, Result
);
100 raise Bad_Switch_Value
;