-- --
-- B o d y --
-- --
--- Copyright (C) 2001-2005 Free Software Foundation, Inc. --
+-- Copyright (C) 2001-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- --
-- Skip past the initial character (must be the switch character)
if Ptr = Max then
- raise Bad_Switch;
+ Bad_Switch (C);
else
Ptr := Ptr + 1;
end if;
then
Set_Debug_Flag (C);
else
- raise Bad_Switch;
+ Bad_Switch (C);
end if;
end loop;
when 'D' =>
Ptr := Ptr + 1;
- Scan_Pos (Switch_Chars, Max, Ptr, Default_Sec_Stack_Size);
+ Scan_Pos
+ (Switch_Chars, Max, Ptr, Default_Sec_Stack_Size, C);
-- Processing for e switch
when 'i' =>
if Ptr = Max then
- raise Bad_Switch;
+ Bad_Switch (C);
end if;
Ptr := Ptr + 1;
Identifier_Character_Set := C;
Ptr := Ptr + 1;
else
- raise Bad_Switch;
+ Bad_Switch (C);
end if;
-- Processing for K switch
when 'm' =>
Ptr := Ptr + 1;
- Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors);
+ Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors, C);
-- Processing for n switch
Ptr := Ptr + 1;
if Output_File_Name_Present then
- raise Too_Many_Output_Files;
+ Osint.Fail ("duplicate -o switch");
else
Output_File_Name_Present := True;
when 'T' =>
Ptr := Ptr + 1;
Time_Slice_Set := True;
- Scan_Nat (Switch_Chars, Max, Ptr, Time_Slice_Value);
+ Scan_Nat (Switch_Chars, Max, Ptr, Time_Slice_Value, C);
Time_Slice_Value := Time_Slice_Value * 1_000;
-- Processing for v switch
Warning_Mode := Suppress;
when others =>
- raise Bad_Switch;
+ Bad_Switch (C);
end case;
Ptr := Ptr + 1;
exit;
elsif J = WC_Encoding_Method'Last then
- raise Bad_Switch;
+ Bad_Switch (C);
end if;
end loop;
when 'X' =>
Ptr := Ptr + 1;
- Scan_Pos (Switch_Chars, Max, Ptr, Default_Exit_Status);
+ Scan_Pos (Switch_Chars, Max, Ptr, Default_Exit_Status, C);
-- Processing for z switch
RTS_Src_Path_Name := Src_Path_Name;
RTS_Lib_Path_Name := Lib_Path_Name;
- -- We can exit as there can not be another switch
+ -- We can exit as there cannot be another switch
-- after --RTS
exit;
-- Anything else is an error (illegal switch character)
when others =>
- raise Bad_Switch;
+ Bad_Switch (C);
end case;
end loop;
-
- exception
- when Bad_Switch =>
- Osint.Fail ("invalid switch: ", (1 => C));
-
- when Bad_Switch_Value =>
- Osint.Fail ("numeric value out of range for switch: ", (1 => C));
-
- when Missing_Switch_Value =>
- Osint.Fail ("missing numeric value for switch: ", (1 => C));
-
- when Too_Many_Output_Files =>
- Osint.Fail ("duplicate -o switch");
end Scan_Binder_Switches;
end Switch.B;
-- --
-- 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- --
-- --
------------------------------------------------------------------------------
+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 --
-------------------------
(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;
--------------
(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;
-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2003 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- --
-- child packages (there is one such child package for each tool that
-- uses Switches to scan switches - Compiler/gnatbind/gnatmake/.
- Bad_Switch : exception;
- -- Exception raised if bad switch encountered
-
- Bad_Switch_Value : exception;
- -- Exception raised if bad switch value encountered
-
- Missing_Switch_Value : exception;
- -- Exception raised if no switch value encountered
-
- Too_Many_Output_Files : exception;
- -- Exception raised if the -o switch is encountered more than once
-
Switch_Max_Value : constant := 999_999;
-- Maximum value permitted in switches that take a value
(Switch_Chars : String;
Max : Integer;
Ptr : in out Integer;
- Result : out Nat);
+ Result : out Nat;
+ Switch : Character);
-- Scan natural integer parameter for switch. On entry, Ptr points
-- just past the switch character, on exit it points past the last
-- digit of the integer value.
(Switch_Chars : String;
Max : Integer;
Ptr : in out Integer;
- Result : out Pos);
+ Result : out Pos;
+ Switch : Character);
-- Scan positive integer parameter for switch. On entry, Ptr points
-- just past the switch character, on exit it points past the last
-- digit of the integer value.
+ procedure Bad_Switch (Switch : Character);
+ -- Fail with an appropriate message when a switch is not recognized
+
end Switch;