From a10505d19e40e0802aa1520538cdd87be57e441e Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 16 Oct 2021 02:04:24 +0000 Subject: [PATCH] experimenting with character classes --- lib2/h3-arrays.ads | 1 + lib2/hello2.adb | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib2/h3-arrays.ads b/lib2/h3-arrays.ads index 09decde..9fba326 100644 --- a/lib2/h3-arrays.ads +++ b/lib2/h3-arrays.ads @@ -76,6 +76,7 @@ private end record; type Buffer_Pointer is access all Buffer_Record; + --for Buffer_Pointer'Storage_Pool use <> H3'Storage_Pool; --Empty_Buffer: aliased Buffer_Record(1); -- Use 1 slot to hold the terminator value regardless of th terminator length in Empty_Buffer. diff --git a/lib2/hello2.adb b/lib2/hello2.adb index a2aeaff..41b4fa1 100644 --- a/lib2/hello2.adb +++ b/lib2/hello2.adb @@ -1,8 +1,10 @@ with H3.Arrays; with H3.Strings; +with H3.CC; with Ada.Text_IO; with Ada.Wide_Text_IO; with Ada.Assertions; +with Interfaces.C; use type H3.System_Size; @@ -51,5 +53,29 @@ begin -- --------------------- Ada.Wide_Text_IO.Put_Line (Standard.Wide_String(Str.To_Item_Array)); Ada.Wide_Text_IO.Put_Line (Standard.Wide_String(Str2.To_Item_Array)); -end; + + declare + package C renames Interfaces.C; + package CC is new H3.CC(Standard.Wide_Character); + + --function isspace(a: Standard.Character) return C.int + -- with Import => True, Convention => C, External_Name => "isspace"; + function isspace(a: Standard.Character) return C.int; + pragma Import (C, isspace, "isspace"); + + ch: Standard.Wide_Character; + begin + for i in 0 .. 255 loop + ch := Standard.Wide_Character'Val(i); + Ada.Text_IO.Put (I'img & "[" & ch'Img & "]"); + + for j in CC.Class'Range loop + Ada.Text_IO.Put (" " & J'Img & ":" & CC.Is_Class(ch, j)'Img); + end loop; + + Ada.Text_IO.Put_Line (""); + end loop; + + end; +end;