Commit 9f4b346b by Bob Duff Committed by Pierre-Marie de Rodat

[Ada] Preliminary work to avoid full pathnames in ALI files

Normally, ALI files refer to source files using simple names. This allows files
to be moved around without disturbing things (causing extra recompilations,
etc). However, for configuration files, the full pathname is stored. This patch
preparates the code base to store the simple name in this case.

2018-05-29  Bob Duff  <duff@adacore.com>

gcc/ada/

	* lib-writ.adb (Write_ALI): Cleanup: avoid use of global var; call new
	To_Lower function.
	* libgnat/s-casuti.ads, libgnat/s-casuti.adb (To_Upper, To_Lower,
	To_Mixed): New functions.
	* osint.adb: Cleanup: use Is_Directory_Separator, which correctly
	allows both '\' and '/' on Windows.

From-SVN: r260860
parent 0c46b426
2018-05-29 Bob Duff <duff@adacore.com>
* lib-writ.adb (Write_ALI): Cleanup: avoid use of global var; call new
To_Lower function.
* libgnat/s-casuti.ads, libgnat/s-casuti.adb (To_Upper, To_Lower,
To_Mixed): New functions.
* osint.adb: Cleanup: use Is_Directory_Separator, which correctly
allows both '\' and '/' on Windows.
2018-05-28 Eric Botcazou <ebotcazou@adacore.com>
* repinfo.ads: Minor fixes and tweaks in comments.
......
......@@ -1539,15 +1539,21 @@ package body Lib.Writ is
-- Normal case of a unit entry with a source index
if Sind > No_Source_File then
Fname := File_Name (Sind);
-- We never want directory information in ALI files
-- ???But back out this change temporarily until
-- gprbuild is fixed.
-- Ensure that on platforms where the file names are not case
-- sensitive, the recorded file name is in lower case.
if False then
Fname := Strip_Directory (File_Name (Sind));
else
Fname := File_Name (Sind);
end if;
-- Ensure that on platforms where the file names are not
-- case sensitive, the recorded file name is in lower case.
if not File_Names_Case_Sensitive then
Get_Name_String (Fname);
To_Lower (Name_Buffer (1 .. Name_Len));
Fname := Name_Find;
Fname := Name_Find (To_Lower (Get_Name_String (Fname)));
end if;
Write_Info_Name_May_Be_Quoted (Fname);
......
......@@ -58,6 +58,13 @@ package body System.Case_Util is
end loop;
end To_Lower;
function To_Lower (A : String) return String is
Result : String := A;
begin
To_Lower (Result);
return Result;
end To_Lower;
--------------
-- To_Mixed --
--------------
......@@ -77,6 +84,13 @@ package body System.Case_Util is
end loop;
end To_Mixed;
function To_Mixed (A : String) return String is
Result : String := A;
begin
To_Mixed (Result);
return Result;
end To_Mixed;
--------------
-- To_Upper --
--------------
......@@ -102,4 +116,11 @@ package body System.Case_Util is
end loop;
end To_Upper;
function To_Upper (A : String) return String is
Result : String := A;
begin
To_Upper (Result);
return Result;
end To_Upper;
end System.Case_Util;
......@@ -49,6 +49,7 @@ package System.Case_Util is
-- returns the input argument unchanged.
procedure To_Upper (A : in out String);
function To_Upper (A : String) return String;
-- Folds all characters of string A to upper case
function To_Lower (A : Character) return Character;
......@@ -56,9 +57,11 @@ package System.Case_Util is
-- returns the input argument unchanged.
procedure To_Lower (A : in out String);
function To_Lower (A : String) return String;
-- Folds all characters of string A to lower case
procedure To_Mixed (A : in out String);
function To_Mixed (A : String) return String;
-- Converts A to mixed case (i.e. lower case, except for initial
-- character and any character after an underscore, which are
-- converted to upper case.
......
......@@ -830,9 +830,7 @@ package body Osint is
Add_Suffix := False;
exit;
elsif Name_Buffer (J) = '/' or else
Name_Buffer (J) = Directory_Separator
then
elsif Is_Directory_Separator (Name_Buffer (J)) then
exit;
end if;
end loop;
......@@ -905,9 +903,7 @@ package body Osint is
Add_Suffix := False;
exit;
elsif Canonical_Name (J) = '/' or else
Canonical_Name (J) = Directory_Separator
then
elsif Is_Directory_Separator (Canonical_Name (J)) then
exit;
end if;
end loop;
......@@ -1501,7 +1497,7 @@ package body Osint is
-- Add a directory separator at the end of the directory if necessary
-- so that we can directly append a file to the directory
if Search_Dir (Search_Dir'Last) /= Directory_Separator then
if not Is_Directory_Separator (Search_Dir (Search_Dir'Last)) then
Local_Search_Dir :=
new String'(Search_Dir & String'(1 => Directory_Separator));
else
......@@ -1553,7 +1549,7 @@ package body Osint is
raise Program_Error;
end if;
if Buffer (Path_Len) /= Directory_Separator then
if not Is_Directory_Separator (Buffer (Path_Len)) then
Path_Len := Path_Len + 1;
Buffer (Path_Len) := Directory_Separator;
end if;
......@@ -1964,9 +1960,7 @@ package body Osint is
Fptr := File_Name'First;
for J in reverse File_Name'Range loop
if File_Name (J) = Directory_Separator
or else File_Name (J) = '/'
then
if Is_Directory_Separator (File_Name (J)) then
if J = File_Name'Last then
Fail ("File name missing");
end if;
......@@ -2221,8 +2215,7 @@ package body Osint is
-- Ditto for suffix, e.g. in "gcc-4.1", the suffix is "-4.1"
for J in reverse 1 .. Name_Len loop
if Name_Buffer (J) = '/'
or else Name_Buffer (J) = Directory_Separator
if Is_Directory_Separator (Name_Buffer (J))
or else Name_Buffer (J) = ':'
then
Start_Of_Prefix := J + 1;
......
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