1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 1992-2000 Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
34 ------------------------------------------------------------------------------
38 (Buffer
: in out String;
44 B1
: Character renames Buffer
(1);
51 -- Deal with special predefined children cases. Startloc is the first
52 -- location for the krunch, set to 1, except for the predefined children
53 -- case, where it is set to 3, to start after the standard prefix.
61 and then Buffer
(1 .. 17) = "ada-wide_text_io-"
64 Buffer
(2 .. 5) := "-wt-";
65 Buffer
(6 .. Len
- 12) := Buffer
(18 .. Len
);
69 elsif Len
>= 4 and then Buffer
(1 .. 4) = "ada-" then
71 Buffer
(2 .. Len
- 2) := Buffer
(4 .. Len
);
75 elsif Len
>= 5 and then Buffer
(1 .. 5) = "gnat-" then
77 Buffer
(2 .. Len
- 3) := Buffer
(5 .. Len
);
81 elsif Len
>= 7 and then Buffer
(1 .. 7) = "system-" then
83 Buffer
(2 .. Len
- 5) := Buffer
(7 .. Len
);
87 elsif Len
>= 11 and then Buffer
(1 .. 11) = "interfaces-" then
89 Buffer
(2 .. Len
- 9) := Buffer
(11 .. Len
);
93 -- For the renamings in the obsolescent section, we also force krunching
94 -- to 8 characters, but no other special processing is required here.
95 -- Note that text_io and calendar are already short enough anyway.
97 elsif (Len
= 9 and then Buffer
(1 .. 9) = "direct_io")
98 or else (Len
= 10 and then Buffer
(1 .. 10) = "interfaces")
99 or else (Len
= 13 and then Buffer
(1 .. 13) = "io_exceptions")
100 or else (Len
= 12 and then Buffer
(1 .. 12) = "machine_code")
101 or else (Len
= 13 and then Buffer
(1 .. 13) = "sequential_io")
102 or else (Len
= 20 and then Buffer
(1 .. 20) = "unchecked_conversion")
103 or else (Len
= 22 and then Buffer
(1 .. 22) = "unchecked_deallocation")
109 -- Special case of a child unit whose parent unit is a single letter that
110 -- is A, G, I, or S. In order to prevent confusion with krunched names
111 -- of predefined units use a tilde rather than a minus as the second
112 -- character of the file name. On VMS a tilde is an illegal character
113 -- in a file name, so a dollar_sign is used instead.
116 and then Buffer
(2) = '-'
117 and then (B1
= 'a' or else B1
= 'g' or else B1
= 'i' or else B1
= 's')
118 and then Len
<= Maxlen
120 if Hostparm
.OpenVMS
then
128 -- Normal case, not a predefined file
136 -- Immediate return if file name is short enough now
138 if Curlen
<= Krlen
then
143 -- For now, refuse to krunch a name that contains an ESC character (wide
144 -- character sequence) since it's too much trouble to do this right ???
146 for J
in 1 .. Curlen
loop
147 if Buffer
(J
) = ASCII
.ESC
then
152 -- Count number of separators (minus signs and underscores) and for now
153 -- replace them by spaces. We keep them around till the end to control
154 -- the krunching process, and then we eliminate them as the last step
158 for J
in Startloc
.. Curlen
loop
159 if Buffer
(J
) = '-' or else Buffer
(J
) = '_' then
161 Num_Seps
:= Num_Seps
+ 1;
165 -- Now we do the one character at a time krunch till we are short enough
167 while Curlen
- Num_Seps
> Krlen
loop
169 Long_Length
: Natural := 0;
170 Long_Last
: Natural := 0;
171 Piece_Start
: Natural;
177 -- Loop through pieces to find longest piece
179 while Ptr
<= Curlen
loop
182 -- Loop through characters in one piece of name
184 while Ptr
<= Curlen
and then Buffer
(Ptr
) /= ' ' loop
188 if Ptr
- Piece_Start
> Long_Length
then
189 Long_Length
:= Ptr
- Piece_Start
;
190 Long_Last
:= Ptr
- 1;
196 -- Remove last character of longest piece
198 if Long_Last
< Curlen
then
199 Buffer
(Long_Last
.. Curlen
- 1) :=
200 Buffer
(Long_Last
+ 1 .. Curlen
);
203 Curlen
:= Curlen
- 1;
207 -- Final step, remove the spaces
211 for J
in 1 .. Curlen
loop
212 if Buffer
(J
) /= ' ' then
214 Buffer
(Len
) := Buffer
(J
);