annotate gcc/ada/libgnat/g-byorma.ads @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- G N A T . B Y T E _ O R D E R _ M A R K --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 2006-2019, AdaCore --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This package provides a procedure for reading and interpreting the BOM
kono
parents:
diff changeset
33 -- (byte order mark) used to publish the encoding method for a string (for
kono
parents:
diff changeset
34 -- example, a UTF-8 encoded file in windows will start with the appropriate
kono
parents:
diff changeset
35 -- BOM sequence to signal UTF-8 encoding).
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 -- There are two cases
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 -- Case 1. UTF encodings for Unicode files
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 -- Here the convention is to have the first character of the file be a
kono
parents:
diff changeset
42 -- non-breaking zero width space character (16#0000_FEFF#). For the UTF
kono
parents:
diff changeset
43 -- encodings, the representation of this character can be used to uniquely
kono
parents:
diff changeset
44 -- determine the encoding. Furthermore, the possibility of any confusion
kono
parents:
diff changeset
45 -- with unencoded files is minimal, since for example the UTF-8 encoding
kono
parents:
diff changeset
46 -- of this character looks like the sequence:
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 -- LC_I_Diaeresis
kono
parents:
diff changeset
49 -- Right_Angle_Quotation
kono
parents:
diff changeset
50 -- Fraction_One_Half
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 -- which is so unlikely to occur legitimately in normal use that it can
kono
parents:
diff changeset
53 -- safely be ignored in most cases (for example, no legitimate Ada source
kono
parents:
diff changeset
54 -- file could start with this sequence of characters).
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 -- Case 2. Specialized XML encodings
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 -- The XML standard defines a number of other possible encodings and also
kono
parents:
diff changeset
59 -- defines standardized sequences for marking these encodings. This package
kono
parents:
diff changeset
60 -- can also optionally handle these XML defined BOM sequences. These XML
kono
parents:
diff changeset
61 -- cases depend on the first character of the XML file being < so that the
kono
parents:
diff changeset
62 -- encoding of this character can be recognized.
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 pragma Compiler_Unit_Warning;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 package GNAT.Byte_Order_Mark is
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 type BOM_Kind is
kono
parents:
diff changeset
69 (UTF8_All, -- UTF8-encoding
kono
parents:
diff changeset
70 UTF16_LE, -- UTF16 little-endian encoding
kono
parents:
diff changeset
71 UTF16_BE, -- UTF16 big-endian encoding
kono
parents:
diff changeset
72 UTF32_LE, -- UTF32 little-endian encoding
kono
parents:
diff changeset
73 UTF32_BE, -- UTF32 big-endian encoding
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 -- The following cases are for XML only
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 UCS4_BE, -- UCS-4, big endian machine (1234 order)
kono
parents:
diff changeset
78 UCS4_LE, -- UCS-4, little endian machine (4321 order)
kono
parents:
diff changeset
79 UCS4_2143, -- UCS-4, unusual byte order (2143 order)
kono
parents:
diff changeset
80 UCS4_3412, -- UCS-4, unusual byte order (3412 order)
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 -- Value returned if no BOM recognized
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 Unknown); -- Unknown, assumed to be ASCII compatible
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 procedure Read_BOM
kono
parents:
diff changeset
87 (Str : String;
kono
parents:
diff changeset
88 Len : out Natural;
kono
parents:
diff changeset
89 BOM : out BOM_Kind;
kono
parents:
diff changeset
90 XML_Support : Boolean := False);
kono
parents:
diff changeset
91 -- This is the routine to read the BOM from the start of the given string
kono
parents:
diff changeset
92 -- Str. On return BOM is set to the appropriate BOM_Kind and Len is set to
kono
parents:
diff changeset
93 -- its length. The caller will typically skip the first Len characters in
kono
parents:
diff changeset
94 -- the string to ignore the BOM sequence. The special XML possibilities are
kono
parents:
diff changeset
95 -- recognized only if flag XML_Support is set to True. Note that for the
kono
parents:
diff changeset
96 -- XML cases, Len is always set to zero on return (not to the length of the
kono
parents:
diff changeset
97 -- relevant sequence) since in the XML cases, the sequence recognized is
kono
parents:
diff changeset
98 -- for the first real character in the file (<) which is not to be skipped.
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 end GNAT.Byte_Order_Mark;