1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 1992-2001, 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 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
27 ------------------------------------------------------------------------------
29 package body Switch is
31 -------------------------
32 -- Is_Front_End_Switch --
33 -------------------------
35 function Is_Front_End_Switch (Switch_Chars : String) return Boolean is
36 Ptr : constant Positive := Switch_Chars'First;
39 return Is_Switch (Switch_Chars)
41 (Switch_Chars (Ptr + 1) = 'I'
42 or else (Switch_Chars'Length >= 5
43 and then Switch_Chars (Ptr + 1 .. Ptr + 4) = "gnat")
44 or else (Switch_Chars'Length >= 5
45 and then Switch_Chars (Ptr + 1 .. Ptr + 4) = "fRTS"));
46 end Is_Front_End_Switch;
52 function Is_Switch (Switch_Chars : String) return Boolean is
54 return Switch_Chars'Length > 1
55 and then Switch_Chars (Switch_Chars'First) = '-';
58 ------------------------
64 (Switch_Chars : String;
72 if Ptr > Max or else Switch_Chars (Ptr) not in '0' .. '9' then
73 raise Missing_Switch_Value;
76 while Ptr <= Max and then Switch_Chars (Ptr) in '0' .. '9' loop
77 Result := Result * 10 +
78 Character'Pos (Switch_Chars (Ptr)) - Character'Pos ('0');
81 if Result > Switch_Max_Value then
82 raise Bad_Switch_Value;
92 (Switch_Chars : String;
98 Scan_Nat (Switch_Chars, Max, Ptr, Result);
101 raise Bad_Switch_Value;