1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2000 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
28 with GNAT.OS_Lib; use GNAT.OS_Lib;
29 with Namet; use Namet;
30 with Prj.Com; use Prj.Com;
31 with Stringt; use Stringt;
32 with Types; use Types;
34 package body Prj.Ext is
36 package Htable is new GNAT.HTable.Simple_HTable
37 (Header_Num => Header_Num,
39 No_Element => No_String,
49 (External_Name : String;
53 The_Value : String_Id;
57 Store_String_Chars (Value);
58 The_Value := End_String;
59 Name_Len := External_Name'Length;
60 Name_Buffer (1 .. Name_Len) := External_Name;
62 Htable.Set (The_Key, The_Value);
69 function Check (Declaration : String) return Boolean is
71 for Equal_Pos in Declaration'Range loop
73 if Declaration (Equal_Pos) = '=' then
74 exit when Equal_Pos = Declaration'First;
75 exit when Equal_Pos = Declaration'Last;
78 Declaration (Declaration'First .. Equal_Pos - 1),
80 Declaration (Equal_Pos + 1 .. Declaration'Last));
94 (External_Name : Name_Id;
95 With_Default : String_Id := No_String)
98 The_Value : String_Id;
101 The_Value := Htable.Get (External_Name);
103 if The_Value /= No_String then
107 -- Find if it is an environment.
108 -- If it is, put the value in the hash table.
111 Env_Value : constant String_Access :=
112 Getenv (Get_Name_String (External_Name));
115 if Env_Value /= null and then Env_Value'Length > 0 then
117 Store_String_Chars (Env_Value.all);
118 The_Value := End_String;
119 Htable.Set (External_Name, The_Value);