-- --
-- B o d y --
-- --
--- $Revision$
--- --
--- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
--- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
--- MA 02111-1307, USA. --
+-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
+-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
--- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
+-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
procedure Write_Char_Code (Code : Char_Code) is
- procedure Write_Hex_Byte (J : Natural);
- -- Write single hex digit
+ procedure Write_Hex_Byte (J : Char_Code);
+ -- Write single hex byte (value in range 0 .. 255) as two digits
- procedure Write_Hex_Byte (J : Natural) is
- Hexd : String := "0123456789abcdef";
+ --------------------
+ -- Write_Hex_Byte --
+ --------------------
+ procedure Write_Hex_Byte (J : Char_Code) is
+ Hexd : constant array (Char_Code range 0 .. 15) of Character :=
+ "0123456789abcdef";
begin
- Write_Char (Hexd (J / 16 + 1));
- Write_Char (Hexd (J mod 16 + 1));
+ Write_Char (Hexd (J / 16));
+ Write_Char (Hexd (J mod 16));
end Write_Hex_Byte;
-- Start of processing for Write_Char_Code
Write_Char ('[');
Write_Char ('"');
+ if Code > 16#FF_FFFF# then
+ Write_Hex_Byte (Code / 2 ** 24);
+ end if;
+
+ if Code > 16#FFFF# then
+ Write_Hex_Byte ((Code / 2 ** 16) mod 256);
+ end if;
+
if Code > 16#FF# then
- Write_Hex_Byte (Natural (Code / 256));
+ Write_Hex_Byte ((Code / 256) mod 256);
end if;
- Write_Hex_Byte (Natural (Code mod 256));
+ Write_Hex_Byte (Code mod 256);
Write_Char ('"');
Write_Char (']');
end if;