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
/
widechar.adb
< prev
next >
Wrap
Text File
|
1996-09-28
|
4KB
|
125 lines
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- W I D E C H A R --
-- --
-- B o d y --
-- --
-- $Revision: 1.10 $ --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- Note: this package uses the generic subprograms in System.Wch_Cnv, which
-- completely encapsulate the set of wide character encoding methods, so no
-- modifications are required when adding new encoding methods.
with Opt; use Opt;
with System.WCh_Cnv; use System.WCh_Cnv;
with System.WCh_Con; use System.WCh_Con;
package body Widechar is
-----------------
-- Length_Wide --
-----------------
function Length_Wide return Nat is
begin
return WC_Longest_Sequence;
end Length_Wide;
---------------
-- Scan_Wide --
---------------
procedure Scan_Wide
(S : Source_Buffer_Ptr;
P : in out Source_Ptr;
C : out Char_Code;
E : out Boolean)
is
function In_Char return Character;
-- Function to obtain characters of wide character escape sequence
function In_Char return Character is
begin
P := P + 1;
return S (P - 1);
end In_Char;
function WC_In is new Char_Sequence_To_Wide_Char (In_Char);
begin
C := Char_Code (Wide_Character'Pos
(WC_In (In_Char, Wide_Character_Encoding_Method)));
E := False;
exception
when Constraint_Error =>
P := P - 1;
E := True;
end Scan_Wide;
--------------
-- Set_Wide --
--------------
procedure Set_Wide
(C : Char_Code;
S : in out String;
P : in out Natural)
is
procedure Out_Char (C : Character);
-- Procedure to store one character of wide character sequence
procedure Out_Char (C : Character) is
begin
P := P + 1;
S (P) := C;
end Out_Char;
procedure WC_Out is new Wide_Char_To_Char_Sequence (Out_Char);
begin
WC_Out (Wide_Character'Val (C), Wide_Character_Encoding_Method);
end Set_Wide;
---------------
-- Skip_Wide --
---------------
procedure Skip_Wide (S : String; P : in out Natural) is
function Skip_Char return Character;
-- Function to skip one character of wide character escape sequence
function Skip_Char return Character is
begin
P := P + 1;
return S (P - 1);
end Skip_Char;
function WC_Skip is new Char_Sequence_To_Wide_Char (Skip_Char);
Discard : Wide_Character;
begin
Discard := WC_Skip (Skip_Char, Wide_Character_Encoding_Method);
end Skip_Wide;
end Widechar;