diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-04-08 06:48:07 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-04-08 06:48:07 +0000 |
commit | f2c1640a0491cd5b734509144ec9ba1bcc6a3e52 (patch) | |
tree | e7c3056dbb2b784441ba566cfe999bb88cb521cc | |
parent | cc60bd167ed27492916b1cc0a316ea41a89a60d1 (diff) | |
download | ppe42-gcc-f2c1640a0491cd5b734509144ec9ba1bcc6a3e52.tar.gz ppe42-gcc-f2c1640a0491cd5b734509144ec9ba1bcc6a3e52.zip |
2008-04-08 Robert Dewar <dewar@adacore.com>
* a-ztdeau.adb, a-tideau.adb, a-wtdeau.adb (Puts_Dec): Fix error in
computing Fore when Exp > 0
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134021 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ada/a-tideau.adb | 18 | ||||
-rw-r--r-- | gcc/ada/a-wtdeau.adb | 18 | ||||
-rw-r--r-- | gcc/ada/a-ztdeau.adb | 18 |
3 files changed, 39 insertions, 15 deletions
diff --git a/gcc/ada/a-tideau.adb b/gcc/ada/a-tideau.adb index 06a41ee791d..b9e39dcb586 100644 --- a/gcc/ada/a-tideau.adb +++ b/gcc/ada/a-tideau.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2008, 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- -- @@ -201,16 +201,24 @@ package body Ada.Text_IO.Decimal_Aux is Ptr : Natural := 0; begin - if Exp = 0 then - Fore := To'Length - 1 - Aft; - else - Fore := To'Length - 2 - Aft - Exp; + -- Compute Fore, allowing for Aft digits and the decimal dot + + Fore := To'Length - Field'Max (1, Aft) - 1; + + -- Allow for Exp and two more for E+ or E- if exponent present + + if Exp /= 0 then + Fore := Fore - 2 - Exp; end if; + -- Make sure we have enough room + if Fore < 1 then raise Layout_Error; end if; + -- Do the conversion and check length of result + Set_Image_Decimal (Item, Buf, Ptr, Scale, Fore, Aft, Exp); if Ptr > To'Length then diff --git a/gcc/ada/a-wtdeau.adb b/gcc/ada/a-wtdeau.adb index fd6cc2eea42..1a9752fb8c2 100644 --- a/gcc/ada/a-wtdeau.adb +++ b/gcc/ada/a-wtdeau.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2008, 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- -- @@ -203,16 +203,24 @@ package body Ada.Wide_Text_IO.Decimal_Aux is Ptr : Natural := 0; begin - if Exp = 0 then - Fore := To'Length - 1 - Aft; - else - Fore := To'Length - 2 - Aft - Exp; + -- Compute Fore, allowing for Aft digits and the decimal dot + + Fore := To'Length - Field'Max (1, Aft) - 1; + + -- Allow for Exp and two more for E+ or E- if exponent present + + if Exp /= 0 then + Fore := Fore - 2 - Exp; end if; + -- Make sure we have enough room + if Fore < 1 then raise Layout_Error; end if; + -- Do the conversion and check length of result + Set_Image_Decimal (Item, Buf, Ptr, Scale, Fore, Aft, Exp); if Ptr > To'Length then diff --git a/gcc/ada/a-ztdeau.adb b/gcc/ada/a-ztdeau.adb index d36d34fb8bd..e7f13ecc57b 100644 --- a/gcc/ada/a-ztdeau.adb +++ b/gcc/ada/a-ztdeau.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2008, 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- -- @@ -203,16 +203,24 @@ package body Ada.Wide_Wide_Text_IO.Decimal_Aux is Ptr : Natural := 0; begin - if Exp = 0 then - Fore := To'Length - 1 - Aft; - else - Fore := To'Length - 2 - Aft - Exp; + -- Compute Fore, allowing for Aft digits and the decimal dot + + Fore := To'Length - Field'Max (1, Aft) - 1; + + -- Allow for Exp and two more for E+ or E- if exponent present + + if Exp /= 0 then + Fore := Fore - 2 - Exp; end if; + -- Make sure we have enough room + if Fore < 1 then raise Layout_Error; end if; + -- Do the conversion and check length of result + Set_Image_Decimal (Item, Buf, Ptr, Scale, Fore, Aft, Exp); if Ptr > To'Length then |