From patchwork Mon Nov 7 08:40:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 16313 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1921575wru; Mon, 7 Nov 2022 00:49:23 -0800 (PST) X-Google-Smtp-Source: AMsMyM4M6cfiS6IQqHtXhV9cQonO7GAa8tIpEnX/LDeK4EqtXUAxX1vE/fQurf+h0PO/84qpJTnn X-Received: by 2002:a05:6402:540d:b0:450:bda7:f76e with SMTP id ev13-20020a056402540d00b00450bda7f76emr28218944edb.249.1667810963584; Mon, 07 Nov 2022 00:49:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667810963; cv=none; d=google.com; s=arc-20160816; b=zeP96Zx93epUX38JFpEk/nNShDnawMcEArPHvkecMGbVqEyvq/16KCKqZUDp9CVMoL GJ9f9szVrHBK+kCSPt+b/mbfIJ8qfTjFQGhwEOY4HYcnzUBcrjZbVaJdGaMjjxRtATn1 fKZ4BRd+x5nc+Y+N2VOCExmarsvkGVmFuB1+AkFW3MyBNuit5/KFfLcgtZ3/iCS8/dBC E+DK2bPFg8xdQbLJxQTcssGWj80zLTktO9xCMllELC1zHmwzX+G/8xJGJ0Nnt/QkSZHp crSve6dDsCtEEPeyfczRutEas+a4RmvTOlkwomjxQAM5cZ7AF7YO2g/J/31JFcE/Kr2E YZqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=xQpTLC6E1PRuW/0kD3SuI3KMgBpS6j8V/VqnCLl4Sg4=; b=mMIwZPx82WcLQtiTIM3b74uC0N9LffcPJx8lwcP7TiA+aHzBMuITXBGdtmh0b57wzi IcfnqbwJIdiPiEQcxGhub4ZJy4aL20qxTzfGGKTTG5VTN+GDfFizhMcVDcxi+RSas3uI Su1v/wyrED1kpCr1DY29x1Upc3eQtYeg/vg+4Kqzqi4JcsbQsoSLEtZku2MOVk99gGJ6 4jboC7dbritw+/BhPh9asnhjuwb1QHry+Cwpi+B5NE25s5fvBKzyPM97mnRxMUHq1guG iY4jAp8j9hPvgVOliJMBTtFGvi2NRIJWTX+MG8kxBkAsv48U1enR6u7z6LH2/myge1NM AFbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Oes5yXar; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id c26-20020a056402159a00b00464718ca52bsi7117947edv.174.2022.11.07.00.49.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 00:49:23 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Oes5yXar; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C39A238983BD for ; Mon, 7 Nov 2022 08:44:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C39A238983BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667810679; bh=xQpTLC6E1PRuW/0kD3SuI3KMgBpS6j8V/VqnCLl4Sg4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Oes5yXarriD6yPtlS1Lge2zoIlmLFT7Giy110YsdUq5Uzcrn3ckOIiXy/EUg8M3Yp GPF9/XoeZaV/UmaphZP0XIzMb+dRWcBsURljxP8hl8rn9s6V/gh2zadMil+Jc8z/vn WYkKc8tzOppX+QuafzUpmWZYPdf53eapBfx2vUMk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 Received: by mail-wr1-x430.google.com with SMTP id cl5so15022346wrb.9 for ; Mon, 07 Nov 2022 00:40:54 -0800 (PST) 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-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) 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748826549083554192?= X-GMAIL-MSGID: =?utf-8?q?1748826549083554192?= 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;