PR tree-optimization/43833
[official-gcc/alias-decl.git] / gcc / ada / s-imglli.adb
blob05154fadc9186a864b0cff08252b0f03adac22de
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- S Y S T E M . I M G _ L L I --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
32 package body System.Img_LLI is
34 -----------------------------
35 -- Image_Long_Long_Integer --
36 -----------------------------
38 procedure Image_Long_Long_Integer
39 (V : Long_Long_Integer;
40 S : in out String;
41 P : out Natural)
43 pragma Assert (S'First = 1);
45 begin
46 if V >= 0 then
47 S (1) := ' ';
48 P := 1;
49 else
50 P := 0;
51 end if;
53 Set_Image_Long_Long_Integer (V, S, P);
54 end Image_Long_Long_Integer;
56 ------------------------------
57 -- Set_Image_Long_Long_Integer --
58 -----------------------------
60 procedure Set_Image_Long_Long_Integer
61 (V : Long_Long_Integer;
62 S : in out String;
63 P : in out Natural)
65 procedure Set_Digits (T : Long_Long_Integer);
66 -- Set digits of absolute value of T, which is zero or negative. We work
67 -- with the negative of the value so that the largest negative number is
68 -- not a special case.
70 ----------------
71 -- Set_Digits --
72 ----------------
74 procedure Set_Digits (T : Long_Long_Integer) is
75 begin
76 if T <= -10 then
77 Set_Digits (T / 10);
78 P := P + 1;
79 S (P) := Character'Val (48 - (T rem 10));
80 else
81 P := P + 1;
82 S (P) := Character'Val (48 - T);
83 end if;
84 end Set_Digits;
86 -- Start of processing for Set_Image_Long_Long_Integer
88 begin
89 if V >= 0 then
90 Set_Digits (-V);
91 else
92 P := P + 1;
93 S (P) := '-';
94 Set_Digits (V);
95 end if;
96 end Set_Image_Long_Long_Integer;
98 end System.Img_LLI;