annotate gcc/ada/krunch.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 -- K R U N C H --
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) 1992-2019, Free Software Foundation, Inc. --
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 procedure implements file name crunching
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 -- First, the name is divided into segments separated by minus signs and
kono
parents:
diff changeset
35 -- underscores, then all minus signs and underscores are eliminated. If
kono
parents:
diff changeset
36 -- this leaves the name short enough, we are done.
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 -- If not, then the longest segment is located (left-most if there are
kono
parents:
diff changeset
39 -- two of equal length), and shortened by dropping its last character.
kono
parents:
diff changeset
40 -- This is repeated until the name is short enough.
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 -- As an example, consider the krunch of our-strings-wide_fixed.adb
kono
parents:
diff changeset
43 -- to fit the name into 8 characters as required by DOS:
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 -- our-strings-wide_fixed 22
kono
parents:
diff changeset
46 -- our strings wide fixed 19
kono
parents:
diff changeset
47 -- our string wide fixed 18
kono
parents:
diff changeset
48 -- our strin wide fixed 17
kono
parents:
diff changeset
49 -- our stri wide fixed 16
kono
parents:
diff changeset
50 -- our stri wide fixe 15
kono
parents:
diff changeset
51 -- our str wide fixe 14
kono
parents:
diff changeset
52 -- our str wid fixe 13
kono
parents:
diff changeset
53 -- our str wid fix 12
kono
parents:
diff changeset
54 -- ou str wid fix 11
kono
parents:
diff changeset
55 -- ou st wid fix 10
kono
parents:
diff changeset
56 -- ou st wi fix 9
kono
parents:
diff changeset
57 -- ou st wi fi 8
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 -- Final file name: OUSTWIFX.ADB
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 -- A special rule applies for children of System, Ada, Gnat, and Interfaces.
kono
parents:
diff changeset
62 -- In these cases, the following special prefix replacements occur:
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 -- ada- replaced by a-
kono
parents:
diff changeset
65 -- gnat- replaced by g-
kono
parents:
diff changeset
66 -- interfaces- replaced by i-
kono
parents:
diff changeset
67 -- system- replaced by s-
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 -- The rest of the name is krunched in the usual manner described above.
kono
parents:
diff changeset
70 -- In addition, these names, as well as the names of the renamed packages
kono
parents:
diff changeset
71 -- from the obsolescent features annex, are always krunched to 8 characters
kono
parents:
diff changeset
72 -- regardless of the setting of Maxlen.
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 -- As an example of this special rule, consider ada-strings-wide_fixed.adb
kono
parents:
diff changeset
75 -- which gets krunched as follows:
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 -- ada-strings-wide_fixed 22
kono
parents:
diff changeset
78 -- a- strings wide fixed 18
kono
parents:
diff changeset
79 -- a- string wide fixed 17
kono
parents:
diff changeset
80 -- a- strin wide fixed 16
kono
parents:
diff changeset
81 -- a- stri wide fixed 15
kono
parents:
diff changeset
82 -- a- stri wide fixe 14
kono
parents:
diff changeset
83 -- a- str wide fixe 13
kono
parents:
diff changeset
84 -- a- str wid fixe 12
kono
parents:
diff changeset
85 -- a- str wid fix 11
kono
parents:
diff changeset
86 -- a- st wid fix 10
kono
parents:
diff changeset
87 -- a- st wi fix 9
kono
parents:
diff changeset
88 -- a- st wi fi 8
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 -- Final file name: A-STWIFX.ADB
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 -- Since children of units named A, G, I or S might conflict with the names
kono
parents:
diff changeset
93 -- of predefined units, the naming rule in that case is that the first hyphen
kono
parents:
diff changeset
94 -- is replaced by a tilde sign.
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 -- Note: as described below, this special treatment of predefined library
kono
parents:
diff changeset
97 -- unit file names can be inhibited by setting the No_Predef flag.
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 -- Of course there is no guarantee that this algorithm results in uniquely
kono
parents:
diff changeset
100 -- crunched names (nor, obviously, is there any algorithm which would do so)
kono
parents:
diff changeset
101 -- In fact we run into such a case in the standard library routines with
kono
parents:
diff changeset
102 -- children of Wide_Text_IO, so a special rule is applied to deal with this
kono
parents:
diff changeset
103 -- clash, namely the prefix ada-wide_text_io- is replaced by a-wt- and then
kono
parents:
diff changeset
104 -- the normal crunching rules are applied, so that for example, the unit:
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 -- Ada.Wide_Text_IO.Float_IO
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 -- has the file name
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 -- a-wtflio
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 -- More problems arise with Wide_Wide, so we replace this sequence by
kono
parents:
diff changeset
113 -- a z (which is not used much) and also (as in the Wide_Text_IO case),
kono
parents:
diff changeset
114 -- we replace the prefix ada.wide_wide_text_io- by a-zt- and then
kono
parents:
diff changeset
115 -- the normal crunching rules are applied.
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 -- These are the only irregularity required (so far) to keep the file names
kono
parents:
diff changeset
118 -- unique in the standard predefined libraries.
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 procedure Krunch
kono
parents:
diff changeset
121 (Buffer : in out String;
kono
parents:
diff changeset
122 Len : in out Natural;
kono
parents:
diff changeset
123 Maxlen : Natural;
kono
parents:
diff changeset
124 No_Predef : Boolean);
kono
parents:
diff changeset
125 pragma Elaborate_Body (Krunch);
kono
parents:
diff changeset
126 -- The full file name is stored in Buffer (1 .. Len) on entry. The file
kono
parents:
diff changeset
127 -- name is crunched in place and on return Len is updated, so that the
kono
parents:
diff changeset
128 -- resulting krunched name is in Buffer (1 .. Len) where Len <= Maxlen.
kono
parents:
diff changeset
129 -- Note that Len may be less than or equal to Maxlen on entry, in which
kono
parents:
diff changeset
130 -- case it may be possible that Krunch does not modify Buffer. The fourth
kono
parents:
diff changeset
131 -- parameter, No_Predef, is a switch which, if set to True, disables the
kono
parents:
diff changeset
132 -- normal special treatment of predefined library unit file names.
kono
parents:
diff changeset
133 --
kono
parents:
diff changeset
134 -- Note: the string Buffer must have a lower bound of 1, and may not
kono
parents:
diff changeset
135 -- contain any blanks (in particular, it must not have leading blanks).