summaryrefslogtreecommitdiff
path: root/gcc/ada/s-wchjis.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-15 09:46:58 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-15 09:46:58 +0000
commit0e24cc5dca80f31987129601ae23ce7ff8c53a4d (patch)
treed646cc375fad086c110529e8fdca4b92e9450943 /gcc/ada/s-wchjis.adb
parent9ce02b233ca3dcfa6be1a342fb0747113b3c7693 (diff)
downloadgcc-0e24cc5dca80f31987129601ae23ce7ff8c53a4d.tar.gz
2006-02-13 Robert Dewar <dewar@adacore.com>
* s-wchjis.adb (JIS_To_EUC): Raise Constraint_Error for invalid value git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111102 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/s-wchjis.adb')
-rw-r--r--gcc/ada/s-wchjis.adb26
1 files changed, 23 insertions, 3 deletions
diff --git a/gcc/ada/s-wchjis.adb b/gcc/ada/s-wchjis.adb
index 5ac43a67bfc..079712f97b7 100644
--- a/gcc/ada/s-wchjis.adb
+++ b/gcc/ada/s-wchjis.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2006, 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- --
@@ -31,6 +31,8 @@
-- --
------------------------------------------------------------------------------
+with System.Pure_Exceptions; use System.Pure_Exceptions;
+
package body System.WCh_JIS is
type Byte is mod 256;
@@ -68,7 +70,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 +78,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_Exception (CE, "invalid small Katakana character");
+ 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_Exception (CE, "wide character value out of EUC range");
+
+ -- 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 +111,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