diff options
author | guerby <guerby@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-16 07:21:58 +0000 |
---|---|---|
committer | guerby <guerby@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-16 07:21:58 +0000 |
commit | 8eb0100871d840172febe46ef192cf1d5e50b50f (patch) | |
tree | d0971f5a0a3323f5bd3c88b8e6859cebfe814989 /gcc/ada/a-nudira.adb | |
parent | e380e64692e6118a841d2026ac8cc5a1b453865a (diff) | |
download | ppe42-gcc-8eb0100871d840172febe46ef192cf1d5e50b50f.tar.gz ppe42-gcc-8eb0100871d840172febe46ef192cf1d5e50b50f.zip |
2005-04-16 Laurent GUERBY <laurent@guerby.net>
PR ada/18847
* a-nudira.adb (Value): Check for valid string.
* a-nuflra.adb (Value): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98223 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-nudira.adb')
-rw-r--r-- | gcc/ada/a-nudira.adb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gcc/ada/a-nudira.adb b/gcc/ada/a-nudira.adb index f3ef91afdf6..1b91d890b9a 100644 --- a/gcc/ada/a-nudira.adb +++ b/gcc/ada/a-nudira.adb @@ -229,25 +229,34 @@ package body Ada.Numerics.Discrete_Random is ----------- function Value (Coded_State : String) return State is + Last : constant Natural := Coded_State'Last; Start : Positive := Coded_State'First; Stop : Positive := Coded_State'First; Outs : State; begin - while Coded_State (Stop) /= ',' loop + while Stop <= Last and then Coded_State (Stop) /= ',' loop Stop := Stop + 1; end loop; + if Stop > Last then + raise Constraint_Error; + end if; + Outs.X1 := Int'Value (Coded_State (Start .. Stop - 1)); Start := Stop + 1; loop Stop := Stop + 1; - exit when Coded_State (Stop) = ','; + exit when Stop > Last or else Coded_State (Stop) = ','; end loop; + if Stop > Last then + raise Constraint_Error; + end if; + Outs.X2 := Int'Value (Coded_State (Start .. Stop - 1)); - Outs.Q := Int'Value (Coded_State (Stop + 1 .. Coded_State'Last)); + Outs.Q := Int'Value (Coded_State (Stop + 1 .. Last)); Outs.P := Outs.Q * 2 + 1; Outs.FP := Flt (Outs.P); Outs.Scl := (RstL - RstF + 1.0) / (Flt (Outs.P) * Flt (Outs.Q)); |