===================================================================
@@ -2229,20 +2229,21 @@
Directory : String;
Path : out Namet.Path_Name_Type)
is
+ Result : String_Access;
+ Has_Dot : Boolean := False;
+ Key : Name_Id;
+
File : constant String := Project_File_Name;
-- Have to do a copy, in case the parameter is Name_Buffer, which we
- -- modify below
+ -- modify below.
- function Try_Path_Name is new Find_Name_In_Path
- (Check_Filename => Is_Regular_File);
+ Cached_Path : Namet.Path_Name_Type;
+ -- This should be commented rather than making us guess from the name???
+
+ 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
-
- Result : String_Access;
- Has_Dot : Boolean := False;
- Key : Name_Id;
-
-- Start of processing for Find_Project
begin
@@ -2259,13 +2260,8 @@
Name_Len := File'Length;
Name_Buffer (1 .. Name_Len) := File;
Key := Name_Find;
- Path := Projects_Paths.Get (Self.Cache, Key);
+ Cached_Path := Projects_Paths.Get (Self.Cache, Key);
- if Path /= No_Path then
- Debug_Decrease_Indent;
- return;
- end if;
-
-- Check if File contains an extension (a dot before a
-- directory separator). If it is the case we do not try project file
-- with an added extension as it is not possible to have multiple dots
@@ -2283,13 +2279,42 @@
if not Is_Absolute_Path (File) then
+ -- If we have found project in the cache, check if in the directory
+
+ if Cached_Path /= No_Path then
+ declare
+ Cached : constant String := Get_Name_String (Cached_Path);
+ begin
+ if (not Has_Dot
+ and then Cached =
+ GNAT.OS_Lib.Normalize_Pathname
+ (File & Project_File_Extension,
+ Directory => Directory,
+ Resolve_Links => Opt.Follow_Links_For_Files,
+ Case_Sensitive => True))
+ or else
+ Cached =
+ GNAT.OS_Lib.Normalize_Pathname
+ (File,
+ Directory => Directory,
+ Resolve_Links => Opt.Follow_Links_For_Files,
+ Case_Sensitive => True)
+ then
+ Path := Cached_Path;
+ Debug_Decrease_Indent;
+ return;
+ end if;
+ end;
+ end if;
+
-- First we try <directory>/<file_name>.<extension>
if not Has_Dot then
- Result := Try_Path_Name
- (Self,
- Directory & Directory_Separator &
- File & Project_File_Extension);
+ Result :=
+ Try_Path_Name
+ (Self,
+ Directory & Directory_Separator &
+ File & Project_File_Extension);
end if;
-- Then we try <directory>/<file_name>
@@ -2300,6 +2325,14 @@
end if;
end if;
+ -- If we found the path in the cache, this is the one
+
+ if Result = null and then Cached_Path /= No_Path then
+ Path := Cached_Path;
+ Debug_Decrease_Indent;
+ return;
+ end if;
+
-- Then we try <file_name>.<extension>
if Result = null and then not Has_Dot then