OSDN Git Service

2008-05-27 Vincent Celier <celier@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-wchjis.adb
index 6767c44..8dbe2db 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---           Copyright (C) 1992-2005 Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2007, 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- --
 --                                                                          --
 ------------------------------------------------------------------------------
 
+pragma Warnings (Off);
+pragma Compiler_Unit;
+pragma Warnings (On);
+
 package body System.WCh_JIS is
 
    type Byte is mod 256;
@@ -68,7 +72,7 @@ package body System.WCh_JIS is
    ----------------
 
    procedure JIS_To_EUC
-     (J    : in Wide_Character;
+     (J    : Wide_Character;
       EUC1 : out Character;
       EUC2 : out Character)
    is
@@ -76,10 +80,28 @@ package body System.WCh_JIS is
       JIS2 : constant Natural := Wide_Character'Pos (J) rem 256;
 
    begin
+      --  Special case of small Katakana
+
       if JIS1 = 0 then
+
+         --  The value must be in the range 16#80# to 16#FF# so that the upper
+         --  bit is set in both bytes.
+
+         if JIS2 < 16#80# then
+            raise Constraint_Error;
+         end if;
+
          EUC1 := Character'Val (EUC_Hankaku_Kana);
          EUC2 := Character'Val (JIS2);
 
+      --  The upper bit of both characters must be clear, or this is not
+      --  a valid character for representation in EUC form.
+
+      elsif JIS1 > 16#7F# or else JIS2 > 16#7F# then
+         raise Constraint_Error;
+
+      --  Result is just the two characters with upper bits set
+
       else
          EUC1 := Character'Val (JIS1 + 16#80#);
          EUC2 := Character'Val (JIS2 + 16#80#);
@@ -91,7 +113,7 @@ package body System.WCh_JIS is
    ----------------------
 
    procedure JIS_To_Shift_JIS
-     (J   : in Wide_Character;
+     (J   : Wide_Character;
       SJ1 : out Character;
       SJ2 : out Character)
    is