OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-swuwti.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUNTIME COMPONENTS                          --
4 --                                                                          --
5 --                  ADA.STRINGS.WIDE_UNBOUNDED.WIDE_TEXT_IO                 --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --                                                                          --
10 --          Copyright (C) 1997-1999 Free Software Foundation, Inc.          --
11 --                                                                          --
12 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
13 -- terms of the  GNU General Public License as published  by the Free Soft- --
14 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
15 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
18 -- for  more details.  You should have  received  a copy of the GNU General --
19 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
20 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
21 -- MA 02111-1307, USA.                                                      --
22 --                                                                          --
23 -- As a special exception,  if other files  instantiate  generics from this --
24 -- unit, or you link  this unit with other files  to produce an executable, --
25 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
26 -- covered  by the  GNU  General  Public  License.  This exception does not --
27 -- however invalidate  any other reasons why  the executable file  might be --
28 -- covered by the  GNU Public License.                                      --
29 --                                                                          --
30 -- GNAT was originally developed  by the GNAT team at  New York University. --
31 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
32 --                                                                          --
33 ------------------------------------------------------------------------------
34
35 with Ada.Wide_Text_IO; use Ada.Wide_Text_IO;
36
37 package body Ada.Strings.Wide_Unbounded.Wide_Text_IO is
38
39    --------------
40    -- Get_Line --
41    --------------
42
43    function Get_Line return Unbounded_Wide_String is
44       Buffer : Wide_String (1 .. 1000);
45       Last   : Natural;
46       Str1   : Wide_String_Access;
47       Str2   : Wide_String_Access;
48
49    begin
50       Get_Line (Buffer, Last);
51       Str1 := new Wide_String'(Buffer (1 .. Last));
52
53       while Last = Buffer'Last loop
54          Get_Line (Buffer, Last);
55          Str2 := new Wide_String'(Str1.all & Buffer (1 .. Last));
56          Free (Str1);
57          Str1 := Str2;
58       end loop;
59
60       return To_Unbounded_Wide_String (Str1.all);
61    end Get_Line;
62
63    function Get_Line
64      (File : Ada.Wide_Text_IO.File_Type)
65       return Unbounded_Wide_String
66    is
67       Buffer : Wide_String (1 .. 1000);
68       Last   : Natural;
69       Str1   : Wide_String_Access;
70       Str2   : Wide_String_Access;
71
72    begin
73       Get_Line (File, Buffer, Last);
74       Str1 := new Wide_String'(Buffer (1 .. Last));
75
76       while Last = Buffer'Last loop
77          Get_Line (File, Buffer, Last);
78          Str2 := new Wide_String'(Str1.all & Buffer (1 .. Last));
79          Free (Str1);
80          Str1 := Str2;
81       end loop;
82
83       return To_Unbounded_Wide_String (Str1.all);
84    end Get_Line;
85
86    ---------
87    -- Put --
88    ---------
89
90    procedure Put (U : Unbounded_Wide_String) is
91    begin
92       Put (To_Wide_String (U));
93    end Put;
94
95    procedure Put (File : File_Type; U : Unbounded_Wide_String) is
96    begin
97       Put (File, To_Wide_String (U));
98    end Put;
99
100    --------------
101    -- Put_Line --
102    --------------
103
104    procedure Put_Line (U : Unbounded_Wide_String) is
105    begin
106       Put_Line (To_Wide_String (U));
107    end Put_Line;
108
109    procedure Put_Line (File : File_Type; U : Unbounded_Wide_String) is
110    begin
111       Put_Line (File, To_Wide_String (U));
112    end Put_Line;
113
114 end Ada.Strings.Wide_Unbounded.Wide_Text_IO;