aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert Bosch <bosch@adacore.com>2007-12-13 11:21:51 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2007-12-13 11:21:51 +0100
commitf8755021cc57dcd4514ef53a8d8cb5fe4059d1c8 (patch)
tree84263fa12834e30c157b0b03fe77510c1ff3ce65
parent470cd9e99870bde530a3f6087efdc00d9b3f8f48 (diff)
downloadgcc-f8755021cc57dcd4514ef53a8d8cb5fe4059d1c8.zip
gcc-f8755021cc57dcd4514ef53a8d8cb5fe4059d1c8.tar.gz
gcc-f8755021cc57dcd4514ef53a8d8cb5fe4059d1c8.tar.bz2
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
-rw-r--r--gcc/ada/a-tifiio.adb18
1 files changed, 14 insertions, 4 deletions
diff --git a/gcc/ada/a-tifiio.adb b/gcc/ada/a-tifiio.adb
index 92c24ea..ae1a60d 100644
--- a/gcc/ada/a-tifiio.adb
+++ b/gcc/ada/a-tifiio.adb
@@ -6,7 +6,7 @@
-- --
-- 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 --
-- 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
X : constant Int64 := Int64'Integer_Value (Item);
A : constant Field := Field'Max (Aft, 1);
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;
E : constant Integer := Boolean'Pos (not Exact)
@@ -538,12 +538,22 @@ package body Ada.Text_IO.Fixed_IO is
return;
end if;
- Pos := Scale;
-
if X not in -9 .. 9 then
Put_Int64 (X / 10, Scale + 1);
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));
end Put_Int64;