Comments
Patch
===================================================================
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
+-- Copyright (C) 2005-2010, 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- --
@@ -150,6 +150,19 @@ package body Ada.Wide_Wide_Characters.Un
end Is_Space;
-------------------
+ -- To_Lower_Case --
+ -------------------
+
+ function To_Lower_Case
+ (U : Wide_Wide_Character) return Wide_Wide_Character
+ is
+ begin
+ return
+ Wide_Wide_Character'Val
+ (G.UTF_32_To_Lower_Case (Wide_Wide_Character'Pos (U)));
+ end To_Lower_Case;
+
+ -------------------
-- To_Upper_Case --
-------------------
===================================================================
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
+-- Copyright (C) 2005-2010, 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- --
@@ -173,7 +173,16 @@ package Ada.Wide_Wide_Characters.Unicode
-- The following function is used to fold to upper case, as required by
-- the Ada 2005 standard rules for identifier case folding. Two
-- identifiers are equivalent if they are identical after folding all
- -- letters to upper case using this routine.
+ -- letters to upper case using this routine. A fold to lower routine is
+ -- also provided.
+
+ function To_Lower_Case
+ (U : Wide_Wide_Character) return Wide_Wide_Character;
+ pragma Inline (To_Lower_Case);
+ -- If U represents an upper case letter, returns the corresponding lower
+ -- case letter, otherwise U is returned unchanged. The folding is locale
+ -- independent as defined by documents referenced in the note in section
+ -- 1 of ISO/IEC 10646:2003
function To_Upper_Case
(U : Wide_Wide_Character) return Wide_Wide_Character;
===================================================================
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
+-- Copyright (C) 2005-2010, 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- --
@@ -150,6 +150,19 @@ package body Ada.Wide_Characters.Unicode
end Is_Space;
-------------------
+ -- To_Lower_Case --
+ -------------------
+
+ function To_Lower_Case
+ (U : Wide_Character) return Wide_Character
+ is
+ begin
+ return
+ Wide_Character'Val
+ (G.UTF_32_To_Lower_Case (Wide_Character'Pos (U)));
+ end To_Lower_Case;
+
+ -------------------
-- To_Upper_Case --
-------------------
===================================================================
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
+-- Copyright (C) 2005-2010, 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- --
@@ -176,7 +176,15 @@ package Ada.Wide_Characters.Unicode is
-- The following function is used to fold to upper case, as required by
-- the Ada 2005 standard rules for identifier case folding. Two
-- identifiers are equivalent if they are identical after folding all
- -- letters to upper case using this routine.
+ -- letters to upper case using this routine. A corresponding function to
+ -- fold to lower case is also provided.
+
+ function To_Lower_Case (U : Wide_Character) return Wide_Character;
+ pragma Inline (To_Lower_Case);
+ -- If U represents an upper case letter, returns the corresponding lower
+ -- case letter, otherwise U is returned unchanged. The folding is locale
+ -- independent as defined by documents referenced in the note in section
+ -- 1 of ISO/IEC 10646:2003
function To_Upper_Case (U : Wide_Character) return Wide_Character;
pragma Inline (To_Upper_Case);
This patch adds a To_Lower_Case function to the Unicode packages for Wide_Character and Wide_Wide_Character, and improves and corrects the To_Upper_Case function as previously described for the corresponding case conversion routines in System.UTF_32, on which these new routines depend. The following two programs compile without error using -gnata -gnat05: with Ada.Wide_Characters.Unicode; use Ada.Wide_Characters.Unicode; with Text_IO; use Text_IO; procedure WUnicode is subtype WC is Wide_Character; C : WC; procedure T (Test : String; Val : Boolean) is begin if not Val then Put_Line ("Test " & test & " failed"); end if; end T; begin T ("01", To_Upper_Case (WC'Val (16#B5#)) = WC'Val (16#B5#)); T ("02", To_Upper_Case ('a') = 'A'); T ("03", To_Upper_Case (WC'Val (16#253#)) = WC'Val(16#253# - 210)); T ("04", To_Lower_Case (WC'Val(16#B5#)) = WC'Val(16#B5#)); T ("05", To_Lower_Case (WC'Val(16#253# - 210)) = WC'Val(16#253#)); T ("06", To_Lower_Case ('A') = 'a'); for J in Wide_Character loop C := To_Lower_Case (J); T ("07", C = J or else To_Upper_Case (C) = J); C := To_Upper_Case (J); T ("08", C = J or else To_Lower_Case (C) = J); end loop; end WUnicode; with Ada.Wide_Wide_Characters.Unicode; use Ada.Wide_Wide_Characters.Unicode; with Text_IO; use Text_IO; procedure WWUnicode is subtype WC is Wide_Wide_Character; C : WC; procedure T (Test : String; Val : Boolean) is begin if not Val then Put_Line ("Test " & test & " failed"); end if; end T; begin T ("01", To_Upper_Case (WC'Val (16#B5#)) = WC'Val (16#B5#)); T ("02", To_Upper_Case ('a') = 'A'); T ("03", To_Upper_Case (WC'Val (16#253#)) = WC'Val(16#253# - 210)); T ("04", To_Lower_Case (WC'Val(16#B5#)) = WC'Val(16#B5#)); T ("05", To_Lower_Case (WC'Val(16#253# - 210)) = WC'Val(16#253#)); T ("06", To_Lower_Case ('A') = 'a'); for J in WC'Val (0) .. WC'Val(16#10_FFFF#) loop C := To_Lower_Case (J); T ("07", C = J or else To_Upper_Case (C) = J); C := To_Upper_Case (J); T ("08", C = J or else To_Lower_Case (C) = J); end loop; end WWUnicode; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-07 Robert Dewar <dewar@adacore.com> * a-wichun.ads, a-wichun.adb (To_Lower_Case): New function (To_Upper_Case): Fix to be inverse of To_Lower_Case * a-zchuni.ads, a-zchuni.adb (To_Lower_Case): New function (To_Upper_Case): Fix to be inverse of To_Lower_Case