Commit d9b4a5d3 by Emmanuel Briot Committed by Arnaud Charlet

prj-ext.adb, [...] (Is_External_Assignment): Remove duplicate code.

2009-09-17  Emmanuel Briot  <briot@adacore.com>

	* prj-ext.adb, prj-ext.ads, makeutl.adb (Is_External_Assignment):
	Remove duplicate code.
	(Prj.Ext): Fix memory leak
	(Check): Now allow the syntax "-Xfoo=" to set an empty value to the
	variable. This was previously allowed in the code in
	Is_External_Assignment, and some tests rely on it

From-SVN: r151793
parent daa72421
2009-09-17 Emmanuel Briot <briot@adacore.com>
* prj-ext.adb, prj-ext.ads, makeutl.adb (Is_External_Assignment):
Remove duplicate code.
(Prj.Ext): Fix memory leak
(Check): Now allow the syntax "-Xfoo=" to set an empty value to the
variable. This was previously allowed in the code in
Is_External_Assignment, and some tests rely on it
2009-09-17 Bob Duff <duff@adacore.com> 2009-09-17 Bob Duff <duff@adacore.com>
* gnat_rm.texi, s-oscons-tmplt.c: Minor typo * gnat_rm.texi, s-oscons-tmplt.c: Minor typo
......
...@@ -453,7 +453,6 @@ package body Makeutl is ...@@ -453,7 +453,6 @@ package body Makeutl is
is is
Start : Positive := 3; Start : Positive := 3;
Finish : Natural := Argv'Last; Finish : Natural := Argv'Last;
Equal_Pos : Natural;
pragma Assert (Argv'First = 1); pragma Assert (Argv'First = 1);
pragma Assert (Argv (1 .. 2) = "-X"); pragma Assert (Argv (1 .. 2) = "-X");
...@@ -471,21 +470,9 @@ package body Makeutl is ...@@ -471,21 +470,9 @@ package body Makeutl is
end if; end if;
end if; end if;
Equal_Pos := Start; return Prj.Ext.Check
while Equal_Pos <= Finish and then Argv (Equal_Pos) /= '=' loop
Equal_Pos := Equal_Pos + 1;
end loop;
if Equal_Pos = Start or else Equal_Pos > Finish then
return False;
else
Prj.Ext.Add
(Tree => Tree, (Tree => Tree,
External_Name => Argv (Start .. Equal_Pos - 1), Declaration => Argv (Start .. Finish));
Value => Argv (Equal_Pos + 1 .. Finish));
return True;
end if;
end Is_External_Assignment; end Is_External_Assignment;
--------------- ---------------
......
...@@ -32,16 +32,6 @@ with Table; ...@@ -32,16 +32,6 @@ with Table;
package body Prj.Ext is package body Prj.Ext is
Ada_Project_Path : constant String := "ADA_PROJECT_PATH";
-- Name of alternate env. variable that contain path name(s) of directories
-- where project files may reside. GPR_PROJECT_PATH has precedence over
-- ADA_PROJECT_PATH.
Gpr_Prj_Path : constant String_Access := Getenv (Gpr_Project_Path);
Ada_Prj_Path : constant String_Access := Getenv (Ada_Project_Path);
-- The path name(s) of directories where project files may reside.
-- May be empty.
No_Project_Default_Dir : constant String := "-"; No_Project_Default_Dir : constant String := "-";
Current_Project_Path : String_Access; Current_Project_Path : String_Access;
...@@ -82,7 +72,6 @@ package body Prj.Ext is ...@@ -82,7 +72,6 @@ package body Prj.Ext is
Name_To_Name_HTable.Set (Tree.External_References, The_Key, The_Value); Name_To_Name_HTable.Set (Tree.External_References, The_Key, The_Value);
end Add; end Add;
-----------
---------------------------------- ----------------------------------
-- Add_Search_Project_Directory -- -- Add_Search_Project_Directory --
---------------------------------- ----------------------------------
...@@ -104,7 +93,6 @@ package body Prj.Ext is ...@@ -104,7 +93,6 @@ package body Prj.Ext is
for Equal_Pos in Declaration'Range loop for Equal_Pos in Declaration'Range loop
if Declaration (Equal_Pos) = '=' then if Declaration (Equal_Pos) = '=' then
exit when Equal_Pos = Declaration'First; exit when Equal_Pos = Declaration'First;
exit when Equal_Pos = Declaration'Last;
Add Add
(Tree => Tree, (Tree => Tree,
External_Name => External_Name =>
...@@ -129,6 +117,17 @@ package body Prj.Ext is ...@@ -129,6 +117,17 @@ package body Prj.Ext is
New_Len : Positive; New_Len : Positive;
New_Last : Positive; New_Last : Positive;
Ada_Project_Path : constant String := "ADA_PROJECT_PATH";
Gpr_Project_Path : constant String := "GPR_PROJECT_PATH";
-- Name of alternate env. variable that contain path name(s) of
-- directories where project files may reside. GPR_PROJECT_PATH has
-- precedence over ADA_PROJECT_PATH.
Gpr_Prj_Path : String_Access := Getenv (Gpr_Project_Path);
Ada_Prj_Path : String_Access := Getenv (Ada_Project_Path);
-- The path name(s) of directories where project files may reside.
-- May be empty.
begin begin
-- The current directory is always first -- The current directory is always first
...@@ -152,12 +151,16 @@ package body Prj.Ext is ...@@ -152,12 +151,16 @@ package body Prj.Ext is
Add_Str_To_Name_Buffer (Gpr_Prj_Path.all); Add_Str_To_Name_Buffer (Gpr_Prj_Path.all);
end if; end if;
Free (Gpr_Prj_Path);
if Ada_Prj_Path.all /= "" then if Ada_Prj_Path.all /= "" then
Name_Len := Name_Len + 1; Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := Path_Separator; Name_Buffer (Name_Len) := Path_Separator;
Add_Str_To_Name_Buffer (Ada_Prj_Path.all); Add_Str_To_Name_Buffer (Ada_Prj_Path.all);
end if; end if;
Free (Ada_Prj_Path);
-- Scan the directory path to see if "-" is one of the directories. -- Scan the directory path to see if "-" is one of the directories.
-- Remove each occurrence of "-" and set Add_Default_Dir to False. -- Remove each occurrence of "-" and set Add_Default_Dir to False.
-- Also resolve relative paths and symbolic links. -- Also resolve relative paths and symbolic links.
......
...@@ -34,10 +34,6 @@ package Prj.Ext is ...@@ -34,10 +34,6 @@ package Prj.Ext is
-- Project Path -- -- Project Path --
------------------ ------------------
Gpr_Project_Path : constant String := "GPR_PROJECT_PATH";
-- Name of primary env. variable that contain path name(s) of directories
-- where project files may reside.
procedure Add_Search_Project_Directory (Path : String); procedure Add_Search_Project_Directory (Path : String);
-- Add a directory to the project path. Directories added with this -- Add a directory to the project path. Directories added with this
-- procedure are added in order after the current directory and before -- procedure are added in order after the current directory and before
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment