| 
									
										
										
										
											2021-10-06 06:28:43 +00:00
										 |  |  |  | with H3.Arrays; | 
					
						
							|  |  |  |  | with H3.Strings; | 
					
						
							| 
									
										
										
										
											2021-10-30 05:32:16 +00:00
										 |  |  |  | with H3.Runes; | 
					
						
							| 
									
										
										
										
											2021-10-06 06:28:43 +00:00
										 |  |  |  | with Ada.Text_IO; | 
					
						
							|  |  |  |  | with Ada.Wide_Text_IO; | 
					
						
							|  |  |  |  | with Ada.Assertions; | 
					
						
							| 
									
										
										
										
											2021-10-16 02:04:24 +00:00
										 |  |  |  | with Interfaces.C; | 
					
						
							| 
									
										
										
										
											2021-10-16 11:42:42 +00:00
										 |  |  |  | --with Interfaces.C.Strings;
 | 
					
						
							|  |  |  |  | with System; | 
					
						
							| 
									
										
										
										
											2021-10-06 06:28:43 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | use type H3.System_Size; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | procedure hello2 is | 
					
						
							| 
									
										
										
										
											2021-10-27 15:34:30 +00:00
										 |  |  |  | 	package A is new H3.Arrays(Standard.Wide_Character, 1, Wide_Character'First); | 
					
						
							|  |  |  |  | 	package S is new H3.Strings(Standard.Wide_Character); | 
					
						
							| 
									
										
										
										
											2021-10-30 05:32:16 +00:00
										 |  |  |  | 	package R is new H3.Runes(Standard.Wide_Character); | 
					
						
							| 
									
										
										
										
											2021-10-16 11:42:42 +00:00
										 |  |  |  | 	package C renames Interfaces.C; | 
					
						
							| 
									
										
										
										
											2021-10-06 06:28:43 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	--package S_I is new H3.Arrays(Integer, 1, 16#FF#);
 | 
					
						
							|  |  |  |  | 	Arr: A.Elastic_Array; | 
					
						
							|  |  |  |  | 	Arr2: A.Elastic_Array; | 
					
						
							|  |  |  |  | 	 | 
					
						
							|  |  |  |  | 	Str: S.Elastic_String; | 
					
						
							|  |  |  |  | 	Str2: S.Elastic_String; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	use type S.Elastic_String; | 
					
						
							| 
									
										
										
										
											2021-10-16 11:42:42 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	--procedure setlocale(a: C.int; b: Interfaces.C.Strings.chars_ptr);
 | 
					
						
							|  |  |  |  | 	procedure setlocale(a: C.int; b: System.Address); | 
					
						
							|  |  |  |  | 	pragma Import (C, setlocale, "setlocale"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-30 05:32:16 +00:00
										 |  |  |  | 	function is_class (V: Standard.Wide_Character; Class: R.Item_Class) return Standard.Boolean is | 
					
						
							| 
									
										
										
										
											2021-10-16 11:42:42 +00:00
										 |  |  |  | 		function iswalpha(a: C.int) return C.int; | 
					
						
							|  |  |  |  | 		pragma Import (C, iswalpha, "iswalpha"); | 
					
						
							|  |  |  |  | 		function iswalnum(a: C.int) return C.int; | 
					
						
							|  |  |  |  | 		pragma Import (C, iswalnum, "iswalnum"); | 
					
						
							|  |  |  |  | 		function iswblank(a: C.int) return C.int; | 
					
						
							|  |  |  |  | 		pragma Import (C, iswblank, "iswblank"); | 
					
						
							|  |  |  |  | 		function iswcntrl(a: C.int) return C.int; | 
					
						
							|  |  |  |  | 		pragma Import (C, iswcntrl, "iswcntrl"); | 
					
						
							|  |  |  |  | 		function iswdigit(a: C.int) return C.int; | 
					
						
							|  |  |  |  | 		pragma Import (C, iswdigit, "iswdigit"); | 
					
						
							|  |  |  |  | 		function iswgraph(a: C.int) return C.int; | 
					
						
							|  |  |  |  | 		pragma Import (C, iswgraph, "iswgraph"); | 
					
						
							|  |  |  |  | 		function iswlower(a: C.int) return C.int; | 
					
						
							|  |  |  |  | 		pragma Import (C, iswlower, "iswlower"); | 
					
						
							|  |  |  |  | 		function iswprint(a: C.int) return C.int; | 
					
						
							|  |  |  |  | 		pragma Import (C, iswprint, "iswprint"); | 
					
						
							|  |  |  |  | 		function iswpunct(a: C.int) return C.int; | 
					
						
							|  |  |  |  | 		pragma Import (C, iswpunct, "iswpunct"); | 
					
						
							|  |  |  |  | 		function iswspace(a: C.int) return C.int; | 
					
						
							|  |  |  |  | 		pragma Import (C, iswspace, "iswspace"); | 
					
						
							|  |  |  |  | 		function iswupper(a: C.int) return C.int; | 
					
						
							|  |  |  |  | 		pragma Import (C, iswupper, "iswupper"); | 
					
						
							|  |  |  |  | 		function iswxdigit(a: C.int) return C.int; | 
					
						
							|  |  |  |  | 		pragma Import (C, iswxdigit, "iswxdigit"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		use type C.int; | 
					
						
							|  |  |  |  | 		X: C.int := Standard.Wide_Character'Pos(V); | 
					
						
							|  |  |  |  | 	begin | 
					
						
							| 
									
										
										
										
											2021-10-27 16:16:36 +00:00
										 |  |  |  | 		case Class is | 
					
						
							| 
									
										
										
										
											2021-10-30 05:32:16 +00:00
										 |  |  |  | 			when R.ALPHA => return IswAlpha(X) /= 0; | 
					
						
							|  |  |  |  | 			when R.ALNUM => return IswAlnum(X) /= 0; | 
					
						
							|  |  |  |  | 			when R.BLANK => return IswBlank(X) /= 0; | 
					
						
							|  |  |  |  | 			when R.CNTRL => return IswCntrl(X) /= 0; | 
					
						
							|  |  |  |  | 			when R.DIGIT => return IswDigit(X) /= 0; | 
					
						
							|  |  |  |  | 			when R.GRAPH => return IswGraph(X) /= 0; | 
					
						
							|  |  |  |  | 			when R.LOWER => return IswLower(X) /= 0; | 
					
						
							|  |  |  |  | 			when R.PRINT => return IswPrint(X) /= 0; | 
					
						
							|  |  |  |  | 			when R.PUNCT => return IswPunct(X) /= 0; | 
					
						
							|  |  |  |  | 			when R.SPACE => return IswSpace(X) /= 0; | 
					
						
							|  |  |  |  | 			when R.UPPER => return IswUpper(X) /= 0; | 
					
						
							|  |  |  |  | 			when R.XDIGIT => return IswXdigit(X) /= 0; | 
					
						
							| 
									
										
										
										
											2021-10-16 11:42:42 +00:00
										 |  |  |  | 		end case; | 
					
						
							|  |  |  |  | 	end is_class; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-16 15:19:10 +00:00
										 |  |  |  | 	--Empty_String: aliased Standard.String := "en_US.utf8" & Standard.Character'Val(0);
 | 
					
						
							|  |  |  |  | 	Empty_String: aliased Standard.String := "" & Standard.Character'Val(0); | 
					
						
							| 
									
										
										
										
											2021-10-06 06:28:43 +00:00
										 |  |  |  | begin | 
					
						
							| 
									
										
										
										
											2021-10-16 11:42:42 +00:00
										 |  |  |  | 	--setlocale (6, Interfaces.C.Strings.To_Chars_Ptr(Empty_String'access));
 | 
					
						
							|  |  |  |  | 	setlocale (6, Empty_String'Address); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-06 06:28:43 +00:00
										 |  |  |  | 	A.Append (Arr, "hello"); | 
					
						
							|  |  |  |  | 	A.Append (Arr, "world"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	Arr.Append ("fantastic"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	Arr2 := Arr; | 
					
						
							|  |  |  |  | 	A.Delete (Arr2, 1, 5); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	Str.Append ("wonderful"); | 
					
						
							|  |  |  |  | 	Str.Delete (2, 3); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	Str2 := Str; | 
					
						
							|  |  |  |  | 	Str2.Clear; | 
					
						
							| 
									
										
										
										
											2021-10-16 11:42:42 +00:00
										 |  |  |  | 	Str2.Append ("saxage"); | 
					
						
							| 
									
										
										
										
											2021-10-06 06:28:43 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	Str := Str2; | 
					
						
							|  |  |  |  | 	Str.Clear; | 
					
						
							|  |  |  |  | 	Str.Append("primitive"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if Str = "savage" then | 
					
						
							|  |  |  |  | 		ada.text_io.put_line ("is savage"); | 
					
						
							|  |  |  |  | 	else | 
					
						
							|  |  |  |  | 		ada.text_io.put_line ("is not savage"); | 
					
						
							|  |  |  |  | 	end if; | 
					
						
							|  |  |  |  | 	Ada.Wide_Text_IO.Put_Line (Standard.Wide_String(A.To_Item_Array(Arr))); | 
					
						
							|  |  |  |  | 	Ada.Wide_Text_IO.Put_Line (Standard.Wide_String(A.To_Item_Array(Arr2))); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	-- ---------------------
 | 
					
						
							|  |  |  |  | 	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)); | 
					
						
							| 
									
										
										
										
											2021-10-16 02:04:24 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	declare | 
					
						
							|  |  |  |  | 		--function isspace(a: Standard.Character) return C.int
 | 
					
						
							|  |  |  |  | 		--	with Import => True, Convention => C, External_Name => "isspace";
 | 
					
						
							|  |  |  |  | 		ch: Standard.Wide_Character; | 
					
						
							|  |  |  |  | 	begin | 
					
						
							| 
									
										
										
										
											2021-10-16 11:42:42 +00:00
										 |  |  |  | 		for i in 0 .. 10000 loop | 
					
						
							| 
									
										
										
										
											2021-10-16 02:04:24 +00:00
										 |  |  |  | 			ch := Standard.Wide_Character'Val(i); | 
					
						
							|  |  |  |  | 			Ada.Text_IO.Put (I'img & "[" & ch'Img & "]"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-30 05:32:16 +00:00
										 |  |  |  | 			for j in R.Item_Class'Range loop | 
					
						
							|  |  |  |  | 				Ada.Text_IO.Put (" " & J'Img & ":" & R.Is_Class(ch, j)'Img); | 
					
						
							|  |  |  |  | 				if R.Is_Class(ch, j) /= Is_Class(ch, j) then | 
					
						
							| 
									
										
										
										
											2021-10-16 11:42:42 +00:00
										 |  |  |  | 					Ada.Text_IO.Put ("[X]"); | 
					
						
							|  |  |  |  | 				--else
 | 
					
						
							|  |  |  |  | 				--	Ada.Text_IO.Put ("[O]");
 | 
					
						
							|  |  |  |  | 				end if; | 
					
						
							| 
									
										
										
										
											2021-10-16 02:04:24 +00:00
										 |  |  |  | 			end loop; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 			Ada.Text_IO.Put_Line (""); | 
					
						
							|  |  |  |  | 		end loop; | 
					
						
							|  |  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2021-10-30 05:32:16 +00:00
										 |  |  |  | 		Ada.Text_IO.Put_line (R.Is_Alpha('σ')'Img); | 
					
						
							| 
									
										
										
										
											2021-10-16 02:04:24 +00:00
										 |  |  |  | 	end; | 
					
						
							|  |  |  |  | end;	 | 
					
						
							| 
									
										
										
										
											2021-10-06 06:28:43 +00:00
										 |  |  |  | 
 |