From patchwork Tue May 29 09:47:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 921908 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-478638-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="uftm8Ho3"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40w8692JfRz9s0y for ; Tue, 29 May 2018 19:47:44 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=JyxUNdN+7vY2AVeQup4+E8TI9caoj5rf7BN4xvpYASQVDhyTv2 CQxbrh+2Q/ARJ31ZLs6mXkcuy7O7TeDm+TfcQSM6sxdMkpKTC58tyv2R+Bn0HKTl LZdOIUqG5FAlKZd7F1xai2FLanSetI1b3T2p3/jm+l5oCmnWxZQIEA1Kg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=XOmrzGwDxuTpEyaKdkOglne9BQU=; b=uftm8Ho32ceoLzIE0VAk tlr/SnjfwegEPTWLkTlRhQ7E/QZm7H478Hf3DD4bgnzyC4y8QblWlunAspP7UUWY dO5MjjELlo+TYLnu29yiq7DsFiSZNSgYJvfaHYlJtAgTVcjNLKoBdbHGhB76aaAR 6ywo/6yE6VyOJ7n2JMrf8Eo= Received: (qmail 113014 invoked by alias); 29 May 2018 09:47:36 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 112990 invoked by uid 89); 29 May 2018 09:47:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=sind, Hx-languages-length:5119 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 May 2018 09:47:33 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 5BE4D56006; Tue, 29 May 2018 05:47:32 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id XYy2ohHdUgpf; Tue, 29 May 2018 05:47:32 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 46DE856001; Tue, 29 May 2018 05:47:32 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 433CE78A; Tue, 29 May 2018 05:47:32 -0400 (EDT) Date: Tue, 29 May 2018 05:47:32 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] Preliminary work to avoid full pathnames in ALI files Message-ID: <20180529094732.GA104843@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes 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. Tested on x86_64-pc-linux-gnu, committed on trunk 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. --- gcc/ada/lib-writ.adb +++ 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); --- gcc/ada/libgnat/s-casuti.adb +++ 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; --- gcc/ada/libgnat/s-casuti.ads +++ 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. --- gcc/ada/osint.adb +++ 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;