* [Ada] Simplify construction of a path to file
@ 2022-05-30 8:32 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-30 8:32 UTC (permalink / raw)
To: gcc-patches; +Cc: Piotr Trojanek
[-- Attachment #1: Type: text/plain, Size: 225 bytes --]
Code cleanup; semantics is unaffected.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* osint.adb (Locate_File): Change variable to constant and
initialize it by concatenation of directory, file name and NUL.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 808 bytes --]
diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb
--- a/gcc/ada/osint.adb
+++ b/gcc/ada/osint.adb
@@ -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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-30 8:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-30 8:32 [Ada] Simplify construction of a path to file Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).