diff options
author | Vincent Celier <celier@adacore.com> | 2005-11-15 15:04:56 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2005-11-15 15:04:56 +0100 |
commit | d4deddd7e92a3b559af36a8f832460ff00cc19fc (patch) | |
tree | 91a514cf2a4b28fae991ff1a1824a9d2f353fdc3 /gcc/ada/switch.adb | |
parent | 49c041e306a21fdf9d38d8d2b432d3573450693c (diff) | |
download | gcc-d4deddd7e92a3b559af36a8f832460ff00cc19fc.zip gcc-d4deddd7e92a3b559af36a8f832460ff00cc19fc.tar.gz gcc-d4deddd7e92a3b559af36a8f832460ff00cc19fc.tar.bz2 |
switch.adb (Bad_Switch): New procedure
2005-11-14 Vincent Celier <celier@adacore.com>
* switch.adb (Bad_Switch): New procedure
(Scan_Nat, Scan_Pos): Directly call Osint.Fail with the appropriate
message when in error.
* switch.ads (Bad_Switch, Bad_Switch_Value, Missing_Switch_Value,
Too_Many_Output_Files): Remove declarations, no longer used.
(Scan_Nat): New parameter Switch
(Scan_Pos): Ditto
(Bad_Switch): New procedure
* switch-b.adb (Scan_Binder_Switches): Replace "raise Bad_Switch;"
with call to new procedure Bad_Switch. Call Scan_Pos and Scan_Natwith
new parameter Switch. Replace "raise Too_Many_Output_Files;" with call
to Osint.Fail. Do not handle any exception.
From-SVN: r107011
Diffstat (limited to 'gcc/ada/switch.adb')
-rw-r--r-- | gcc/ada/switch.adb | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/gcc/ada/switch.adb b/gcc/ada/switch.adb index c960b57..048678b 100644 --- a/gcc/ada/switch.adb +++ b/gcc/ada/switch.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2004, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2005, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -24,8 +24,19 @@ -- -- ------------------------------------------------------------------------------ +with Osint; + package body Switch is + ---------------- + -- Bad_Switch -- + ---------------- + + procedure Bad_Switch (Switch : Character) is + begin + Osint.Fail ("invalid switch: ", (1 => Switch)); + end Bad_Switch; + ------------------------- -- Is_Front_End_Switch -- ------------------------- @@ -61,24 +72,27 @@ package body Switch is (Switch_Chars : String; Max : Integer; Ptr : in out Integer; - Result : out Nat) + Result : out Nat; + Switch : Character) is begin Result := 0; if Ptr > Max or else Switch_Chars (Ptr) not in '0' .. '9' then - raise Missing_Switch_Value; + Osint.Fail ("missing numeric value for switch: ", (1 => Switch)); + + else + while Ptr <= Max and then Switch_Chars (Ptr) in '0' .. '9' loop + Result := Result * 10 + + Character'Pos (Switch_Chars (Ptr)) - Character'Pos ('0'); + Ptr := Ptr + 1; + + if Result > Switch_Max_Value then + Osint.Fail + ("numeric value out of range for switch: ", (1 => Switch)); + end if; + end loop; end if; - - while Ptr <= Max and then Switch_Chars (Ptr) in '0' .. '9' loop - Result := Result * 10 + - Character'Pos (Switch_Chars (Ptr)) - Character'Pos ('0'); - Ptr := Ptr + 1; - - if Result > Switch_Max_Value then - raise Bad_Switch_Value; - end if; - end loop; end Scan_Nat; -------------- @@ -89,15 +103,16 @@ package body Switch is (Switch_Chars : String; Max : Integer; Ptr : in out Integer; - Result : out Pos) + Result : out Pos; + Switch : Character) is Temp : Nat; begin - Scan_Nat (Switch_Chars, Max, Ptr, Temp); + Scan_Nat (Switch_Chars, Max, Ptr, Temp, Switch); if Temp = 0 then - raise Bad_Switch_Value; + Osint.Fail ("numeric value out of range for switch: ", (1 => Switch)); end if; Result := Temp; |