===================================================================
@@ -33,8 +33,7 @@
package body Ada.Locales is
- type Lower_4 is array (1 .. 4) of Character range 'a' .. 'z';
- type Upper_4 is array (1 .. 4) of Character range 'A' .. 'Z';
+ type Str_4 is new String (1 .. 4);
--------------
-- Language --
@@ -43,7 +42,7 @@
function Language return Language_Code is
procedure C_Get_Language_Code (P : Address);
pragma Import (C, C_Get_Language_Code);
- F : Lower_4;
+ F : Str_4;
begin
C_Get_Language_Code (F'Address);
return Language_Code (F (1 .. 3));
@@ -56,7 +55,7 @@
function Country return Country_Code is
procedure C_Get_Country_Code (P : Address);
pragma Import (C, C_Get_Country_Code);
- F : Upper_4;
+ F : Str_4;
begin
C_Get_Country_Code (F'Address);
return Country_Code (F (1 .. 2));
===================================================================
@@ -19,9 +19,14 @@
pragma Preelaborate (Locales);
pragma Remote_Types (Locales);
- type Language_Code is array (1 .. 3) of Character range 'a' .. 'z';
- type Country_Code is array (1 .. 2) of Character range 'A' .. 'Z';
+ type Language_Code is new String (1 .. 3)
+ with Dynamic_Predicate =>
+ (for all E of Language_Code => E in 'a' .. 'z');
+ type Country_Code is new String (1 .. 2)
+ with Dynamic_Predicate =>
+ (for all E of Country_Code => E in 'A' .. 'Z');
+
Language_Unknown : constant Language_Code := "und";
Country_Unknown : constant Country_Code := "ZZ";