/usr/share/ada/adainclude/asis/a4g-a_types.adb is in libasis2014-dev 2014-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . A _ T Y P E S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2012, Free Software Foundation, Inc. --
-- --
-- ASIS-for-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 --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.adacore.com). --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with System; use System;
with Hostparm;
package body A4G.A_Types is
---------------
-- A_OS_Time --
---------------
function A_OS_Time return ASIS_OS_Time is
begin
return ASIS_Clock;
end A_OS_Time;
-----------------------------
-- Asis_Normalize_Pathname --
-----------------------------
Asis_Normalize_Pathname_Result : String_Access;
function Asis_Normalize_Pathname
(Name : String;
Directory : String := "";
Resolve_Links : Boolean := True;
Case_Sensitive : Boolean := True) return String
is
-- ???
-- All the stuff in the declarative part is copied from Osint...
function C_String_Length (S : Address) return Integer;
-- Returns length of a C string (zero for a null address)
function To_Path_String_Access
(Path_Addr : Address;
Path_Len : Integer) return String_Access;
-- Converts a C String to an Ada String. Are we doing this to avoid
-- withing Interfaces.C.Strings ???
-- Caller must free result.
function To_Host_Dir_Spec
(Canonical_Dir : String;
Prefix_Style : Boolean) return String_Access;
-- Convert a canonical syntax directory specification to host syntax.
-- The Prefix_Style flag is currently ignored but should be set to
-- False. Note that the caller must free result.
-- ???
-- Copied from Osint...
function C_String_Length (S : Address) return Integer is
function Strlen (S : Address) return Integer;
pragma Import (C, Strlen, "strlen");
begin
if S = Null_Address then
return 0;
else
return Strlen (S);
end if;
end C_String_Length;
function To_Path_String_Access
(Path_Addr : Address;
Path_Len : Integer) return String_Access
is
subtype Path_String is String (1 .. Path_Len);
type Path_String_Access is access Path_String;
function Address_To_Access is new
Ada.Unchecked_Conversion (Source => Address,
Target => Path_String_Access);
Path_Access : constant Path_String_Access :=
Address_To_Access (Path_Addr);
Return_Val : String_Access;
begin
Return_Val := new String (1 .. Path_Len);
for J in 1 .. Path_Len loop
Return_Val (J) := Path_Access (J);
end loop;
return Return_Val;
end To_Path_String_Access;
function To_Host_Dir_Spec
(Canonical_Dir : String;
Prefix_Style : Boolean) return String_Access
is
function To_Host_Dir_Spec
(Canonical_Dir : Address;
Prefix_Flag : Integer) return Address;
pragma Import (C, To_Host_Dir_Spec, "__gnat_to_host_dir_spec");
C_Canonical_Dir : String (1 .. Canonical_Dir'Length + 1);
Host_Dir_Addr : Address;
Host_Dir_Len : Integer;
begin
C_Canonical_Dir (1 .. Canonical_Dir'Length) := Canonical_Dir;
C_Canonical_Dir (C_Canonical_Dir'Last) := ASCII.NUL;
if Prefix_Style then
Host_Dir_Addr := To_Host_Dir_Spec (C_Canonical_Dir'Address, 1);
else
Host_Dir_Addr := To_Host_Dir_Spec (C_Canonical_Dir'Address, 0);
end if;
Host_Dir_Len := C_String_Length (Host_Dir_Addr);
if Host_Dir_Len = 0 then
return null;
else
return To_Path_String_Access (Host_Dir_Addr, Host_Dir_Len);
end if;
end To_Host_Dir_Spec;
begin
if Name = "" then
return "";
else
Free (Asis_Normalize_Pathname_Result);
Asis_Normalize_Pathname_Result := To_Host_Dir_Spec (
Canonical_Dir =>
Normalize_Pathname (
Name => Name,
Directory => Directory,
Resolve_Links => Resolve_Links,
Case_Sensitive => Case_Sensitive),
Prefix_Style => False);
return Asis_Normalize_Pathname_Result.all;
end if;
end Asis_Normalize_Pathname;
---------------------------
-- Increase_ASIS_OS_Time --
---------------------------
procedure Increase_ASIS_OS_Time is
begin
ASIS_Clock := ASIS_Clock + 1;
end Increase_ASIS_OS_Time;
-----------
-- Later --
-----------
function Later (L, R : ASIS_OS_Time) return Boolean is
begin
return L <= R;
end Later;
------------------------------
-- Parameter_String_To_List --
------------------------------
function Parameter_String_To_List
(Par_String : String)
return Argument_List_Access
is
Max_Pars : constant Integer := Par_String'Length;
New_Parv : Argument_List (1 .. Max_Pars);
New_Parc : Natural := 0;
Idx : Integer;
Old_Idx : Integer;
function Move_To_Next_Par (Ind : Integer) return Integer;
-- Provided that Ind points somewhere inside Par_String, moves
-- it ahead to point to the beginning of the next parameter if
-- Ind points to the character considering as a parameter separator,
-- otherwise returns Ind unchanged. If Ind points to a separator and
-- there is no more parameters ahead, Par_String'Last + 1 is returned.
-- (See the definition of the syntax of the Parameters string in the
-- ASIS Reference Manual)
function Move_To_Par_End (Ind : Integer) return Integer;
-- Provided that Ind points to some character of a separate parameters
-- being a part of Par_String, returns the index of the last character
-- of this parameter
function Move_To_Next_Par (Ind : Integer) return Integer is
Result : Integer := Ind;
begin
while Result <= Par_String'Last and then
(Par_String (Result) = ' ' or else
Par_String (Result) = ASCII.HT or else
Par_String (Result) = ASCII.LF or else
Par_String (Result) = ASCII.CR)
loop
Result := Result + 1;
end loop;
return Result;
end Move_To_Next_Par;
function Move_To_Par_End (Ind : Integer) return Integer is
Result : Integer := Ind;
Quoted : Boolean := False;
begin
loop
-- Am unquoted white space or EOL is the end of an argument
if not Quoted
and then
(Par_String (Result) = ' ' or else
Par_String (Result) = ASCII.HT or else
Par_String (Result) = ASCII.LF or else
Par_String (Result) = ASCII.CR)
then
exit;
-- Start of quoted string
elsif not Quoted
and then Par_String (Result) = '"'
then
Quoted := True;
-- End of a quoted string and end of an argument
elsif Quoted
and then Par_String (Result) = '"'
then
Result := Result + 1;
exit;
end if;
Result := Result + 1;
exit when Result > Par_String'Last;
end loop;
Result := Result - 1;
return Result;
end Move_To_Par_End;
begin
Idx := Move_To_Next_Par (Par_String'First);
while Idx <= Par_String'Last loop
Old_Idx := Idx;
Idx := Move_To_Par_End (Idx);
New_Parc := New_Parc + 1;
New_Parv (New_Parc) :=
new String'(Par_String (Old_Idx .. Idx));
Idx := Move_To_Next_Par (Idx + 1);
end loop;
return new Argument_List'(New_Parv (1 .. New_Parc));
end Parameter_String_To_List;
begin
if Hostparm.OpenVMS then
ASIS_Path_Separator := ',';
ASIS_Current_Directory := new String'("[]");
else
ASIS_Path_Separator := GNAT.OS_Lib.Path_Separator;
ASIS_Current_Directory := new String'(".");
end if;
end A4G.A_Types;
|