1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2000-2010, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Osint
; use Osint
;
27 with Prj
.Tree
; use Prj
.Tree
;
29 package body Prj
.Ext
is
36 (Tree
: Prj
.Tree
.Project_Node_Tree_Ref
;
37 External_Name
: String;
43 Name_Len
:= Value
'Length;
44 Name_Buffer
(1 .. Name_Len
) := Value
;
45 The_Value
:= Name_Find
;
46 Name_Len
:= External_Name
'Length;
47 Name_Buffer
(1 .. Name_Len
) := External_Name
;
48 Canonical_Case_Env_Var_Name
(Name_Buffer
(1 .. Name_Len
));
50 Name_To_Name_HTable
.Set
(Tree
.External_References
, The_Key
, The_Value
);
58 (Tree
: Prj
.Tree
.Project_Node_Tree_Ref
;
59 Declaration
: String) return Boolean
62 for Equal_Pos
in Declaration
'Range loop
63 if Declaration
(Equal_Pos
) = '=' then
64 exit when Equal_Pos
= Declaration
'First;
68 Declaration
(Declaration
'First .. Equal_Pos
- 1),
70 Declaration
(Equal_Pos
+ 1 .. Declaration
'Last));
82 procedure Reset
(Tree
: Prj
.Tree
.Project_Node_Tree_Ref
) is
84 Name_To_Name_HTable
.Reset
(Tree
.External_References
);
92 (Tree
: Prj
.Tree
.Project_Node_Tree_Ref
;
93 External_Name
: Name_Id
;
94 With_Default
: Name_Id
:= No_Name
)
98 Name
: String := Get_Name_String
(External_Name
);
101 Canonical_Case_Env_Var_Name
(Name
);
102 Name_Len
:= Name
'Length;
103 Name_Buffer
(1 .. Name_Len
) := Name
;
105 Name_To_Name_HTable
.Get
(Tree
.External_References
, Name_Find
);
107 if The_Value
/= No_Name
then
111 -- Find if it is an environment, if it is, put value in the hash table
114 Env_Value
: String_Access
:= Getenv
(Name
);
117 if Env_Value
/= null and then Env_Value
'Length > 0 then
118 Name_Len
:= Env_Value
'Length;
119 Name_Buffer
(1 .. Name_Len
) := Env_Value
.all;
120 The_Value
:= Name_Find
;
121 Name_To_Name_HTable
.Set
122 (Tree
.External_References
, External_Name
, The_Value
);