public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-848] [Ada] Simplify construction of a path to file
Date: Mon, 30 May 2022 08:31:48 +0000 (GMT)	[thread overview]
Message-ID: <20220530083148.F317F3815FFB@sourceware.org> (raw)

https://gcc.gnu.org/g:263cb16b7667ba92fbac3098375aecfb7f80105e

commit r13-848-g263cb16b7667ba92fbac3098375aecfb7f80105e
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Sat Mar 26 00:11:35 2022 +0100

    [Ada] Simplify construction of a path to file
    
    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.

Diff:
---
 gcc/ada/osint.adb | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb
index a38ad7874e3..eeedfcbc3ae 100644
--- 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


                 reply	other threads:[~2022-05-30  8:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220530083148.F317F3815FFB@sourceware.org \
    --to=pmderodat@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).