Commit f8755021 by Geert Bosch Committed by Arnaud Charlet

2007-12-06 Geert Bosch <bosch@adacore.com>

	* a-tifiio.adb
	(Put_Int64): Use Put_Digit to advance Pos. This fixes a case where
	the second or later Scaled_Divide would omit leading zeroes,
	resulting in too few digits produced and a Layout_Error as result.
	(Put): Initialize Pos.

From-SVN: r130819
parent 470cd9e9
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -423,7 +423,7 @@ package body Ada.Text_IO.Fixed_IO is ...@@ -423,7 +423,7 @@ package body Ada.Text_IO.Fixed_IO is
X : constant Int64 := Int64'Integer_Value (Item); X : constant Int64 := Int64'Integer_Value (Item);
A : constant Field := Field'Max (Aft, 1); A : constant Field := Field'Max (Aft, 1);
Neg : constant Boolean := (Item < 0.0); Neg : constant Boolean := (Item < 0.0);
Pos : Integer; -- Next digit X has value X * 10.0**Pos; Pos : Integer := 0; -- Next digit X has value X * 10.0**Pos;
Y, Z : Int64; Y, Z : Int64;
E : constant Integer := Boolean'Pos (not Exact) E : constant Integer := Boolean'Pos (not Exact)
...@@ -538,12 +538,22 @@ package body Ada.Text_IO.Fixed_IO is ...@@ -538,12 +538,22 @@ package body Ada.Text_IO.Fixed_IO is
return; return;
end if; end if;
Pos := Scale;
if X not in -9 .. 9 then if X not in -9 .. 9 then
Put_Int64 (X / 10, Scale + 1); Put_Int64 (X / 10, Scale + 1);
end if; end if;
-- Use Put_Digit to advance Pos. This fixes a case where the second
-- or later Scaled_Divide would omit leading zeroes, resulting in
-- too few digits produced and a Layout_Error as result.
while Pos > Scale loop
Put_Digit (0);
end loop;
-- If Pos is less than Scale now, reset to equal Scale
Pos := Scale;
Put_Digit (abs (X rem 10)); Put_Digit (abs (X rem 10));
end Put_Int64; end Put_Int64;
......
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