1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 2000 Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
27 ------------------------------------------------------------------------------
30 with GNAT.OS_Lib; use GNAT.OS_Lib;
31 with Namet; use Namet;
32 with Prj.Com; use Prj.Com;
33 with Stringt; use Stringt;
34 with Types; use Types;
36 package body Prj.Ext is
38 package Htable is new GNAT.HTable.Simple_HTable
39 (Header_Num => Header_Num,
41 No_Element => No_String,
51 (External_Name : String;
55 The_Value : String_Id;
59 Store_String_Chars (Value);
60 The_Value := End_String;
61 Name_Len := External_Name'Length;
62 Name_Buffer (1 .. Name_Len) := External_Name;
64 Htable.Set (The_Key, The_Value);
71 function Check (Declaration : String) return Boolean is
73 for Equal_Pos in Declaration'Range loop
75 if Declaration (Equal_Pos) = '=' then
76 exit when Equal_Pos = Declaration'First;
77 exit when Equal_Pos = Declaration'Last;
80 Declaration (Declaration'First .. Equal_Pos - 1),
82 Declaration (Equal_Pos + 1 .. Declaration'Last));
96 (External_Name : Name_Id;
97 With_Default : String_Id := No_String)
100 The_Value : String_Id;
103 The_Value := Htable.Get (External_Name);
105 if The_Value /= No_String then
109 -- Find if it is an environment.
110 -- If it is, put the value in the hash table.
113 Env_Value : constant String_Access :=
114 Getenv (Get_Name_String (External_Name));
117 if Env_Value /= null and then Env_Value'Length > 0 then
119 Store_String_Chars (Env_Value.all);
120 The_Value := End_String;
121 Htable.Set (External_Name, The_Value);