summaryrefslogtreecommitdiff
path: root/gcc/ada/s-imgint.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-13 10:30:04 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-13 10:30:04 +0000
commit830a3f424d271773b4efa216a3006b108d48d04f (patch)
tree723bf7b7f6c79be9da7af8b7b5180dc8dc0f63f7 /gcc/ada/s-imgint.adb
parent587185fc9008481f0b72ec5dcf732420b1a92288 (diff)
downloadgcc-830a3f424d271773b4efa216a3006b108d48d04f.tar.gz
2007-12-06 Robert Dewar <dewar@adacore.com>
* s-imenne.adb, s-imenne.ads: New files. * s-imgboo.adb, s-imgboo.ads, s-imgcha.adb, s-imgcha.ads, s-imgdec.adb, s-imgdec.ads, s-imgenu.ads, s-imgint.adb, s-imgint.ads, s-imglld.adb, s-imglld.ads, s-imglli.adb, s-imglli.ads, s-imgllu.adb, s-imgllu.ads, s-imgrea.adb, s-imgrea.ads, s-imguns.adb, s-imguns.ads, s-imgwch.adb, s-imgwch.ads: New calling sequence for Image routines to avoid sec stack usage. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130852 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/s-imgint.adb')
-rw-r--r--gcc/ada/s-imgint.adb52
1 files changed, 40 insertions, 12 deletions
diff --git a/gcc/ada/s-imgint.adb b/gcc/ada/s-imgint.adb
index e57c58d41ba..74a5b736e48 100644
--- a/gcc/ada/s-imgint.adb
+++ b/gcc/ada/s-imgint.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2005 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- --
@@ -37,20 +37,46 @@ package body System.Img_Int is
-- Image_Integer --
-------------------
- function Image_Integer (V : Integer) return String is
- P : Natural;
- S : String (1 .. Integer'Width);
+ procedure Image_Integer
+ (V : Integer;
+ S : in out String;
+ P : out Natural)
+ is
+ pragma Assert (S'First = 1);
+
+ procedure Set_Digits (T : Integer);
+ -- Set digits of absolute value of T, which is zero or negative. We work
+ -- with the negative of the value so that the largest negative number is
+ -- not a special case.
+
+ ----------------
+ -- Set_Digits --
+ ----------------
+
+ procedure Set_Digits (T : Integer) is
+ begin
+ if T <= -10 then
+ Set_Digits (T / 10);
+ P := P + 1;
+ S (P) := Character'Val (48 - (T rem 10));
+ else
+ P := P + 1;
+ S (P) := Character'Val (48 - T);
+ end if;
+ end Set_Digits;
+
+ -- Start of processinng for Image_Integer
begin
+ P := 1;
+
if V >= 0 then
- P := 1;
S (P) := ' ';
+ Set_Digits (-V);
else
- P := 0;
+ S (P) := '-';
+ Set_Digits (V);
end if;
-
- Set_Image_Integer (V, S, P);
- return S (1 .. P);
end Image_Integer;
-----------------------
@@ -59,7 +85,7 @@ package body System.Img_Int is
procedure Set_Image_Integer
(V : Integer;
- S : out String;
+ S : in out String;
P : in out Natural)
is
procedure Set_Digits (T : Integer);
@@ -67,13 +93,16 @@ package body System.Img_Int is
-- with the negative of the value so that the largest negative number is
-- not a special case.
+ ----------------
+ -- Set_Digits --
+ ----------------
+
procedure Set_Digits (T : Integer) is
begin
if T <= -10 then
Set_Digits (T / 10);
P := P + 1;
S (P) := Character'Val (48 - (T rem 10));
-
else
P := P + 1;
S (P) := Character'Val (48 - T);
@@ -85,7 +114,6 @@ package body System.Img_Int is
begin
if V >= 0 then
Set_Digits (-V);
-
else
P := P + 1;
S (P) := '-';