* jump.c: Remove prototypes for delete_computation and
[official-gcc.git] / gcc / ada / s-trafor-default.adb
blob4451f432eba936fa7d1717bb7847cd95eaabddda
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- S Y S T E M . T R A C E S . F O R M A T --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2001-2006 Free Software Foundation, Inc. --
10 -- --
11 -- GNARL 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 2, or (at your option) any later ver- --
14 -- sion. GNARL 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNARL; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 with System.Parameters;
36 package body System.Traces.Format is
38 procedure Send_Trace (Id : Trace_T; Info : String) is separate;
40 ------------------
41 -- Format_Trace --
42 ------------------
44 function Format_Trace (Source : String) return String_Trace is
45 Length : Integer := Source'Length;
46 Result : String_Trace := (others => ' ');
48 begin
49 -- If run-time tracing active, then fill the string
51 if Parameters.Runtime_Traces then
52 if Max_Size - Length > 0 then
53 Result (1 .. Length) := Source (1 .. Length);
54 Result (Length + 1 .. Max_Size) := (others => ' ');
55 Result (Length + 1) := ASCII.NUL;
56 else
57 Result (1 .. Max_Size - 1) := Source (1 .. Max_Size - 1);
58 Result (Max_Size) := ASCII.NUL;
59 end if;
60 end if;
62 return Result;
63 end Format_Trace;
65 ------------
66 -- Append --
67 ------------
69 function Append
70 (Source : String_Trace;
71 Annex : String)
72 return String_Trace
74 Result : String_Trace := (others => ' ');
75 Source_Length : Integer := 1;
76 Annex_Length : Integer := Annex'Length;
78 begin
79 if Parameters.Runtime_Traces then
81 -- First we determine the size used, without the spaces at the
82 -- end, if a String_Trace is present. Look at
83 -- System.Traces.Tasking for examples.
85 while Source (Source_Length) /= ASCII.NUL loop
86 Source_Length := Source_Length + 1;
87 end loop;
89 -- Then we fill the string.
91 if Source_Length - 1 + Annex_Length <= Max_Size then
92 Result (1 .. Source_Length - 1) :=
93 Source (1 .. Source_Length - 1);
95 Result (Source_Length .. Source_Length - 1 + Annex_Length) :=
96 Annex (1 .. Annex_Length);
98 Result (Source_Length + Annex_Length) := ASCII.NUL;
100 Result (Source_Length + Annex_Length + 1 .. Max_Size) :=
101 (others => ' ');
102 else
103 Result (1 .. Source_Length - 1) := Source (1 .. Source_Length - 1);
104 Result (Source_Length .. Max_Size - 1) :=
105 Annex (1 .. Max_Size - Source_Length);
106 Result (Max_Size) := ASCII.NUL;
107 end if;
108 end if;
110 return Result;
111 end Append;
113 end System.Traces.Format;