]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Simplify string manipulation related to preprocessing
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 24 May 2021 13:27:28 +0000 (15:27 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 8 Jul 2021 13:34:16 +0000 (13:34 +0000)
gcc/ada/

* sinput-l.adb (Load_File): Simplify foreword manipulation with
concatenation; similar for filename with preprocessed output.

gcc/ada/sinput-l.adb

index 102f3638abc57143c1f242c31996157b230fabd6..2d5efb004244cebd799a51024a51641ba2189515 100644 (file)
@@ -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;