From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 65B3C3857429 for ; Mon, 7 Nov 2022 08:40:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 65B3C3857429 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x430.google.com with SMTP id cl5so15022346wrb.9 for ; Mon, 07 Nov 2022 00:40:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xQpTLC6E1PRuW/0kD3SuI3KMgBpS6j8V/VqnCLl4Sg4=; b=dvKuSL5SIxv5EnzO2IplHmJcsYC16KnTNrqvE88vvO1iPW3tu4cqsb2x8/PPw3QR9E NecFmzxzNPfUPI4ojkXFZJF1tgth0Ibjs6uH+DeQEKKYxlrPw/EJUY1UP1sZuxBzlkz9 HRhfM5iXslb9ciawOrHZ0dBNId3039Wo/054tHxCT3AOG2LtMxAQkkqMulj/nGjkn0+c NY4LG4+i8TOofLTwcPMtPHUG+XaICSds2tVXNQDULF0fiNp3vv9Iyzn7unnyBEPQY/wR +pUz0Lnk2Q+uIU6mKkYoRAeDxr7bieRX3Tp+z7LePrMRPijj57SWiG1oQKjJIuNXz+/5 C5GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xQpTLC6E1PRuW/0kD3SuI3KMgBpS6j8V/VqnCLl4Sg4=; b=lSI3E59Q4uAUlgcNWSFrF1kgqsrAH95zb4nC/bVBCKOcVNa8Ey9fgGz2YvYTsEHVDY x72kvDsTA36Mtb9VH4/RQTvf+TbUdyzZCEqoO6YF5iNEM5GPdZbTHZFEQr0pJhDYoUuV aKXngMJDFyhMHKbQLVrNmxi7Rs3+Ds58X17NImZvyLndibilgqUyZirpgWd+nUu5gIMj jplbNsqFndfXNLqiBuZVmfKK7b4NkPMIFuIPSSMtqmHdqi+F38CCn8DWTUz72wtp0WWb DDMqdqTqgrLECjNMZ57mCoIRHIJoZd4YKGbJfoZd83/lsLvFgu7Vmt8AlNC6omPvm5nm 8/lw== X-Gm-Message-State: ACrzQf3KnaIkm4byunnrqOL7MbMYQ9hRs/x31z8yLoo21ah7V9Zv+IAO UjDF2r7+inE9sbkAdXDaMFTGR/E5E+pxrg== X-Google-Smtp-Source: AMsMyM6ycF0O1xJtMgtN9AqwKg5yP9OtEE1DFwQRjxLXB4yEq6vJjxRIj3gjZJfCVwOUz0DIL4OQnQ== X-Received: by 2002:a05:6000:43:b0:236:d95e:2be with SMTP id k3-20020a056000004300b00236d95e02bemr24086344wrx.478.1667810453310; Mon, 07 Nov 2022 00:40:53 -0800 (PST) Received: from poulhies-Precision-5550.lan (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id q12-20020a5d61cc000000b002238ea5750csm7877845wrv.72.2022.11.07.00.40.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 00:40:52 -0800 (PST) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Clean up unnecessary nesting in code for DLL libraries Date: Mon, 7 Nov 2022 09:40:50 +0100 Message-Id: <20221107084050.151435-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Piotr Trojanek Code cleanup; issue spotted while examining routines with No_ prefix. gcc/ada/ * mdll.ads (Build_Import_Library): Fix grammar in comment. * mdll.adb (Build_Import_Library): Directly execute code of a nested routine; rename No_Lib_Prefix to Strip_Lib_Prefix. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/mdll.adb | 68 ++++++++++++++++++------------------------------ gcc/ada/mdll.ads | 4 +-- 2 files changed, 28 insertions(+), 44 deletions(-) diff --git a/gcc/ada/mdll.adb b/gcc/ada/mdll.adb index 2107994e5c0..88f8f96927c 100644 --- a/gcc/ada/mdll.adb +++ b/gcc/ada/mdll.adb @@ -448,57 +448,41 @@ package body MDLL is (Lib_Filename : String; Def_Filename : String) is - procedure Build_Import_Library (Lib_Filename : String); - -- Build an import library. This is to build only a .a library to link - -- against a DLL. + function Strip_Lib_Prefix (Filename : String) return String; + -- Return Filename without the lib prefix if present - -------------------------- - -- Build_Import_Library -- - -------------------------- - - procedure Build_Import_Library (Lib_Filename : String) is - - function No_Lib_Prefix (Filename : String) return String; - -- Return Filename without the lib prefix if present - - ------------------- - -- No_Lib_Prefix -- - ------------------- - - function No_Lib_Prefix (Filename : String) return String is - begin - if Filename (Filename'First .. Filename'First + 2) = "lib" then - return Filename (Filename'First + 3 .. Filename'Last); - else - return Filename; - end if; - end No_Lib_Prefix; - - -- Local variables - - Def_File : String renames Def_Filename; - Dll_File : constant String := Get_Dll_Name (Lib_Filename); - Base_Filename : constant String := - MDLL.Fil.Ext_To (No_Lib_Prefix (Lib_Filename)); - Lib_File : constant String := "lib" & Base_Filename & ".dll.a"; - - -- Start of processing for Build_Import_Library + ---------------------- + -- Strip_Lib_Prefix -- + ---------------------- + function Strip_Lib_Prefix (Filename : String) return String is begin - if not Quiet then - Text_IO.Put_Line ("Building import library..."); - Text_IO.Put_Line - ("make " & Lib_File & " to use dynamic library " & Dll_File); + if Filename (Filename'First .. Filename'First + 2) = "lib" then + return Filename (Filename'First + 3 .. Filename'Last); + else + return Filename; end if; + end Strip_Lib_Prefix; - Utl.Dlltool - (Def_File, Dll_File, Lib_File, Build_Import => True); - end Build_Import_Library; + -- Local variables + + Def_File : String renames Def_Filename; + Dll_File : constant String := Get_Dll_Name (Lib_Filename); + Base_Filename : constant String := + MDLL.Fil.Ext_To (Strip_Lib_Prefix (Lib_Filename)); + Lib_File : constant String := "lib" & Base_Filename & ".dll.a"; -- Start of processing for Build_Import_Library begin - Build_Import_Library (Lib_Filename); + if not Quiet then + Text_IO.Put_Line ("Building import library..."); + Text_IO.Put_Line + ("make " & Lib_File & " to use dynamic library " & Dll_File); + end if; + + Utl.Dlltool + (Def_File, Dll_File, Lib_File, Build_Import => True); end Build_Import_Library; ------------------ diff --git a/gcc/ada/mdll.ads b/gcc/ada/mdll.ads index 110eb31b001..9f080c0cafe 100644 --- a/gcc/ada/mdll.ads +++ b/gcc/ada/mdll.ads @@ -74,7 +74,7 @@ package MDLL is procedure Build_Import_Library (Lib_Filename : String; Def_Filename : String); - -- Build an import library (.a) from a definition files. An import library - -- is needed to link against a DLL. + -- Build an import library (.a) from definition files. An import library is + -- needed to link against a DLL. end MDLL; -- 2.34.1