From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id 4C0D1398B879; Thu, 8 Jul 2021 13:35:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C0D1398B879 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-2140] [Ada] Simplify string manipulation related to preprocessing X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/master X-Git-Oldrev: 2e9ef3929b0305235b968c431c8d7fec92885101 X-Git-Newrev: 999a2dd00d3cb8127bc1e7a2a5264d2131c92242 Message-Id: <20210708133553.4C0D1398B879@sourceware.org> Date: Thu, 8 Jul 2021 13:35:53 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jul 2021 13:35:53 -0000 https://gcc.gnu.org/g:999a2dd00d3cb8127bc1e7a2a5264d2131c92242 commit r12-2140-g999a2dd00d3cb8127bc1e7a2a5264d2131c92242 Author: Piotr Trojanek Date: Mon May 24 15:27:28 2021 +0200 [Ada] Simplify string manipulation related to preprocessing gcc/ada/ * sinput-l.adb (Load_File): Simplify foreword manipulation with concatenation; similar for filename with preprocessed output. Diff: --- gcc/ada/sinput-l.adb | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/gcc/ada/sinput-l.adb b/gcc/ada/sinput-l.adb index 102f3638abc..2d5efb00424 100644 --- a/gcc/ada/sinput-l.adb +++ b/gcc/ada/sinput-l.adb @@ -551,19 +551,10 @@ package body Sinput.L is Set_Source_File_Index_Table (X); if Opt.List_Preprocessing_Symbols then - Get_Name_String (N); - declare - Foreword : String (1 .. Foreword_Start'Length + - Name_Len + Foreword_End'Length); - + Foreword : constant String := + Foreword_Start & Get_Name_String (N) & Foreword_End; begin - Foreword (1 .. Foreword_Start'Length) := Foreword_Start; - Foreword (Foreword_Start'Length + 1 .. - Foreword_Start'Length + Name_Len) := - Name_Buffer (1 .. Name_Len); - Foreword (Foreword'Last - Foreword_End'Length + 1 .. - Foreword'Last) := Foreword_End; Prep.List_Symbols (Foreword); end; end if; @@ -654,14 +645,13 @@ package body Sinput.L is NB : Integer; Status : Boolean; - begin - Get_Name_String (N); - Add_Str_To_Name_Buffer (Prep_Suffix); + Prep_Filename : constant String := + Get_Name_String (N) & Prep_Suffix; - Delete_File (Name_Buffer (1 .. Name_Len), Status); + begin + Delete_File (Prep_Filename, Status); - FD := - Create_New_File (Name_Buffer (1 .. Name_Len), Text); + FD := Create_New_File (Prep_Filename, Text); Status := FD /= Invalid_FD;