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>
* gnat_rm.texi, s-oscons-tmplt.c: Minor typo
......
......@@ -453,7 +453,6 @@ package body Makeutl is
is
Start : Positive := 3;
Finish : Natural := Argv'Last;
Equal_Pos : Natural;
pragma Assert (Argv'First = 1);
pragma Assert (Argv (1 .. 2) = "-X");
......@@ -471,21 +470,9 @@ package body Makeutl is
end if;
end if;
Equal_Pos := Start;
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,
External_Name => Argv (Start .. Equal_Pos - 1),
Value => Argv (Equal_Pos + 1 .. Finish));
return True;
end if;
return Prj.Ext.Check
(Tree => Tree,
Declaration => Argv (Start .. Finish));
end Is_External_Assignment;
---------------
......
......@@ -32,16 +32,6 @@ with Table;
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 := "-";
Current_Project_Path : String_Access;
......@@ -82,7 +72,6 @@ package body Prj.Ext is
Name_To_Name_HTable.Set (Tree.External_References, The_Key, The_Value);
end Add;
-----------
----------------------------------
-- Add_Search_Project_Directory --
----------------------------------
......@@ -104,7 +93,6 @@ package body Prj.Ext is
for Equal_Pos in Declaration'Range loop
if Declaration (Equal_Pos) = '=' then
exit when Equal_Pos = Declaration'First;
exit when Equal_Pos = Declaration'Last;
Add
(Tree => Tree,
External_Name =>
......@@ -129,6 +117,17 @@ package body Prj.Ext is
New_Len : 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
-- The current directory is always first
......@@ -152,12 +151,16 @@ package body Prj.Ext is
Add_Str_To_Name_Buffer (Gpr_Prj_Path.all);
end if;
Free (Gpr_Prj_Path);
if Ada_Prj_Path.all /= "" then
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := Path_Separator;
Add_Str_To_Name_Buffer (Ada_Prj_Path.all);
end if;
Free (Ada_Prj_Path);
-- Scan the directory path to see if "-" is one of the directories.
-- Remove each occurrence of "-" and set Add_Default_Dir to False.
-- Also resolve relative paths and symbolic links.
......
......@@ -34,10 +34,6 @@ package Prj.Ext is
-- 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);
-- Add a directory to the project path. Directories added with this
-- 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