From d4deddd7e92a3b559af36a8f832460ff00cc19fc Mon Sep 17 00:00:00 2001 From: Vincent Celier Date: Tue, 15 Nov 2005 15:04:56 +0100 Subject: switch.adb (Bad_Switch): New procedure 2005-11-14 Vincent Celier * 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 --- gcc/ada/switch.adb | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) (limited to 'gcc/ada/switch.adb') 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; -- cgit v1.1