begin
-- Check if the directory is already in the table
- for Index in Object_Path_Table.First ..
- Object_Path_Table.Last (Object_Paths)
+ for Index in
+ Object_Path_Table.First .. Object_Path_Table.Last (Object_Paths)
loop
-- If it is, remove it, and add it as the last one
if Object_Paths.Table (Index) = Object_Dir then
- for Index2 in Index + 1 ..
- Object_Path_Table.Last (Object_Paths)
+ for Index2 in
+ Index + 1 .. Object_Path_Table.Last (Object_Paths)
loop
Object_Paths.Table (Index2 - 1) := Object_Paths.Table (Index2);
end loop;
-- Check if the source directory is already in the table
- for Index in Source_Path_Table.First ..
- Source_Path_Table.Last (Source_Paths)
+ for Index in
+ Source_Path_Table.First .. Source_Path_Table.Last (Source_Paths)
loop
-- If it is already, no need to add it
Table_Low_Bound => 1,
Table_Initial => 5,
Table_Increment => 100);
+
Default_Naming : constant Naming_Id := Naming_Table.First;
Namings : Naming_Table.Instance;
-- Table storing the naming data for gnatmake/gprmake
if not Source.Locally_Removed
and then Source.Unit /= null
and then
- (Source.Index >= 1 or else Source.Naming_Exception)
+ (Source.Index >= 1 or else Source.Naming_Exception /= No)
then
Put (Source);
end if;
In_Tree : Project_Tree_Ref;
Name : out Path_Name_Type)
is
- File : File_Descriptor := Invalid_FD;
-
- Buffer : String_Access := new String (1 .. Buffer_Initial);
- Buffer_Last : Natural := 0;
+ File : File_Descriptor := Invalid_FD;
+ Buffer : String_Access := new String (1 .. Buffer_Initial);
+ Buffer_Last : Natural := 0;
procedure Put_Name_Buffer;
-- Put the line contained in the Name_Buffer in the global buffer
if Source.Replaced_By = No_Source
and then Source.Path.Name /= No_Path
- and then
- (Source.Language.Config.Kind = File_Based
- or else Source.Unit /= No_Unit_Index)
+ and then (Source.Language.Config.Kind = File_Based
+ or else Source.Unit /= No_Unit_Index)
then
if Source.Unit /= No_Unit_Index then
- Get_Name_String (Source.Unit.Name);
+
+ -- Put the encoded unit name in the name buffer
+
+ declare
+ Uname : constant String :=
+ Get_Name_String (Source.Unit.Name);
+
+ begin
+ Name_Len := 0;
+ for J in Uname'Range loop
+ if Uname (J) in Upper_Half_Character then
+ Store_Encoded_Character (Get_Char_Code (Uname (J)));
+ else
+ Add_Char_To_Name_Buffer (Uname (J));
+ end if;
+ end loop;
+ end;
if Source.Language.Config.Kind = Unit_Based then
end case;
if Suffix /= No_File then
- Add_Str_To_Name_Buffer
- (Get_Name_String (Suffix));
+ Add_Str_To_Name_Buffer (Get_Name_String (Suffix));
end if;
end if;
procedure For_Every_Imported_Project is new
For_Every_Project_Imported (State => Integer, Action => Process);
+ -- Local variables
+
Dummy : Integer := 0;
-- Start of processing for Create_Mapping_File
Main_Project_Only : Boolean := True;
Full_Path : Boolean := False) return String
is
+
+ Lang : constant Language_Ptr :=
+ Get_Language_From_Name (Project, "ada");
The_Project : Project_Id := Project;
Original_Name : String := Name;
- Lang : constant Language_Ptr :=
- Get_Language_From_Name (Project, "ada");
-
Unit : Unit_Index;
The_Original_Name : Name_Id;
The_Spec_Name : Name_Id;
-- Check for spec
if not Main_Project_Only
- or else
- (Unit.File_Names (Spec) /= null
- and then Unit.File_Names (Spec).Project =
- The_Project)
+ or else (Unit.File_Names (Spec) /= null
+ and then Unit.File_Names (Spec).Project = The_Project)
then
declare
Current_Name : File_Name_Type;
while Unit /= null loop
if Unit.File_Names (Spec) /= null
+ and then not Unit.File_Names (Spec).Locally_Removed
and then Unit.File_Names (Spec).File /= No_File
and then
(Namet.Get_Name_String
- (Unit.File_Names (Spec).File) = Original_Name
- or else (Unit.File_Names (Spec).Path /=
- No_Path_Information
+ (Unit.File_Names (Spec).File) = Original_Name
+ or else (Unit.File_Names (Spec).Path /= No_Path_Information
and then
Namet.Get_Name_String
- (Unit.File_Names (Spec).Path.Name) =
- Original_Name))
+ (Unit.File_Names (Spec).Path.Name) =
+ Original_Name))
then
- Project := Ultimate_Extending_Project_Of
- (Unit.File_Names (Spec).Project);
+ Project :=
+ Ultimate_Extending_Project_Of
+ (Unit.File_Names (Spec).Project);
Path := Unit.File_Names (Spec).Path.Display_Name;
if Current_Verbosity > Default then
elsif Unit.File_Names (Impl) /= null
and then Unit.File_Names (Impl).File /= No_File
+ and then not Unit.File_Names (Impl).Locally_Removed
and then
(Namet.Get_Name_String
(Unit.File_Names (Impl).File) = Original_Name
- or else (Unit.File_Names (Impl).Path /=
- No_Path_Information
- and then Namet.Get_Name_String
- (Unit.File_Names (Impl).Path.Name) =
- Original_Name))
+ or else (Unit.File_Names (Impl).Path /= No_Path_Information
+ and then Namet.Get_Name_String
+ (Unit.File_Names (Impl).Path.Name) =
+ Original_Name))
then
- Project := Ultimate_Extending_Project_Of
- (Unit.File_Names (Impl).Project);
+ Project :=
+ Ultimate_Extending_Project_Of
+ (Unit.File_Names (Impl).Project);
Path := Unit.File_Names (Impl).Path.Display_Name;
if Current_Verbosity > Default then
if Source_FD /= Invalid_FD then
Buffer_Last := 0;
- for Index in Source_Path_Table.First ..
- Source_Path_Table.Last (Source_Paths)
+ for Index in
+ Source_Path_Table.First .. Source_Path_Table.Last (Source_Paths)
loop
Get_Name_String (Source_Paths.Table (Index));
Name_Len := Name_Len + 1;
if Object_FD /= Invalid_FD then
Buffer_Last := 0;
- for Index in Object_Path_Table.First ..
- Object_Path_Table.Last (Object_Paths)
+ for Index in
+ Object_Path_Table.First .. Object_Path_Table.Last (Object_Paths)
loop
Get_Name_String (Object_Paths.Table (Index));
Name_Len := Name_Len + 1;
-- Set the env vars, if they need to be changed, and set the
-- corresponding flags.
- if Include_Path and then
- Shared.Private_Part.Current_Source_Path_File /=
- Project.Include_Path_File
+ if Include_Path
+ and then
+ Shared.Private_Part.Current_Source_Path_File /=
+ Project.Include_Path_File
then
Shared.Private_Part.Current_Source_Path_File :=
Project.Include_Path_File;
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;
- return Result;
- end Try_Path_Name;
+ First := Last + 1;
+ end loop;
+ end if;
+
+ return null;
+ end Find_Name_In_Path;
+
+ ------------------
+ -- 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
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
end if;
-- No need to copy the Cache, it will be recomputed as needed
-
end Copy;
end Prj.Env;