From patchwork Thu Oct 7 09:26:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 67019 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id BDFE9B6F01 for ; Thu, 7 Oct 2010 20:27:02 +1100 (EST) Received: (qmail 3272 invoked by alias); 7 Oct 2010 09:26:57 -0000 Received: (qmail 3078 invoked by uid 22791); 7 Oct 2010 09:26:52 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Oct 2010 09:26:43 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 805EE29000E; Thu, 7 Oct 2010 11:26:40 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ChYpf0ZEu-JV; Thu, 7 Oct 2010 11:26:40 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id 6A79329000D; Thu, 7 Oct 2010 11:26:40 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 4BA15D9BB5; Thu, 7 Oct 2010 11:26:40 +0200 (CEST) Date: Thu, 7 Oct 2010 11:26:40 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] Ada 2012 packages Ada.Wide_[Wide_]Characters.Handling Message-ID: <20101007092640.GA31299@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch implements AI-185 which defines two new Ada 2012 packages Ada.Wide_[Wide_]Characters.Handling. The Wide_Wide package is available in Ada 2005 mode, and the Wide package is available in Ada 95 mode. Both are of course available in Ada 2012 mode. The following two programs execute quietly with -gnata -gnat12 with Ada.Wide_Characters.Handling; use Ada.Wide_Characters.Handling; with Text_IO; use Text_IO; procedure WchTest 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 -- To_Upper/To_Lower T ("01", To_Upper (WC'Val (16#B5#)) = WC'Val (16#B5#)); T ("02", To_Upper ('a') = 'A'); T ("03", To_Upper (WC'Val (16#253#)) = WC'Val(16#253# - 210)); T ("04", To_Upper ("Hello!") = "HELLO!"); T ("05", To_Lower (WC'Val(16#B5#)) = WC'Val(16#B5#)); T ("06", To_Lower (WC'Val(16#253# - 210)) = WC'Val(16#253#)); T ("07", To_Lower ('A') = 'a'); T ("08", To_Lower ("Hello Robert!") = "hello robert!"); for J in Wide_Character loop C := To_Lower (J); T ("09", C = J or else To_Upper (C) = J); C := To_Upper (J); T ("10", C = J or else To_Lower (C) = J); end loop; T ("11", Is_Control (WC'Val (13))); T ("12", not Is_Control ('a')); T ("13", Is_Lower ('a')); T ("14", not Is_Lower ('A')); T ("15", Is_Upper ('A')); T ("16", not Is_Upper ('a')); T ("17", Is_Digit ('3')); T ("18", not Is_Digit ('a')); T ("17", Is_Digit ('3')); T ("18", not Is_Digit ('a')); T ("19", Is_Decimal_Digit ('3')); T ("20", not Is_Decimal_Digit ('a')); T ("21", Is_Hexadecimal_Digit ('3')); T ("22", Is_Hexadecimal_Digit ('a')); T ("23", not Is_Hexadecimal_Digit ('g')); T ("24", Is_Alphanumeric ('3')); T ("25", Is_Alphanumeric ('a')); T ("26", not Is_Alphanumeric ('!')); T ("27", Is_Special ('!')); T ("28", not Is_Special ('a')); T ("29", Is_Line_Terminator (WC'Val (13))); T ("30", not Is_Line_Terminator ('a')); T ("31", Is_Mark (WC'Val (16#35E#))); T ("32", not Is_Mark ('.')); T ("33", Is_Other (WC'Val (16#6DD#))); T ("34", not Is_Other (''')); T ("35", Is_Punctuation (WC'Val (16#2054#))); T ("36", not Is_Punctuation ('.')); T ("37", Is_Space (' ')); T ("38", Is_Space (WC'Val (16#202F#))); T ("39", not Is_Space ('_')); T ("40", Is_Graphic (WC'Val (16#2027#))); T ("41", not Is_Graphic (WC'Val (16#2029#))); end WchTest; with Ada.Wide_Wide_Characters.Handling; use Ada.Wide_Wide_Characters.Handling; with Text_IO; use Text_IO; procedure WWchTest 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 -- To_Upper/To_Lower T ("01", To_Upper (WC'Val (16#B5#)) = WC'Val (16#B5#)); T ("02", To_Upper ('a') = 'A'); T ("03", To_Upper (WC'Val (16#253#)) = WC'Val(16#253# - 210)); T ("04", To_Upper ("Hello!") = "HELLO!"); T ("05", To_Lower (WC'Val(16#B5#)) = WC'Val(16#B5#)); T ("06", To_Lower (WC'Val(16#253# - 210)) = WC'Val(16#253#)); T ("07", To_Lower ('A') = 'a'); T ("08", To_Lower ("Hello Robert!") = "hello robert!"); for J in WC'Val (0) .. WC'Val (16#10_FFFF#) loop C := To_Lower (J); T ("09", C = J or else To_Upper (C) = J); C := To_Upper (J); T ("10", C = J or else To_Lower (C) = J); end loop; T ("11", Is_Control (WC'Val (13))); T ("12", not Is_Control ('a')); T ("13", Is_Lower ('a')); T ("14", not Is_Lower ('A')); T ("15", Is_Upper ('A')); T ("16", not Is_Upper ('a')); T ("17", Is_Digit ('3')); T ("18", not Is_Digit ('a')); T ("17", Is_Digit ('3')); T ("18", not Is_Digit ('a')); T ("19", Is_Decimal_Digit ('3')); T ("20", not Is_Decimal_Digit ('a')); T ("21", Is_Hexadecimal_Digit ('3')); T ("22", Is_Hexadecimal_Digit ('a')); T ("23", not Is_Hexadecimal_Digit ('g')); T ("24", Is_Alphanumeric ('3')); T ("25", Is_Alphanumeric ('a')); T ("26", not Is_Alphanumeric ('!')); T ("27", Is_Special ('!')); T ("28", not Is_Special ('a')); T ("29", Is_Line_Terminator (WC'Val (13))); T ("30", not Is_Line_Terminator ('a')); T ("31", Is_Mark (WC'Val (16#35E#))); T ("32", not Is_Mark ('.')); T ("33", Is_Other (WC'Val (16#6DD#))); T ("34", not Is_Other (''')); T ("35", Is_Punctuation (WC'Val (16#2054#))); T ("36", not Is_Punctuation ('.')); T ("37", Is_Space (' ')); T ("38", Is_Space (WC'Val (16#202F#))); T ("39", not Is_Space ('_')); T ("40", Is_Graphic (WC'Val (16#2027#))); T ("41", not Is_Graphic (WC'Val (16#2029#))); end WWchTest; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-07 Robert Dewar * a-wichha.adb, a-wichha.ads, a-zchhan.adb, a-zchhan.ads: New file. * impunit.adb: Add entries for a-wichha/a-zchhan * Makefile.rtl: Add entries for a-wichha/a-zchhan Property changes on: a-wichha.ads Index: impunit.adb =================================================================== --- impunit.adb (revision 165080) +++ impunit.adb (working copy) @@ -177,6 +177,7 @@ package body Impunit is -- harmless (and useful) to make then available in Ada 95 mode, since -- they do not deal with Wide_Wide_Character. + "a-wichha", -- Ada.Wide_Characters.Handling "a-stuten", -- Ada.Strings.UTF_Encoding "a-suenco", -- Ada.Strings.UTF_Encoding.Conversions "a-suesen", -- Ada.Strings.UTF_Encoding.String_Encoding @@ -426,6 +427,7 @@ package body Impunit is "a-wwboio", -- Ada.Wide_Text_IO.Wide_Bounded_IO "a-wwunio", -- Ada.Wide_Text_IO.Wide_Unbounded_IO "a-zchara", -- Ada.Wide_Wide_Characters + "a-zchhan", -- Ada.Wide_Wide_Characters.Handling "a-ztcoio", -- Ada.Wide_Wide_Text_IO.Complex_IO "a-ztedit", -- Ada.Wide_Wide_Text_IO.Editing "a-zttest", -- Ada.Wide_Wide_Text_IO.Text_Streams Index: a-zchhan.adb =================================================================== --- a-zchhan.adb (revision 0) +++ a-zchhan.adb (revision 0) @@ -0,0 +1,186 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT RUN-TIME COMPONENTS -- +-- -- +-- A D A . W I D E _ W I D E _ C H A R A C T E R S . H A N D L I N G -- +-- -- +-- B o d y -- +-- -- +-- Copyright (C) 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- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- +-- or FITNESS FOR A PARTICULAR PURPOSE. -- +-- -- +-- As a special exception under Section 7 of GPL version 3, you are granted -- +-- additional permissions described in the GCC Runtime Library Exception, -- +-- version 3.1, as published by the Free Software Foundation. -- +-- -- +-- You should have received a copy of the GNU General Public License and -- +-- a copy of the GCC Runtime Library Exception along with this program; -- +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- +-- . -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +with Ada.Wide_Wide_Characters.Unicode; use Ada.Wide_Wide_Characters.Unicode; + +package body Ada.Wide_Wide_Characters.Handling is + + --------------------- + -- Is_Alphanumeric -- + --------------------- + + function Is_Alphanumeric (Item : Wide_Wide_Character) return Boolean is + begin + return Is_Letter (Item) or else Is_Digit (Item); + end Is_Alphanumeric; + + ---------------- + -- Is_Control -- + ---------------- + + function Is_Control (Item : Wide_Wide_Character) return Boolean is + begin + return Get_Category (Item) = Cc; + end Is_Control; + + -------------- + -- Is_Digit -- + -------------- + + function Is_Digit (Item : Wide_Wide_Character) return Boolean + renames Ada.Wide_Wide_Characters.Unicode.Is_Digit; + + ---------------- + -- Is_Graphic -- + ---------------- + + function Is_Graphic (Item : Wide_Wide_Character) return Boolean is + begin + return not Is_Non_Graphic (Item); + end Is_Graphic; + + -------------------------- + -- Is_Hexadecimal_Digit -- + -------------------------- + + function Is_Hexadecimal_Digit (Item : Wide_Wide_Character) return Boolean is + begin + return Is_Digit (Item) + or else Item in 'A' .. 'F' + or else Item in 'a' .. 'f'; + end Is_Hexadecimal_Digit; + + --------------- + -- Is_Letter -- + --------------- + + function Is_Letter (Item : Wide_Wide_Character) return Boolean + renames Ada.Wide_Wide_Characters.Unicode.Is_Letter; + + ------------------------ + -- Is_Line_Terminator -- + ------------------------ + + function Is_Line_Terminator (Item : Wide_Wide_Character) return Boolean + renames Ada.Wide_Wide_Characters.Unicode.Is_Line_Terminator; + + -------------- + -- Is_Lower -- + -------------- + + function Is_Lower (Item : Wide_Wide_Character) return Boolean is + begin + return Get_Category (Item) = Ll; + end Is_Lower; + + ------------- + -- Is_Mark -- + ------------- + + function Is_Mark (Item : Wide_Wide_Character) return Boolean + renames Ada.Wide_Wide_Characters.Unicode.Is_Mark; + + -------------- + -- Is_Other -- + -------------- + + function Is_Other (Item : Wide_Wide_Character) return Boolean + renames Ada.Wide_Wide_Characters.Unicode.Is_Other; + + -------------------- + -- Is_Punctuation -- + -------------------- + + function Is_Punctuation (Item : Wide_Wide_Character) return Boolean + renames Ada.Wide_Wide_Characters.Unicode.Is_Punctuation; + + -------------- + -- Is_Space -- + -------------- + + function Is_Space (Item : Wide_Wide_Character) return Boolean + renames Ada.Wide_Wide_Characters.Unicode.Is_Space; + + ---------------- + -- Is_Special -- + ---------------- + + function Is_Special (Item : Wide_Wide_Character) return Boolean is + begin + return Is_Graphic (Item) and then not Is_Alphanumeric (Item); + end Is_Special; + + -------------- + -- Is_Upper -- + -------------- + + function Is_Upper (Item : Wide_Wide_Character) return Boolean is + begin + return Get_Category (Item) = Lu; + end Is_Upper; + + -------------- + -- To_Lower -- + -------------- + + function To_Lower (Item : Wide_Wide_Character) return Wide_Wide_Character + renames Ada.Wide_Wide_Characters.Unicode.To_Lower_Case; + + function To_Lower (Item : Wide_Wide_String) return Wide_Wide_String is + Result : Wide_Wide_String (Item'Range); + + begin + for J in Result'Range loop + Result (J) := To_Lower (Item (J)); + end loop; + + return Result; + end To_Lower; + + -------------- + -- To_Upper -- + -------------- + + function To_Upper (Item : Wide_Wide_Character) return Wide_Wide_Character + renames Ada.Wide_Wide_Characters.Unicode.To_Upper_Case; + + function To_Upper (Item : Wide_Wide_String) return Wide_Wide_String is + Result : Wide_Wide_String (Item'Range); + + begin + for J in Result'Range loop + Result (J) := To_Upper (Item (J)); + end loop; + + return Result; + end To_Upper; + +end Ada.Wide_Wide_Characters.Handling; Property changes on: a-zchhan.adb ___________________________________________________________________ Name: svn:executable + * Index: a-zchhan.ads =================================================================== --- a-zchhan.ads (revision 0) +++ a-zchhan.ads (revision 0) @@ -0,0 +1,126 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT RUN-TIME COMPONENTS -- +-- -- +-- A D A . W I D E _ W I D E _ C H A R A C T E R S . H A N D L I N G -- +-- -- +-- S p e c -- +-- -- +-- This specification is derived from the Ada Reference Manual for use with -- +-- GNAT. In accordance with the copyright of that document, you can freely -- +-- copy and modify this specification, provided that if you redistribute a -- +-- modified version, any changes that you have made are clearly indicated. -- +-- -- +------------------------------------------------------------------------------ + +package Ada.Wide_Wide_Characters.Handling is + + function Is_Control (Item : Wide_Wide_Character) return Boolean; + pragma Inline (Is_Control); + -- Returns True if the Wide_Wide_Character designated by Item is + -- categorized as other_control, otherwise returns false. + + function Is_Letter (Item : Wide_Wide_Character) return Boolean; + pragma Inline (Is_Letter); + -- Returns True if the Wide_Wide_Character designated by Item is + -- categorized as letter_uppercase, letter_lowercase, letter_titlecase, + -- letter_modifier, letter_other, or number_letter. Otherwise returns + -- false. + + function Is_Lower (Item : Wide_Wide_Character) return Boolean; + pragma Inline (Is_Lower); + -- Returns True if the Wide_Wide_Character designated by Item is + -- categorized as letter_lowercase, otherwise returns false. + + function Is_Upper (Item : Wide_Wide_Character) return Boolean; + pragma Inline (Is_Upper); + -- Returns True if the Wide_Wide_Character designated by Item is + -- categorized as letter_uppercase, otherwise returns false. + + function Is_Digit (Item : Wide_Wide_Character) return Boolean; + pragma Inline (Is_Digit); + -- Returns True if the Wide_Wide_Character designated by Item is + -- categorized as number_decimal, otherwise returns false. + + function Is_Decimal_Digit (Item : Wide_Wide_Character) return Boolean + renames Is_Digit; + + function Is_Hexadecimal_Digit (Item : Wide_Wide_Character) return Boolean; + -- Returns True if the Wide_Wide_Character designated by Item is + -- categorized as number_decimal, or is in the range 'A' .. 'F' or + -- 'a' .. 'f', otherwise returns false. + + function Is_Alphanumeric (Item : Wide_Wide_Character) return Boolean; + pragma Inline (Is_Alphanumeric); + -- Returns True if the Wide_Wide_Character designated by Item is + -- categorized as letter_uppercase, letter_lowercase, letter_titlecase, + -- letter_modifier, letter_other, number_letter, or number_decimal. + -- Otherwise returns false. + + function Is_Special (Item : Wide_Wide_Character) return Boolean; + pragma Inline (Is_Special); + -- Returns True if the Wide_Wide_Character designated by Item + -- is categorized as graphic_character, but not categorized as + -- letter_uppercase, letter_lowercase, letter_titlecase, letter_modifier, + -- letter_other, number_letter, or number_decimal. Otherwise returns false. + + function Is_Line_Terminator (Item : Wide_Wide_Character) return Boolean; + pragma Inline (Is_Line_Terminator); + -- Returns True if the Wide_Wide_Character designated by Item is + -- categorized as separator_line or separator_paragraph, or if Item is a + -- conventional line terminator character (CR, LF, VT, or FF). Otherwise + -- returns false. + + function Is_Mark (Item : Wide_Wide_Character) return Boolean; + pragma Inline (Is_Mark); + -- Returns True if the Wide_Wide_Character designated by Item is + -- categorized as mark_non_spacing or mark_spacing_combining, otherwise + -- returns false. + + function Is_Other (Item : Wide_Wide_Character) return Boolean; + pragma Inline (Is_Other); + -- Returns True if the Wide_Wide_Character designated by Item is + -- categorized as other_format, otherwise returns false. + + function Is_Punctuation (Item : Wide_Wide_Character) return Boolean; + pragma Inline (Is_Punctuation); + -- Returns True if the Wide_Wide_Character designated by Item is + -- categorized as punctuation_connector, otherwise returns false. + + function Is_Space (Item : Wide_Wide_Character) return Boolean; + pragma Inline (Is_Space); + -- Returns True if the Wide_Wide_Character designated by Item is + -- categorized as separator_space, otherwise returns false. + + function Is_Graphic (Item : Wide_Wide_Character) return Boolean; + pragma Inline (Is_Graphic); + -- Returns True if the Wide_Wide_Character designated by Item is + -- categorized as graphic_character, otherwise returns false. + + function To_Lower (Item : Wide_Wide_Character) return Wide_Wide_Character; + pragma Inline (To_Lower); + -- Returns the Simple Lowercase Mapping of the Wide_Wide_Character + -- designated by Item. If the Simple Lowercase Mapping does not exist for + -- the Wide_Wide_Character designated by Item, then the value of Item is + -- returned. + + function To_Lower (Item : Wide_Wide_String) return Wide_Wide_String; + -- Returns the result of applying the To_Lower Wide_Wide_Character to + -- Wide_Wide_Character conversion to each element of the Wide_Wide_String + -- designated by Item. The result is the null Wide_Wide_String if the value + -- of the formal parameter is the null Wide_Wide_String. + + function To_Upper (Item : Wide_Wide_Character) return Wide_Wide_Character; + pragma Inline (To_Upper); + -- Returns the Simple Uppercase Mapping of the Wide_Wide_Character + -- designated by Item. If the Simple Uppercase Mapping does not exist for + -- the Wide_Wide_Character designated by Item, then the value of Item is + -- returned. + + function To_Upper (Item : Wide_Wide_String) return Wide_Wide_String; + -- Returns the result of applying the To_Upper Wide_Wide_Character to + -- Wide_Wide_Character conversion to each element of the Wide_Wide_String + -- designated by Item. The result is the null Wide_Wide_String if the value + -- of the formal parameter is the null Wide_Wide_String. + +end Ada.Wide_Wide_Characters.Handling; Property changes on: a-zchhan.ads ___________________________________________________________________ Name: svn:executable + * Index: Makefile.rtl =================================================================== --- Makefile.rtl (revision 165080) +++ Makefile.rtl (working copy) @@ -268,6 +268,7 @@ GNATRTL_NONTASKING_OBJS= \ a-tiunio$(objext) \ a-unccon$(objext) \ a-uncdea$(objext) \ + a-wichha$(objext) \ a-wichun$(objext) \ a-widcha$(objext) \ a-witeio$(objext) \ @@ -292,6 +293,7 @@ GNATRTL_NONTASKING_OBJS= \ a-wwboio$(objext) \ a-wwunio$(objext) \ a-zchara$(objext) \ + a-zchhan$(objext) \ a-zchuni$(objext) \ a-zrstfi$(objext) \ a-ztcoau$(objext) \ Index: a-wichha.adb =================================================================== --- a-wichha.adb (revision 0) +++ a-wichha.adb (revision 0) @@ -0,0 +1,186 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT RUN-TIME COMPONENTS -- +-- -- +-- A D A . W I D E _ C H A R A C T E R S . H A N D L I N G -- +-- -- +-- B o d y -- +-- -- +-- Copyright (C) 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- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- +-- or FITNESS FOR A PARTICULAR PURPOSE. -- +-- -- +-- As a special exception under Section 7 of GPL version 3, you are granted -- +-- additional permissions described in the GCC Runtime Library Exception, -- +-- version 3.1, as published by the Free Software Foundation. -- +-- -- +-- You should have received a copy of the GNU General Public License and -- +-- a copy of the GCC Runtime Library Exception along with this program; -- +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- +-- . -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +with Ada.Wide_Characters.Unicode; use Ada.Wide_Characters.Unicode; + +package body Ada.Wide_Characters.Handling is + + --------------------- + -- Is_Alphanumeric -- + --------------------- + + function Is_Alphanumeric (Item : Wide_Character) return Boolean is + begin + return Is_Letter (Item) or else Is_Digit (Item); + end Is_Alphanumeric; + + ---------------- + -- Is_Control -- + ---------------- + + function Is_Control (Item : Wide_Character) return Boolean is + begin + return Get_Category (Item) = Cc; + end Is_Control; + + -------------- + -- Is_Digit -- + -------------- + + function Is_Digit (Item : Wide_Character) return Boolean + renames Ada.Wide_Characters.Unicode.Is_Digit; + + ---------------- + -- Is_Graphic -- + ---------------- + + function Is_Graphic (Item : Wide_Character) return Boolean is + begin + return not Is_Non_Graphic (Item); + end Is_Graphic; + + -------------------------- + -- Is_Hexadecimal_Digit -- + -------------------------- + + function Is_Hexadecimal_Digit (Item : Wide_Character) return Boolean is + begin + return Is_Digit (Item) + or else Item in 'A' .. 'F' + or else Item in 'a' .. 'f'; + end Is_Hexadecimal_Digit; + + --------------- + -- Is_Letter -- + --------------- + + function Is_Letter (Item : Wide_Character) return Boolean + renames Ada.Wide_Characters.Unicode.Is_Letter; + + ------------------------ + -- Is_Line_Terminator -- + ------------------------ + + function Is_Line_Terminator (Item : Wide_Character) return Boolean + renames Ada.Wide_Characters.Unicode.Is_Line_Terminator; + + -------------- + -- Is_Lower -- + -------------- + + function Is_Lower (Item : Wide_Character) return Boolean is + begin + return Get_Category (Item) = Ll; + end Is_Lower; + + ------------- + -- Is_Mark -- + ------------- + + function Is_Mark (Item : Wide_Character) return Boolean + renames Ada.Wide_Characters.Unicode.Is_Mark; + + -------------- + -- Is_Other -- + -------------- + + function Is_Other (Item : Wide_Character) return Boolean + renames Ada.Wide_Characters.Unicode.Is_Other; + + -------------------- + -- Is_Punctuation -- + -------------------- + + function Is_Punctuation (Item : Wide_Character) return Boolean + renames Ada.Wide_Characters.Unicode.Is_Punctuation; + + -------------- + -- Is_Space -- + -------------- + + function Is_Space (Item : Wide_Character) return Boolean + renames Ada.Wide_Characters.Unicode.Is_Space; + + ---------------- + -- Is_Special -- + ---------------- + + function Is_Special (Item : Wide_Character) return Boolean is + begin + return Is_Graphic (Item) and then not Is_Alphanumeric (Item); + end Is_Special; + + -------------- + -- Is_Upper -- + -------------- + + function Is_Upper (Item : Wide_Character) return Boolean is + begin + return Get_Category (Item) = Lu; + end Is_Upper; + + -------------- + -- To_Lower -- + -------------- + + function To_Lower (Item : Wide_Character) return Wide_Character + renames Ada.Wide_Characters.Unicode.To_Lower_Case; + + function To_Lower (Item : Wide_String) return Wide_String is + Result : Wide_String (Item'Range); + + begin + for J in Result'Range loop + Result (J) := To_Lower (Item (J)); + end loop; + + return Result; + end To_Lower; + + -------------- + -- To_Upper -- + -------------- + + function To_Upper (Item : Wide_Character) return Wide_Character + renames Ada.Wide_Characters.Unicode.To_Upper_Case; + + function To_Upper (Item : Wide_String) return Wide_String is + Result : Wide_String (Item'Range); + + begin + for J in Result'Range loop + Result (J) := To_Upper (Item (J)); + end loop; + + return Result; + end To_Upper; + +end Ada.Wide_Characters.Handling; Property changes on: a-wichha.adb ___________________________________________________________________ Name: svn:executable + * Index: a-wichha.ads =================================================================== --- a-wichha.ads (revision 0) +++ a-wichha.ads (revision 0) @@ -0,0 +1,120 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT RUN-TIME COMPONENTS -- +-- -- +-- A D A . W I D E _ C H A R A C T E R S . H A N D L I N G -- +-- -- +-- S p e c -- +-- -- +-- This specification is derived from the Ada Reference Manual for use with -- +-- GNAT. In accordance with the copyright of that document, you can freely -- +-- copy and modify this specification, provided that if you redistribute a -- +-- modified version, any changes that you have made are clearly indicated. -- +-- -- +------------------------------------------------------------------------------ + +package Ada.Wide_Characters.Handling is + + function Is_Control (Item : Wide_Character) return Boolean; + pragma Inline (Is_Control); + -- Returns True if the Wide_Character designated by Item is categorized as + -- other_control, otherwise returns false. + + function Is_Letter (Item : Wide_Character) return Boolean; + pragma Inline (Is_Letter); + -- Returns True if the Wide_Character designated by Item is categorized as + -- letter_uppercase, letter_lowercase, letter_titlecase, letter_modifier, + -- letter_other, or number_letter. Otherwise returns false. + + function Is_Lower (Item : Wide_Character) return Boolean; + pragma Inline (Is_Lower); + -- Returns True if the Wide_Character designated by Item is categorized as + -- letter_lowercase, otherwise returns false. + + function Is_Upper (Item : Wide_Character) return Boolean; + pragma Inline (Is_Upper); + -- Returns True if the Wide_Character designated by Item is categorized as + -- letter_uppercase, otherwise returns false. + + function Is_Digit (Item : Wide_Character) return Boolean; + pragma Inline (Is_Digit); + -- Returns True if the Wide_Character designated by Item is categorized as + -- number_decimal, otherwise returns false. + + function Is_Decimal_Digit (Item : Wide_Character) return Boolean + renames Is_Digit; + + function Is_Hexadecimal_Digit (Item : Wide_Character) return Boolean; + -- Returns True if the Wide_Character designated by Item is categorized as + -- number_decimal, or is in the range 'A' .. 'F' or 'a' .. 'f', otherwise + -- returns false. + + function Is_Alphanumeric (Item : Wide_Character) return Boolean; + pragma Inline (Is_Alphanumeric); + -- Returns True if the Wide_Character designated by Item is categorized as + -- number_decimal, or is in the range 'A' .. 'F' or 'a' .. 'f', otherwise + -- returns false. + + function Is_Special (Item : Wide_Character) return Boolean; + pragma Inline (Is_Special); + -- Returns True if the Wide_Character designated by Item is categorized + -- as graphic_character, but not categorized as letter_uppercase, + -- letter_lowercase, letter_titlecase, letter_modifier, letter_other, + -- number_letter, or number_decimal. Otherwise returns false. + + function Is_Line_Terminator (Item : Wide_Character) return Boolean; + pragma Inline (Is_Line_Terminator); + -- Returns True if the Wide_Character designated by Item is categorized as + -- separator_line or separator_paragraph, or if Item is a conventional line + -- terminator character (CR, LF, VT, or FF). Otherwise returns false. + + function Is_Mark (Item : Wide_Character) return Boolean; + pragma Inline (Is_Mark); + -- Returns True if the Wide_Character designated by Item is categorized as + -- mark_non_spacing or mark_spacing_combining, otherwise returns false. + + function Is_Other (Item : Wide_Character) return Boolean; + pragma Inline (Is_Other); + -- Returns True if the Wide_Character designated by Item is categorized as + -- other_format, otherwise returns false. + + function Is_Punctuation (Item : Wide_Character) return Boolean; + pragma Inline (Is_Punctuation); + -- Returns True if the Wide_Character designated by Item is categorized as + -- punctuation_connector, otherwise returns false. + + function Is_Space (Item : Wide_Character) return Boolean; + pragma Inline (Is_Space); + -- Returns True if the Wide_Character designated by Item is categorized as + -- separator_space, otherwise returns false. + + function Is_Graphic (Item : Wide_Character) return Boolean; + pragma Inline (Is_Graphic); + -- Returns True if the Wide_Character designated by Item is categorized as + -- graphic_character, otherwise returns false. + + function To_Lower (Item : Wide_Character) return Wide_Character; + pragma Inline (To_Lower); + -- Returns the Simple Lowercase Mapping of the Wide_Character designated by + -- Item. If the Simple Lowercase Mapping does not exist for the + -- Wide_Character designated by Item, then the value of Item is returned. + + function To_Lower (Item : Wide_String) return Wide_String; + -- Returns the result of applying the To_Lower Wide_Character to + -- Wide_Character conversion to each element of the Wide_String designated + -- by Item. The result is the null Wide_String if the value of the formal + -- parameter is the null Wide_String. + + function To_Upper (Item : Wide_Character) return Wide_Character; + pragma Inline (To_Upper); + -- Returns the Simple Uppercase Mapping of the Wide_Character designated by + -- Item. If the Simple Uppercase Mapping does not exist for the + -- Wide_Character designated by Item, then the value of Item is returned. + + function To_Upper (Item : Wide_String) return Wide_String; + -- Returns the result of applying the To_Upper Wide_Character to + -- Wide_Character conversion to each element of the Wide_String designated + -- by Item. The result is the null Wide_String if the value of the formal + -- parameter is the null Wide_String. + +end Ada.Wide_Characters.Handling;