summaryrefslogtreecommitdiff
path: root/gcc/ada/s-vallli.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-15 09:46:41 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-15 09:46:41 +0000
commit9ce02b233ca3dcfa6be1a342fb0747113b3c7693 (patch)
treecc8ecc6bf75735f2544635ed3a30db37cf84caf2 /gcc/ada/s-vallli.adb
parenta6eae12a1d4f6ac29bab2e0eeb21f6a937a4e7f2 (diff)
downloadgcc-9ce02b233ca3dcfa6be1a342fb0747113b3c7693.tar.gz
2006-02-13 Bob Duff <duff@adacore.com>
* s-valint.adb (Scan_Integer): Call Scan_Raw_Unsigned instead of Scan_Unsigned, so we do not scan leading blanks and sign twice. Integer'Value("- 5") and Integer'Value("-+5") now correctly raise Constraint_Error. * s-vallli.adb (Scan_Long_Long_Integer): Call Scan_Raw_Long_Long_Unsigned instead of Scan_Long_Long_Unsigned, so we do not scan leading blanks and sign twice. Integer'Value("- 5") and Integer'Value("-+5") now correctly raise Constraint_Error. * s-valllu.ads, s-valllu.adb (Scan_Raw_Long_Long_Unsigned, Scan_Long_Long_Unsigned): Split out most of the processing from Scan_Long_Long_Unsigned out into Scan_Raw_Long_Long_Unsigned, so that Val_LLI can call the Raw_ version. This prevents scanning leading blanks and sign twice. Also fixed a bug: Modular'Value("-0") should raise Constraint_Error See RM-3.5(44). * s-valuns.ads, s-valuns.adb (Scan_Raw_Unsigned, Scan_Unsigned): Split out most of the processing from Scan_Unsigned out into Scan_Raw_Unsigned, so that Val_LLI can call the Raw_ version. This prevents scanning leading blanks and sign twice. * s-valuti.ads, s-valuti.adb (Scan_Plus_Sign): Add Scan_Plus_Sign, for use with Modular'Value attribute. (Scan_Plus_Sign): Add Scan_Plus_Sign, for use with Modular'Value attribute. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111101 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/s-vallli.adb')
-rw-r--r--gcc/ada/s-vallli.adb19
1 files changed, 13 insertions, 6 deletions
diff --git a/gcc/ada/s-vallli.adb b/gcc/ada/s-vallli.adb
index ad54db94607..850bdf1b7a9 100644
--- a/gcc/ada/s-vallli.adb
+++ b/gcc/ada/s-vallli.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2006, 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- --
@@ -37,9 +37,9 @@ with System.Val_Util; use System.Val_Util;
package body System.Val_LLI is
- ---------------------------
- -- Scn_Long_Long_Integer --
- ---------------------------
+ ----------------------------
+ -- Scan_Long_Long_Integer --
+ ----------------------------
function Scan_Long_Long_Integer
(Str : String;
@@ -57,13 +57,20 @@ package body System.Val_LLI is
begin
Scan_Sign (Str, Ptr, Max, Minus, Start);
- Uval := Scan_Long_Long_Unsigned (Str, Ptr, Max);
+
+ if Str (Ptr.all) not in '0' .. '9' then
+ Ptr.all := Start;
+ raise Constraint_Error;
+ end if;
+
+ Uval := Scan_Raw_Long_Long_Unsigned (Str, Ptr, Max);
-- Deal with overflow cases, and also with maximum negative number
if Uval > Long_Long_Unsigned (Long_Long_Integer'Last) then
if Minus
- and then Uval = Long_Long_Unsigned (-(Long_Long_Integer'First)) then
+ and then Uval = Long_Long_Unsigned (-(Long_Long_Integer'First))
+ then
return Long_Long_Integer'First;
else
raise Constraint_Error;