Commit 159921c0 by Laurent GUERBY Committed by Laurent Guerby

re PR ada/18847 ([4.0 only] ACATS cxa5012 SEGV on on x86_64)

2005-04-16  Laurent GUERBY  <laurent@guerby.net>

        PR ada/18847
        * a-nudira.adb (Value): Check for valid string.
        * a-nuflra.adb (Value): Likewise.

From-SVN: r98223
parent 83eba878
2005-04-16 Laurent GUERBY <laurent@guerby.net>
PR ada/18847
* a-nudira.adb (Value): Check for valid string.
* a-nuflra.adb (Value): Likewise.
2005-04-11 Richard Sandiford <rsandifo@redhat.com>
* lang.opt: Refer to the GCC internals documentation instead of c.opt.
......
......@@ -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));
......
......@@ -256,33 +256,46 @@ package body Ada.Numerics.Float_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));
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.P := 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.X := Euclid (Outs.P, Outs.Q);
Outs.Scl := 1.0 / (Flt (Outs.P) * Flt (Outs.Q));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment