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
/
casing.adb
< prev
next >
Wrap
Text File
|
1996-09-28
|
4KB
|
109 lines
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- C A S I N G --
-- --
-- B o d y --
-- --
-- $Revision: 1.18 $ --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
with Csets; use Csets;
with Namet; use Namet;
with Opt; use Opt;
with Sinput; use Sinput;
with Types; use Types;
with Widechar; use Widechar;
package body Casing is
----------------
-- Set_Casing --
----------------
procedure Set_Casing (C : Casing_Type; D : Casing_Type := Mixed_Case) is
Ptr : Natural;
Actual_Casing : Casing_Type;
-- Set from C or D as appropriate
After_Und : Boolean := True;
-- True at start of string, and after an underline character or after
-- any other special character that is not a normal identifier char).
begin
if C /= Unknown then
Actual_Casing := C;
else
Actual_Casing := D;
end if;
Ptr := 1;
while Ptr <= Name_Len loop
if Name_Buffer (Ptr) = Ascii.ESC
or else (Upper_Half_Encoding
and then Name_Buffer (Ptr) in Upper_Half_Character)
then
Skip_Wide (Name_Buffer, Ptr);
After_Und := False;
elsif Name_Buffer (Ptr) = '_'
or else not Identifier_Char (Name_Buffer (Ptr))
then
After_Und := True;
Ptr := Ptr + 1;
elsif Is_Lower_Case_Letter (Name_Buffer (Ptr)) then
if Actual_Casing = All_Upper_Case
or else (After_Und and then Actual_Casing = Mixed_Case)
then
Name_Buffer (Ptr) := Fold_Upper (Name_Buffer (Ptr));
end if;
After_Und := False;
Ptr := Ptr + 1;
elsif Is_Upper_Case_Letter (Name_Buffer (Ptr)) then
if Actual_Casing = All_Lower_Case
or else (not After_Und and then Actual_Casing = Mixed_Case)
then
Name_Buffer (Ptr) := Fold_Lower (Name_Buffer (Ptr));
end if;
After_Und := False;
Ptr := Ptr + 1;
else -- all other characters
After_Und := False;
Ptr := Ptr + 1;
end if;
end loop;
end Set_Casing;
------------------------
-- Set_All_Upper_Case --
------------------------
procedure Set_All_Upper_Case is
begin
Set_Casing (All_Upper_Case);
end Set_All_Upper_Case;
end Casing;