a-tifiio.adb (Put, internal): For negative numbers...
authorVincent Celier <celier@adacore.com>
Wed, 6 Jun 2007 10:21:22 +0000 (12:21 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 6 Jun 2007 10:21:22 +0000 (12:21 +0200)
2007-04-20  Vincent Celier  <celier@adacore.com>

* a-tifiio.adb (Put, internal): For negative numbers, check that there
is room for at least one digit and the minus sign.
(Put.Put_Character): Never put a character outside of the range of
string To.

From-SVN: r125382

gcc/ada/a-tifiio.adb

index fe06c2c..92c24ea 100644 (file)
@@ -399,7 +399,7 @@ package body Ada.Text_IO.Fixed_IO is
       Last : Natural;
 
    begin
-      if Fore < 1 or else Fore > Field'Last then
+      if Fore - Boolean'Pos (Item < 0.0) < 1 or else Fore > Field'Last then
          raise Layout_Error;
       end if;
 
@@ -462,7 +462,13 @@ package body Ada.Text_IO.Fixed_IO is
       procedure Put_Character (C : Character) is
       begin
          Last := Last + 1;
-         To (Last) := C;
+
+         --  Never put a character outside of string To. Exception Layout_Error
+         --  will be raised later if Last is greater than To'Last.
+
+         if Last <= To'Last then
+            To (Last) := C;
+         end if;
       end Put_Character;
 
       ---------------