* config/xtensa/linux.h (TARGET_OS_CPP_BUILTINS): Remove definition of
[official-gcc.git] / gcc / ada / prj-ext.adb
blob0f9939b321995e7d1b6e6d921ff7cc5fe7a0e220
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- P R J . E X T --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2000 Free Software Foundation, Inc. --
10 -- --
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. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 with GNAT.HTable;
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,
38 Element => String_Id,
39 No_Element => No_String,
40 Key => Name_Id,
41 Hash => Hash,
42 Equal => "=");
44 ---------
45 -- Add --
46 ---------
48 procedure Add
49 (External_Name : String;
50 Value : String)
52 The_Key : Name_Id;
53 The_Value : String_Id;
55 begin
56 Start_String;
57 Store_String_Chars (Value);
58 The_Value := End_String;
59 Name_Len := External_Name'Length;
60 Name_Buffer (1 .. Name_Len) := External_Name;
61 The_Key := Name_Find;
62 Htable.Set (The_Key, The_Value);
63 end Add;
65 -----------
66 -- Check --
67 -----------
69 function Check (Declaration : String) return Boolean is
70 begin
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;
76 Add
77 (External_Name =>
78 Declaration (Declaration'First .. Equal_Pos - 1),
79 Value =>
80 Declaration (Equal_Pos + 1 .. Declaration'Last));
81 return True;
82 end if;
84 end loop;
86 return False;
87 end Check;
89 --------------
90 -- Value_Of --
91 --------------
93 function Value_Of
94 (External_Name : Name_Id;
95 With_Default : String_Id := No_String)
96 return String_Id
98 The_Value : String_Id;
100 begin
101 The_Value := Htable.Get (External_Name);
103 if The_Value /= No_String then
104 return The_Value;
105 end if;
107 -- Find if it is an environment.
108 -- If it is, put the value in the hash table.
110 declare
111 Env_Value : constant String_Access :=
112 Getenv (Get_Name_String (External_Name));
114 begin
115 if Env_Value /= null and then Env_Value'Length > 0 then
116 Start_String;
117 Store_String_Chars (Env_Value.all);
118 The_Value := End_String;
119 Htable.Set (External_Name, The_Value);
120 return The_Value;
122 else
123 return With_Default;
124 end if;
125 end;
126 end Value_Of;
128 end Prj.Ext;