[Ada] Simplify construction of a path to file
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 25 Mar 2022 23:11:35 +0000 (00:11 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 30 May 2022 08:29:04 +0000 (08:29 +0000)
Code cleanup; semantics is unaffected.

gcc/ada/

* osint.adb (Locate_File): Change variable to constant and
initialize it by concatenation of directory, file name and NUL.

gcc/ada/osint.adb

index a38ad78..eeedfcb 100644 (file)
@@ -1886,13 +1886,13 @@ package body Osint is
       end if;
 
       declare
-         Full_Name : String (1 .. Dir_Name'Length + Name'Length + 1);
+         Full_Name :
+           constant String (1 .. Dir_Name'Length + Name'Length + 1) :=
+           Dir_Name.all & Name & ASCII.NUL;
+         --  Use explicit bounds, because Dir_Name might be a substring whose
+         --  'First is not 1.
 
       begin
-         Full_Name (1 .. Dir_Name'Length) := Dir_Name.all;
-         Full_Name (Dir_Name'Length + 1 .. Full_Name'Last - 1) := Name;
-         Full_Name (Full_Name'Last) := ASCII.NUL;
-
          Attr.all := Unknown_Attributes;
 
          if not Is_Regular_File (Full_Name'Address, Attr) then