summaryrefslogtreecommitdiff
path: root/gcc/ada/prj-ext.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/prj-ext.adb')
-rw-r--r--gcc/ada/prj-ext.adb65
1 files changed, 42 insertions, 23 deletions
diff --git a/gcc/ada/prj-ext.adb b/gcc/ada/prj-ext.adb
index 0f9939b3219..5d8368f145a 100644
--- a/gcc/ada/prj-ext.adb
+++ b/gcc/ada/prj-ext.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2000 Free Software Foundation, Inc. --
+-- Copyright (C) 2000-2003 Free Software Foundation, Inc. --
-- --
-- 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 Soft- --
@@ -24,22 +24,28 @@
-- --
------------------------------------------------------------------------------
+with Namet; use Namet;
+with Osint; use Osint;
+with Prj.Com; use Prj.Com;
+with Types; use Types;
+
with GNAT.HTable;
with GNAT.OS_Lib; use GNAT.OS_Lib;
-with Namet; use Namet;
-with Prj.Com; use Prj.Com;
-with Stringt; use Stringt;
-with Types; use Types;
package body Prj.Ext is
package Htable is new GNAT.HTable.Simple_HTable
(Header_Num => Header_Num,
- Element => String_Id,
- No_Element => No_String,
+ Element => Name_Id,
+ No_Element => No_Name,
Key => Name_Id,
Hash => Hash,
Equal => "=");
+ -- External references are stored in this hash table, either by procedure
+ -- Add (directly or through a call to function Check) or by function
+ -- Value_Of when an environment variable is found non empty. Value_Of
+ -- first for external reference in this table, before checking the
+ -- environment. Htable is emptied (reset) by procedure Reset.
---------
-- Add --
@@ -50,14 +56,15 @@ package body Prj.Ext is
Value : String)
is
The_Key : Name_Id;
- The_Value : String_Id;
+ The_Value : Name_Id;
begin
- Start_String;
- Store_String_Chars (Value);
- The_Value := End_String;
+ Name_Len := Value'Length;
+ Name_Buffer (1 .. Name_Len) := Value;
+ The_Value := Name_Find;
Name_Len := External_Name'Length;
Name_Buffer (1 .. Name_Len) := External_Name;
+ Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
The_Key := Name_Find;
Htable.Set (The_Key, The_Value);
end Add;
@@ -69,7 +76,6 @@ package body Prj.Ext is
function Check (Declaration : String) return Boolean is
begin
for Equal_Pos in Declaration'Range loop
-
if Declaration (Equal_Pos) = '=' then
exit when Equal_Pos = Declaration'First;
exit when Equal_Pos = Declaration'Last;
@@ -80,27 +86,39 @@ package body Prj.Ext is
Declaration (Equal_Pos + 1 .. Declaration'Last));
return True;
end if;
-
end loop;
return False;
end Check;
+ -----------
+ -- Reset --
+ -----------
+
+ procedure Reset is
+ begin
+ Htable.Reset;
+ end Reset;
+
--------------
-- Value_Of --
--------------
function Value_Of
(External_Name : Name_Id;
- With_Default : String_Id := No_String)
- return String_Id
+ With_Default : Name_Id := No_Name)
+ return Name_Id
is
- The_Value : String_Id;
+ The_Value : Name_Id;
+ Name : String := Get_Name_String (External_Name);
begin
- The_Value := Htable.Get (External_Name);
+ Canonical_Case_File_Name (Name);
+ Name_Len := Name'Length;
+ Name_Buffer (1 .. Name_Len) := Name;
+ The_Value := Htable.Get (Name_Find);
- if The_Value /= No_String then
+ if The_Value /= No_Name then
return The_Value;
end if;
@@ -108,18 +126,19 @@ package body Prj.Ext is
-- If it is, put the value in the hash table.
declare
- Env_Value : constant String_Access :=
- Getenv (Get_Name_String (External_Name));
+ Env_Value : String_Access := Getenv (Name);
begin
if Env_Value /= null and then Env_Value'Length > 0 then
- Start_String;
- Store_String_Chars (Env_Value.all);
- The_Value := End_String;
+ Name_Len := Env_Value'Length;
+ Name_Buffer (1 .. Name_Len) := Env_Value.all;
+ The_Value := Name_Find;
Htable.Set (External_Name, The_Value);
+ Free (Env_Value);
return The_Value;
else
+ Free (Env_Value);
return With_Default;
end if;
end;