home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
gnat-2.06-src.tgz
/
tar.out
/
fsf
/
gnat
/
ada
/
krunch.ads
< prev
next >
Wrap
Text File
|
1996-09-28
|
6KB
|
122 lines
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- K R U N C H --
-- --
-- S p e c --
-- --
-- $Revision: 1.8 $ --
-- --
-- Copyright (c) 1992,1993,1994,1995 NYU, All Rights Reserved --
-- --
-- The GNAT library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU Library General Public License as published by --
-- the Free Software Foundation; either version 2, or (at your option) any --
-- later version. The GNAT library is distributed in the hope that it will --
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- Library General Public License for more details. You should have --
-- received a copy of the GNU Library General Public License along with --
-- the GNAT library; see the file COPYING.LIB. If not, write to the Free --
-- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
-- --
------------------------------------------------------------------------------
-- This procedure implements file name crunching
-- First, the name is divided into segments separated by minus signs and
-- underscores, then all minus signs and underscores are eliminated. If
-- this leaves the name short enough, we are done.
-- If not, then the longest segment is located (left-most if there are
-- two of equal length), and shortened by dropping its last character.
-- This is repeated until the name is short enough.
-- As an example, consider the krunch of our-strings-wide_fixed.adb
-- to fit the name into 8 characters as required by DOS:
-- our-strings-wide_fixed 22
-- our strings wide fixed 19
-- our string wide fixed 18
-- our strin wide fixed 17
-- our stri wide fixed 16
-- our stri wide fixe 15
-- our str wide fixe 14
-- our str wid fixe 13
-- our str wid fix 12
-- ou str wid fix 11
-- ou st wid fix 10
-- ou st wi fix 9
-- ou st wi fi 8
-- Final file name: OUSTWIFX.ADB
-- A special rule applies for children of System, Ada, Gnat, and Interfaces.
-- In these cases, the following special prefix replacements occur:
-- ada- replaced by a-
-- gnat- replaced by g-
-- interfaces- replaced by i-
-- system- replaced by s-
-- The rest of the name is krunched in the usual manner described above.
-- In addition, these names, as well as the names of the renamed packages
-- from the obsolescent features annex, are always krunched to 8 characters
-- regardless of the setting of Maxlen.
-- As an example of this special rule, consider ada-strings-wide_fixed.adb
-- which gets krunched as follows:
-- ada-strings-wide_fixed 22
-- a- strings wide fixed 18
-- a- string wide fixed 17
-- a- strin wide fixed 16
-- a- stri wide fixed 15
-- a- stri wide fixe 14
-- a- str wide fixe 13
-- a- str wid fixe 12
-- a- str wid fix 11
-- a- st wid fix 10
-- a- st wi fix 9
-- a- st wi fi 8
-- Final file name: A-STWIFX.ADB
-- Since children of units named A, G, I or S might conflict with the names
-- of predefined units, the naming rule in that case is that the first hyphen
-- is replaced by a plus sign.
-- Note: as described below, this special treatment of predefined library
-- unit file names can be inhibited by setting the No_Predef flag.
-- Of course there is no guarantee that this algorithm results in uniquely
-- crunched names (nor, obviously, is there any algorithm which would do so)
-- In fact we run into such a case in the standard library routines with
-- children of Text_IO.Wide_Text_IO, so a special rule is applied to deal
-- with this clash, namely the prefix ada-text_io-wide_text_io- is replaced
-- by a-wt- and then the normal crunching rules are applied, so that for
-- example, the unit:
-- Ada.Text_IO.Wide_Text_IO.Float_IO
-- has the file name
-- a-wtflio
-- This is the only irregularity required (so far!) to keep the file names
-- unique in the standard predefined libraries.
procedure Krunch
(Buffer : in out String;
Len : in out Natural;
Maxlen : Natural;
No_Predef : Boolean);
-- The full file name is stored in Buffer (1 .. Len) on entry. The file
-- name is crunched in place and on return Len is updated, so that the
-- resulting krunched name is in Buffer (1 .. Len) where Len <= Maxlen.
-- Note that Len may be less than or equal to Maxlen on entry, in which
-- case it may be possible that Krunch does not modify Buffer. The fourth
-- parameter, No_Predef, is a switch which, if set to True, disables the
-- normal special treatment of predefined library unit file names.