adacl_eastrings_6.1.1_e075ab39/src/macos/adacl-eastrings-os.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
-----------------------------------------------------------------------------
--
--  Copyright 2004 Björn Persson.
--
--  This library is free software; you can redistribute it and/or modify it
--  under the terms of the GNU General Public License, version 2, as published
--  by the Free Software Foundation.
--
--  As a special exception, if other files instantiate generics from this
--  unit, or you link this unit with other files to produce an executable,
--  this unit does not by itself cause the resulting executable to be covered
--  by the General Public License. This exception does not however invalidate
--  any other reasons why the executable file might be covered by the General
--  Public License.
--
----------------------------------------------------------------------------

pragma License (Modified_Gpl);
pragma Ada_2022;

with Interfaces.C.Strings;
--  with AdaCL.EAstrings;
pragma Elaborate_All (Interfaces.C.Strings);
--  pragma Elaborate_All (AdaCL.EAstrings);

package body AdaCL.EAstrings.OS is

   procedure Init_Locale;
   pragma Import (C, Init_Locale, "Init_Locale");

   function System_Encoding return  Interfaces.C.Strings.chars_ptr;
   pragma Import (C, System_Encoding, "System_Encoding");

   Encoding : Character_Encoding := Null_String_Encoding;
   --  The real initialization is done below, but without an initialization
   --  here I get a bug box in Gnat 3.4.0.

   function OS_Encoding return Character_Encoding is
   begin
      return Encoding;
   end OS_Encoding;

begin
   Init_Locale;
   Encoding :=
      Encoding_By_Name (Interfaces.C.Strings.Value (System_Encoding));
end AdaCL.EAstrings.OS;