diff options
author | aldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-08 03:20:30 +0000 |
---|---|---|
committer | aldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-08 03:20:30 +0000 |
commit | 643df0593c630691fa6877cddeefdd4c3023d444 (patch) | |
tree | 1eb48ad31d05a9ce117bedc17115de96dffa2f0b /gcc/ada/prj-env.adb | |
parent | 54f3f029d816c6d1626310649adfda740e203f7b (diff) | |
parent | d5d8f1ccc6d3972dc5cfc0949e85e0b1c9e24ee0 (diff) | |
download | gcc-transactional-memory.tar.gz |
* Merge from mainline rev 181122.transactional-memory
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/transactional-memory@181148 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/prj-env.adb')
-rw-r--r-- | gcc/ada/prj-env.adb | 154 |
1 files changed, 79 insertions, 75 deletions
diff --git a/gcc/ada/prj-env.adb b/gcc/ada/prj-env.adb index 9f29313a0b6..898ba8dfa35 100644 --- a/gcc/ada/prj-env.adb +++ b/gcc/ada/prj-env.adb @@ -2058,91 +2058,93 @@ package body Prj.Env is Projects_Paths.Reset (Self.Cache); end Set_Path; - ------------------ - -- Find_Project -- - ------------------ + ----------------------- + -- Find_Name_In_Path -- + ----------------------- - procedure Find_Project - (Self : in out Project_Search_Path; - Project_File_Name : String; - Directory : String; - Path : out Namet.Path_Name_Type) + function Find_Name_In_Path + (Self : Project_Search_Path; + Path : String) return String_Access is - File : constant String := Project_File_Name; - -- Have to do a copy, in case the parameter is Name_Buffer, which we - -- modify below + First : Natural; + Last : Natural; - function Try_Path_Name (Path : String) return String_Access; - pragma Inline (Try_Path_Name); - -- Try the specified Path + begin + if Current_Verbosity = High then + Debug_Output ("Trying " & Path); + end if; - ------------------- - -- Try_Path_Name -- - ------------------- + if Is_Absolute_Path (Path) then + if Check_Filename (Path) then + return new String'(Path); + else + return null; + end if; - function Try_Path_Name (Path : String) return String_Access is - First : Natural; - Last : Natural; - Result : String_Access := null; + else + -- Because we don't want to resolve symbolic links, we cannot use + -- Locate_Regular_File. So, we try each possible path successively. - begin - if Current_Verbosity = High then - Debug_Output ("Trying " & Path); - end if; + First := Self.Path'First; + while First <= Self.Path'Last loop + while First <= Self.Path'Last + and then Self.Path (First) = Path_Separator + loop + First := First + 1; + end loop; - if Is_Absolute_Path (Path) then - if Is_Regular_File (Path) then - Result := new String'(Path); - end if; + exit when First > Self.Path'Last; - else - -- Because we don't want to resolve symbolic links, we cannot use - -- Locate_Regular_File. So, we try each possible path - -- successively. - - First := Self.Path'First; - while First <= Self.Path'Last loop - while First <= Self.Path'Last - and then Self.Path (First) = Path_Separator - loop - First := First + 1; - end loop; - - exit when First > Self.Path'Last; - - Last := First; - while Last < Self.Path'Last - and then Self.Path (Last + 1) /= Path_Separator - loop - Last := Last + 1; - end loop; - - Name_Len := 0; - - if not Is_Absolute_Path (Self.Path (First .. Last)) then - Add_Str_To_Name_Buffer (Get_Current_Dir); -- ??? System call - Add_Char_To_Name_Buffer (Directory_Separator); - end if; + Last := First; + while Last < Self.Path'Last + and then Self.Path (Last + 1) /= Path_Separator + loop + Last := Last + 1; + end loop; - Add_Str_To_Name_Buffer (Self.Path (First .. Last)); + Name_Len := 0; + + if not Is_Absolute_Path (Self.Path (First .. Last)) then + Add_Str_To_Name_Buffer (Get_Current_Dir); -- ??? System call Add_Char_To_Name_Buffer (Directory_Separator); - Add_Str_To_Name_Buffer (Path); + end if; - if Current_Verbosity = High then - Debug_Output ("Testing file " & Name_Buffer (1 .. Name_Len)); - end if; + Add_Str_To_Name_Buffer (Self.Path (First .. Last)); + Add_Char_To_Name_Buffer (Directory_Separator); + Add_Str_To_Name_Buffer (Path); - if Is_Regular_File (Name_Buffer (1 .. Name_Len)) then - Result := new String'(Name_Buffer (1 .. Name_Len)); - exit; - end if; + if Current_Verbosity = High then + Debug_Output ("Testing file " & Name_Buffer (1 .. Name_Len)); + end if; - First := Last + 1; - end loop; - end if; + if Check_Filename (Name_Buffer (1 .. Name_Len)) then + return new String'(Name_Buffer (1 .. Name_Len)); + end if; + + First := Last + 1; + end loop; + end if; + + return null; + end Find_Name_In_Path; - return Result; - end Try_Path_Name; + ------------------ + -- Find_Project -- + ------------------ + + procedure Find_Project + (Self : in out Project_Search_Path; + Project_File_Name : String; + Directory : String; + Path : out Namet.Path_Name_Type) + is + File : constant String := Project_File_Name; + -- Have to do a copy, in case the parameter is Name_Buffer, which we + -- modify below + + function Try_Path_Name is new Find_Name_In_Path + (Check_Filename => Is_Regular_File); + -- Find a file in the project search path. -- Local Declarations @@ -2194,27 +2196,29 @@ package body Prj.Env is if not Has_Dot then Result := Try_Path_Name - (Directory & Directory_Separator & + (Self, + Directory & Directory_Separator & File & Project_File_Extension); end if; -- Then we try <directory>/<file_name> if Result = null then - Result := Try_Path_Name (Directory & Directory_Separator & File); + Result := Try_Path_Name + (Self, Directory & Directory_Separator & File); end if; end if; -- Then we try <file_name>.<extension> if Result = null and then not Has_Dot then - Result := Try_Path_Name (File & Project_File_Extension); + Result := Try_Path_Name (Self, File & Project_File_Extension); end if; -- Then we try <file_name> if Result = null then - Result := Try_Path_Name (File); + Result := Try_Path_Name (Self, File); end if; -- If we cannot find the project file, we return an empty string |