summaryrefslogtreecommitdiff
path: root/gcc/ada/switch.adb
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-27 12:45:13 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-27 12:45:13 +0000
commit268b9e9e95f56a59a8817b28ad59b53f40fc668d (patch)
tree5e9529982daf11d5b3ab800d4c58bc3fbee99d28 /gcc/ada/switch.adb
parente1910362719612f58bd1ea5050fa7a5175036abc (diff)
downloadgcc-268b9e9e95f56a59a8817b28ad59b53f40fc668d.tar.gz
2009-04-27 Basile Starynkevitch <basile@starynkevitch.net>
MERGED WITH TRUNK r146824:: * gcc/basilys.h: all GTY goes before the identifiers. * gcc/basilys.c: removed errors.h include. * gcc/run-basilys.h: ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@146839 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/switch.adb')
-rw-r--r--gcc/ada/switch.adb55
1 files changed, 38 insertions, 17 deletions
diff --git a/gcc/ada/switch.adb b/gcc/ada/switch.adb
index bf32e64ac5a..f318de7f191 100644
--- a/gcc/ada/switch.adb
+++ b/gcc/ada/switch.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2008, 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- --
@@ -34,12 +34,12 @@ package body Switch is
procedure Bad_Switch (Switch : Character) is
begin
- Osint.Fail ("invalid switch: ", (1 => Switch));
+ Osint.Fail ("invalid switch: " & Switch);
end Bad_Switch;
procedure Bad_Switch (Switch : String) is
begin
- Osint.Fail ("invalid switch: ", Switch);
+ Osint.Fail ("invalid switch: " & Switch);
end Bad_Switch;
------------------------------
@@ -148,6 +148,24 @@ package body Switch is
and then Switch_Chars (Switch_Chars'First) = '-';
end Is_Switch;
+ -----------------
+ -- Nat_Present --
+ -----------------
+
+ function Nat_Present
+ (Switch_Chars : String;
+ Max : Integer;
+ Ptr : Integer) return Boolean
+ is
+ begin
+ return (Ptr <= Max
+ and then Switch_Chars (Ptr) in '0' .. '9')
+ or else
+ (Ptr < Max
+ and then Switch_Chars (Ptr) = '='
+ and then Switch_Chars (Ptr + 1) in '0' .. '9');
+ end Nat_Present;
+
--------------
-- Scan_Nat --
--------------
@@ -162,21 +180,24 @@ package body Switch is
begin
Result := 0;
- if Ptr > Max or else Switch_Chars (Ptr) not in '0' .. '9' then
- 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 not Nat_Present (Switch_Chars, Max, Ptr) then
+ Osint.Fail ("missing numeric value for switch: " & Switch);
+ end if;
- if Result > Switch_Max_Value then
- Osint.Fail
- ("numeric value out of range for switch: ", (1 => Switch));
- end if;
- end loop;
+ if Switch_Chars (Ptr) = '=' then
+ Ptr := Ptr + 1;
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
+ Osint.Fail ("numeric value out of range for switch: " & Switch);
+ end if;
+ end loop;
end Scan_Nat;
--------------
@@ -196,7 +217,7 @@ package body Switch is
Scan_Nat (Switch_Chars, Max, Ptr, Temp, Switch);
if Temp = 0 then
- Osint.Fail ("numeric value out of range for switch: ", (1 => Switch));
+ Osint.Fail ("numeric value out of range for switch: " & Switch);
end if;
Result := Temp;