1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
9 -- Copyright (C) 1995-2010, AdaCore --
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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 package body GNAT
.IO
is
34 Current_Out
: File_Type
:= Stdout
;
35 pragma Atomic
(Current_Out
);
36 -- Current output file (modified by Set_Output)
42 procedure Get
(X
: out Integer) is
43 function Get_Int
return Integer;
44 pragma Import
(C
, Get_Int
, "get_int");
49 procedure Get
(C
: out Character) is
50 function Get_Char
return Character;
51 pragma Import
(C
, Get_Char
, "get_char");
60 procedure Get_Line
(Item
: out String; Last
: out Natural) is
64 for Nstore
in Item
'Range loop
83 procedure New_Line
(File
: File_Type
; Spacing
: Positive := 1) is
85 for J
in 1 .. Spacing
loop
90 procedure New_Line
(Spacing
: Positive := 1) is
92 New_Line
(Current_Out
, Spacing
);
99 procedure Put
(X
: Integer) is
101 Put
(Current_Out
, X
);
104 procedure Put
(File
: File_Type
; X
: Integer) is
105 procedure Put_Int
(X
: Integer);
106 pragma Import
(C
, Put_Int
, "put_int");
108 procedure Put_Int_Stderr
(X
: Integer);
109 pragma Import
(C
, Put_Int_Stderr
, "put_int_stderr");
113 when Stdout
=> Put_Int
(X
);
114 when Stderr
=> Put_Int_Stderr
(X
);
118 procedure Put
(C
: Character) is
120 Put
(Current_Out
, C
);
123 procedure Put
(File
: File_Type
; C
: Character) is
124 procedure Put_Char
(C
: Character);
125 pragma Import
(C
, Put_Char
, "put_char");
127 procedure Put_Char_Stderr
(C
: Character);
128 pragma Import
(C
, Put_Char_Stderr
, "put_char_stderr");
132 when Stdout
=> Put_Char
(C
);
133 when Stderr
=> Put_Char_Stderr
(C
);
137 procedure Put
(S
: String) is
139 Put
(Current_Out
, S
);
142 procedure Put
(File
: File_Type
; S
: String) is
144 for J
in S
'Range loop
153 procedure Put_Line
(S
: String) is
155 Put_Line
(Current_Out
, S
);
158 procedure Put_Line
(File
: File_Type
; S
: String) is
168 procedure Set_Output
(File
: File_Type
) is
173 ---------------------
174 -- Standard_Output --
175 ---------------------
177 function Standard_Output
return File_Type
is
186 function Standard_Error
return File_Type
is