1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . W I D E _ W I D E _ T E X T _ I O . G E N E R I C _ A U X --
9 -- Copyright (C) 1992-2023, Free Software Foundation, Inc. --
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 -- This package contains a set of auxiliary routines used by Wide_Wide_Text_IO
33 -- generic children, including for reading and writing numeric strings.
35 -- Note: although this is the Wide version of the package, the interface here
36 -- is still in terms of Character and String rather than Wide_Wide_Character
37 -- and Wide_Wide_String, since all numeric strings are composed entirely of
38 -- characters in the range of type Standard.Character, and the basic
39 -- conversion routines work with Character rather than Wide_Wide_Character.
41 package Ada
.Wide_Wide_Text_IO
.Generic_Aux
is
43 -- Note: for all the Load routines, File indicates the file to be read,
44 -- Buf is the string into which data is stored, Ptr is the index of the
45 -- last character stored so far, and is updated if additional characters
46 -- are stored. Data_Error is raised if the input overflows Buf. The only
47 -- Load routines that do a file status check are Load_Skip and Load_Width
48 -- so one of these two routines must be called first.
50 procedure Check_End_Of_Field
55 -- This routine is used after doing a get operations on a numeric value.
56 -- Buf is the string being scanned, and Stop is the last character of
57 -- the field being scanned. Ptr is as set by the call to the scan routine
58 -- that scanned out the numeric value, i.e. it points one past the last
59 -- character scanned, and Width is the width parameter from the Get call.
61 -- There are two cases, if Width is non-zero, then a check is made that
62 -- the remainder of the field is all blanks. If Width is zero, then it
63 -- means that the scan routine scanned out only part of the field. We
64 -- have already scanned out the field that the ACVC tests seem to expect
65 -- us to read (even if it does not follow the syntax of the type being
66 -- scanned, e.g. allowing negative exponents in integers, and underscores
67 -- at the end of the string), so we just raise Data_Error.
69 procedure Check_On_One_Line
(File
: File_Type
; Length
: Integer);
70 -- Check to see if item of length Integer characters can fit on
71 -- current line. Call New_Line if not, first checking that the
72 -- line length can accommodate Length characters, raise Layout_Error
73 -- if item is too large for a single line.
75 function Is_Blank
(C
: Character) return Boolean;
76 -- Determines if C is a blank (space or tab)
82 Ptr
: in out Integer);
83 -- Loads exactly Width characters, unless a line mark is encountered first
85 procedure Load_Skip
(File
: File_Type
);
86 -- Skips leading blanks and line and page marks, if the end of file is
87 -- read without finding a non-blank character, then End_Error is raised.
88 -- Note: a blank is defined as a space or horizontal tab (RM A.10.6(5)).
95 Loaded
: out Boolean);
96 -- If next character is Char, loads it, otherwise no characters are loaded
97 -- Loaded is set to indicate whether or not the character was found.
102 Ptr
: in out Integer;
104 -- Same as above, but no indication if character is loaded
109 Ptr
: in out Integer;
112 Loaded
: out Boolean);
113 -- If next character is Char1 or Char2, loads it, otherwise no characters
114 -- are loaded. Loaded is set to indicate whether or not one of the two
115 -- characters was found.
120 Ptr
: in out Integer;
123 -- Same as above, but no indication if character is loaded
125 procedure Load_Digits
128 Ptr
: in out Integer;
129 Loaded
: out Boolean);
130 -- Loads a sequence of zero or more decimal digits. Loaded is set if
131 -- at least one digit is loaded.
133 procedure Load_Digits
136 Ptr
: in out Integer);
137 -- Same as above, but no indication if character is loaded
139 procedure Load_Extended_Digits
142 Ptr
: in out Integer;
143 Loaded
: out Boolean);
144 -- Like Load_Digits, but also allows extended digits a-f and A-F
146 procedure Load_Extended_Digits
149 Ptr
: in out Integer);
150 -- Same as above, but no indication if character is loaded
152 procedure Load_Integer
155 Ptr
: in out Natural);
156 -- Loads a possibly signed integer literal value
161 Ptr
: in out Natural);
162 -- Loads a possibly signed real literal value
164 procedure Put_Item
(File
: File_Type
; Str
: String);
165 -- This routine is like Wide_Wide_Text_IO.Put, except that it checks for
166 -- overflow of bounded lines, as described in (RM A.10.6(8)). It is used
167 -- for all output of numeric values and of enumeration values. Note that
168 -- the buffer is of type String. Put_Item deals with converting this to
169 -- Wide_Wide_Characters as required.
175 Ptr
: in out Integer);
176 -- Store a single character in buffer, checking for overflow and
177 -- adjusting the column number in the file to reflect the fact
178 -- that a character has been acquired from the input stream.
179 -- The pos value of the character to store is in ch on entry.
181 procedure String_Skip
(Str
: String; Ptr
: out Integer);
182 -- Used in the Get from string procedures to skip leading blanks in the
183 -- string. Ptr is set to the index of the first non-blank. If the string
184 -- is all blanks, then the exception End_Error is raised, Note that blank
185 -- is defined as a space or horizontal tab (RM A.10.6(5)).
187 procedure Ungetc
(ch
: Integer; File
: File_Type
);
188 -- Pushes back character into stream, using ungetc. The caller has
189 -- checked that the file is in read status. Device_Error is raised
190 -- if the character cannot be pushed back. An attempt to push back
191 -- an end of file (EOF) is ignored.
194 pragma Inline
(Is_Blank
);
196 end Ada
.Wide_Wide_Text_IO
.Generic_Aux
;