This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Handle incorrect input in JIS_To_EUC


Tested on i686-linux, committed on trunk

This patch deals with the fact that JIS_To_EUC generates rubbish
output if it is fed rubbish input (i.e. an invalid JIS code). This
was noticed running the run-time with checks enabled, since this
resulted in an overflow check. The implementation of this routine
has been modified so that it checks explicitly for a bad input
and raises Constraint_Error with an appropriate message if so.

A test program is:

with Ada.Text_IO, Ada.Wide_Text_IO;
with Ada.Exceptions; use Ada.Exceptions;

procedure W is
   File_Name : constant String := "wform-e" & ".wtxt";
   Form      : constant String := "WCEM=e";
   File      : Ada.Wide_Text_IO.File_Type;

begin
   Ada.Text_IO.Put_Line ("Creating file " & File_Name & " with Form """ &
                         Form & '"');
   Ada.Wide_Text_IO.Create (File, Name => File_Name, Form => Form);
   Ada.Wide_Text_IO.Put_Line (File, "ab["9224"]cd");
   Ada.Wide_Text_IO.Close (File);

exception
   when E : others =>
      Ada.Text_IO.Put_Line ("exception raised");
      Ada.Text_IO.Put_Line (Exception_Information (E));
      Ada.Wide_Text_IO.Close (File);
end W;

which will now when executed output:

Creating file wform-e.wtxt with Form "WCEM=e"
exception raised
Exception name: CONSTRAINT_ERROR
Message: wide character value out of EUC range

2006-02-13  Robert Dewar  <dewar@adacore.com>

	* s-wchjis.adb (JIS_To_EUC): Raise Constraint_Error for invalid value

Attachment: difs.83
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]