From 9f4b346b0b604183a7b2285df61961ebb4a4c582 Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Tue, 29 May 2018 09:28:59 +0000 Subject: [PATCH] [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 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 --- gcc/ada/ChangeLog | 9 +++++++++ gcc/ada/lib-writ.adb | 18 ++++++++++++------ gcc/ada/libgnat/s-casuti.adb | 21 +++++++++++++++++++++ gcc/ada/libgnat/s-casuti.ads | 3 +++ gcc/ada/osint.adb | 19 ++++++------------- 5 files changed, 51 insertions(+), 19 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index bd50727..b0bf034 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +2018-05-29 Bob Duff + + * 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 * repinfo.ads: Minor fixes and tweaks in comments. diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb index b861bad..9896a83 100644 --- a/gcc/ada/lib-writ.adb +++ b/gcc/ada/lib-writ.adb @@ -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); diff --git a/gcc/ada/libgnat/s-casuti.adb b/gcc/ada/libgnat/s-casuti.adb index 058798a..345ee8a 100644 --- a/gcc/ada/libgnat/s-casuti.adb +++ b/gcc/ada/libgnat/s-casuti.adb @@ -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; diff --git a/gcc/ada/libgnat/s-casuti.ads b/gcc/ada/libgnat/s-casuti.ads index f18d0e3..7df35f1 100644 --- a/gcc/ada/libgnat/s-casuti.ads +++ b/gcc/ada/libgnat/s-casuti.ads @@ -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. diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb index 896fbc7..e7644b1 100644 --- a/gcc/ada/osint.adb +++ b/gcc/ada/osint.adb @@ -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; -- 2.7.4