diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-01-18 20:27:02 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-01-18 20:27:02 +0100 |
commit | 6e45f40a47afe5fd25254d3730a6f73256879a17 (patch) | |
tree | 71bd250832427d69e85d79b2de9a5404ec23d799 /src | |
parent | c257d0fa8da01df60c993a95aba44cbafd68ac69 (diff) | |
download | ghdl-6e45f40a47afe5fd25254d3730a6f73256879a17.tar.gz ghdl-6e45f40a47afe5fd25254d3730a6f73256879a17.tar.bz2 ghdl-6e45f40a47afe5fd25254d3730a6f73256879a17.zip |
files_map: get rid of global Nam_Buffer use.
Diffstat (limited to 'src')
-rw-r--r-- | src/files_map.adb | 54 | ||||
-rw-r--r-- | src/files_map.ads | 4 | ||||
-rw-r--r-- | src/vhdl/translate/translation.adb | 3 |
3 files changed, 27 insertions, 34 deletions
diff --git a/src/files_map.adb b/src/files_map.adb index 3ca45260c..f422cbaff 100644 --- a/src/files_map.adb +++ b/src/files_map.adb @@ -121,8 +121,11 @@ package body Files_Map is function Get_Home_Directory return Name_Id is begin if Home_Dir = Null_Identifier then - GNAT.Directory_Operations.Get_Current_Dir (Nam_Buffer, Nam_Length); - Home_Dir := Get_Identifier; + declare + Dir : constant String := GNAT.Directory_Operations.Get_Current_Dir; + begin + Home_Dir := Get_Identifier (Dir); + end; end if; return Home_Dir; end Get_Home_Directory; @@ -579,30 +582,22 @@ package body Files_Map is return Res; end Get_Os_Time_Stamp; - function Get_Pathname - (Directory : Name_Id; Name : Name_Id; Add_Nul : Boolean) return String + function Get_Pathname (Directory : Name_Id; Name : Name_Id) return String is - L : Natural; + Filename : constant String := Image (Name); begin - Image (Name); - if not GNAT.OS_Lib.Is_Absolute_Path (Nam_Buffer (1 .. Nam_Length)) then - L := Nam_Length; - Image (Directory); - Nam_Buffer (Nam_Length + 1 .. Nam_Length + L) := Image (Name); - Nam_Length := Nam_Length + L; - end if; - if Add_Nul then - Nam_Length := Nam_Length + 1; - Nam_Buffer (Nam_Length) := Character'Val (0); + if not GNAT.OS_Lib.Is_Absolute_Path (Filename) then + return Image (Directory) & Filename; + else + return Filename; end if; - return Nam_Buffer (1 .. Nam_Length); end Get_Pathname; procedure Normalize_Pathname (Directory : in out Name_Id; Name : in out Name_Id) is - Separator_Pos : Natural; Filename : constant String := Image (Name); + Separator_Pos : Natural; begin -- Find a directory part in NAME, return now if none. Separator_Pos := 0; @@ -616,16 +611,16 @@ package body Files_Map is end if; -- Move the directory part to DIRECTORY. - if Directory /= Null_Identifier then - Image (Directory); - else - Nam_Length := 0; - end if; - for I in Filename'First .. Separator_Pos loop - Nam_Length := Nam_Length + 1; - Nam_Buffer (Nam_Length) := Filename (I); - end loop; - Directory := Get_Identifier; + declare + File_Dir : constant String := + Filename (Filename'First .. Separator_Pos); + begin + if Directory /= Null_Identifier then + Directory := Get_Identifier (Image (Directory) & File_Dir); + else + Directory := Get_Identifier (File_Dir); + end if; + end; Name := Get_Identifier (Filename (Separator_Pos + 1 .. Filename'Last)); end Normalize_Pathname; @@ -813,12 +808,13 @@ package body Files_Map is -- Open the file (punt on non regular files). declare - Filename : String := Get_Pathname (Directory, Name, True); + Filename : constant String := Get_Pathname (Directory, Name); + Filename0 : constant String := Filename & ASCII.NUL; begin if not Is_Regular_File (Filename) then return No_Source_File_Entry; end if; - Fd := Open_Read (Filename'Address, Binary); + Fd := Open_Read (Filename0'Address, Binary); if Fd = Invalid_FD then return No_Source_File_Entry; end if; diff --git a/src/files_map.ads b/src/files_map.ads index b6054c906..f09e5b6e0 100644 --- a/src/files_map.ads +++ b/src/files_map.ads @@ -32,9 +32,7 @@ package Files_Map is -- Create the path from DIRECTORY and NAME: -- If NAME is an absolute pathname, then return NAME. -- Otherwise, return the concatenation of DIRECTORY and NAME. - -- If ADD_NUL is TRUE, then a trailing '\0' is appended. - function Get_Pathname - (Directory : Name_Id; Name : Name_Id; Add_Nul : Boolean) return String; + function Get_Pathname (Directory : Name_Id; Name : Name_Id) return String; -- If NAME contains a directory separator, move it to the DIRECTORY name. -- At the return point, NAME has no directory components. diff --git a/src/vhdl/translate/translation.adb b/src/vhdl/translate/translation.adb index 86497bae5..9c3a3e2a5 100644 --- a/src/vhdl/translate/translation.adb +++ b/src/vhdl/translate/translation.adb @@ -272,8 +272,7 @@ package body Translation is declare Pathname : constant String := Files_Map.Get_Pathname (Get_Design_File_Directory (Design_File), - Get_Design_File_Filename (Design_File), - False); + Get_Design_File_Filename (Design_File)); begin New_Debug_Filename_Decl (Pathname); end; |