]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ada/libgnat/a-suteio__shared.adb
[Ada] Bump copyright year
[thirdparty/gcc.git] / gcc / ada / libgnat / a-suteio__shared.adb
CommitLineData
e487f350
AC
1------------------------------------------------------------------------------
2-- --
3-- GNAT RUN-TIME COMPONENTS --
4-- --
5-- A D A . S T R I N G S . U N B O U N D E D . T E X T _ I O --
6-- --
7-- B o d y --
8-- --
4b490c1e 9-- Copyright (C) 1997-2020, Free Software Foundation, Inc. --
e487f350
AC
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------------------------------------------------------------------------------
31
32with Ada.Text_IO; use Ada.Text_IO;
33
34package body Ada.Strings.Unbounded.Text_IO is
35
36 --------------
37 -- Get_Line --
38 --------------
39
40 function Get_Line return Unbounded_String is
41 Buffer : String (1 .. 1000);
42 Last : Natural;
43 Result : Unbounded_String;
44
45 begin
46 Get_Line (Buffer, Last);
47 Set_Unbounded_String (Result, Buffer (1 .. Last));
48
49 while Last = Buffer'Last loop
50 Get_Line (Buffer, Last);
51 Append (Result, Buffer (1 .. Last));
52 end loop;
53
54 return Result;
55 end Get_Line;
56
57 function Get_Line (File : Ada.Text_IO.File_Type) return Unbounded_String is
58 Buffer : String (1 .. 1000);
59 Last : Natural;
60 Result : Unbounded_String;
61
62 begin
63 Get_Line (File, Buffer, Last);
64 Set_Unbounded_String (Result, Buffer (1 .. Last));
65
66 while Last = Buffer'Last loop
67 Get_Line (File, Buffer, Last);
68 Append (Result, Buffer (1 .. Last));
69 end loop;
70
71 return Result;
72 end Get_Line;
73
74 procedure Get_Line (Item : out Unbounded_String) is
75 begin
76 Get_Line (Current_Input, Item);
77 end Get_Line;
78
79 procedure Get_Line
80 (File : Ada.Text_IO.File_Type;
81 Item : out Unbounded_String)
82 is
83 Buffer : String (1 .. 1000);
84 Last : Natural;
85
86 begin
87 Get_Line (File, Buffer, Last);
88 Set_Unbounded_String (Item, Buffer (1 .. Last));
89
90 while Last = Buffer'Last loop
91 Get_Line (File, Buffer, Last);
92 Append (Item, Buffer (1 .. Last));
93 end loop;
94 end Get_Line;
95
96 ---------
97 -- Put --
98 ---------
99
100 procedure Put (U : Unbounded_String) is
101 UR : constant Shared_String_Access := U.Reference;
102
103 begin
104 Put (UR.Data (1 .. UR.Last));
105 end Put;
106
107 procedure Put (File : File_Type; U : Unbounded_String) is
108 UR : constant Shared_String_Access := U.Reference;
109
110 begin
111 Put (File, UR.Data (1 .. UR.Last));
112 end Put;
113
114 --------------
115 -- Put_Line --
116 --------------
117
118 procedure Put_Line (U : Unbounded_String) is
119 UR : constant Shared_String_Access := U.Reference;
120
121 begin
122 Put_Line (UR.Data (1 .. UR.Last));
123 end Put_Line;
124
125 procedure Put_Line (File : File_Type; U : Unbounded_String) is
126 UR : constant Shared_String_Access := U.Reference;
127
128 begin
129 Put_Line (File, UR.Data (1 .. UR.Last));
130 end Put_Line;
131
132end Ada.Strings.Unbounded.Text_IO;