From patchwork Mon May 8 18:13:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 91221 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2340469vqo; Mon, 8 May 2023 11:14:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5nrksYCabKRig3YJPbuTqsHTVbvYQhjbkhv5DIHIsut9HX6CLP2Nbpg9WrufV8Qvd//U9q X-Received: by 2002:a17:907:701:b0:94a:82ca:12e5 with SMTP id xb1-20020a170907070100b0094a82ca12e5mr9038375ejb.45.1683569692657; Mon, 08 May 2023 11:14:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683569692; cv=none; d=google.com; s=arc-20160816; b=Z5Gf9Gw5pSfgkrhR4Ohc7WDhGoQ+2DqFNHW+iqbFZjm7Abyi9BLceviuj6adMmDnZ/ cIzl7IVX29+xCfFOUdtIARdPeM6P9aXe2BmUvF6SB4Q9vX6rOSSUNy4ci8KQuAql80WI GUHrwEqbsqmmSGo2BkuPsLDOn1AeZaoeJBURqde1Cjy3P/Nm8wFIqInfh6Li7nLHtMUH SHOznrHlr5X/gOCbs9UoNhLObftdsnk9oel1s94SA1cmPSZcyO74JB6hpP0jdVRdA3Dy XC6M/d9BEpilMAQnQ+fUbZ1SFVVmFh295T0m8oRRnvIn9x91T4wQ1cvRo2Mi9nzXpWkf uBaA== 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:references:in-reply-to :message-id:date:subject:cc:to:dkim-filter:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=sXu4vDlY5p6Y+pInEQVP1msog0eEzqoG2Vs9eFvlbdE=; b=rQGum+WzaJEZPPneTDgBAQXnzavAnm319WcKOtPxEgUy5tNHa71gRKC6WYGIvf3yBm GtflVc3+OlBg9NwRFyuG2xxaqOJS7oeuh6+CuK4/gsrl/Vaui9cC/LDoTWBbcE7M9kHe yDX2azDAi62KJzEpsIlcgnf2hEX2Bd5sNj/8jS0LLmRJnOCRJd84zxGO50QzKAx/mKp2 6whjiiWOICztCL73LKTiG4H+FMLDF7LC9p8U+fv5B2QotQMlWUxO5a+rAOTl5JsVi7AW hlROa/JYwCpqhwCSo6bi5M46P8fZ95Nxt84Ml3nQtYq/KMpX0/Ce+5n0ZNVTIz+Wuv/v JBrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xHDJkQud; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id rl18-20020a170907217200b0094edbf6c509si328152ejb.455.2023.05.08.11.14.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 11:14:52 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xHDJkQud; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 3ECC23856DD2 for ; Mon, 8 May 2023 18:14:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3ECC23856DD2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683569652; bh=sXu4vDlY5p6Y+pInEQVP1msog0eEzqoG2Vs9eFvlbdE=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=xHDJkQudKSOimnfTLNZYQ9WR5acqN9X+xxDfceO4JOqyEP1Km+wODnLX7BfsUCXf7 K6Mr++1wlwm0NZLr9iSyEAsCKZ4YNGfj4wD7ecb4wPZOmKi7MSZk9CEhkI5PFD6IHA 8fyBsi+wCGICZx/E3j2wuiXP8EeufaZ1O+k/jsgQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id ABB8E3858D3C for ; Mon, 8 May 2023 18:13:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ABB8E3858D3C Received: from localhost.intra.ispras.ru (unknown [10.10.3.121]) by mail.ispras.ru (Postfix) with ESMTP id 2411C44C1013; Mon, 8 May 2023 18:13:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 2411C44C1013 To: gcc-patches@gcc.gnu.org Cc: Alexander Monakov Subject: [PATCH 2/3] genmatch: clean up showUsage Date: Mon, 8 May 2023 21:13:10 +0300 Message-Id: <20230508181311.25961-3-amonakov@ispras.ru> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230508181311.25961-1-amonakov@ispras.ru> References: <20230508181311.25961-1-amonakov@ispras.ru> MIME-Version: 1.0 X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: Alexander Monakov via Gcc-patches From: Alexander Monakov Reply-To: Alexander Monakov 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?1765350773870572753?= X-GMAIL-MSGID: =?utf-8?q?1765350773870572753?= Display usage more consistently and get rid of camelCase. gcc/ChangeLog: * genmatch.cc (showUsage): Reimplement as ... (usage): ...this. Adjust all uses. (main): Print usage when no arguments. Add missing 'return 1'. --- gcc/genmatch.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc index d5e56e2d68..baf93855a6 100644 --- a/gcc/genmatch.cc +++ b/gcc/genmatch.cc @@ -5301,13 +5301,12 @@ round_alloc_size (size_t s) /* Construct and display the help menu. */ static void -showUsage () +usage () { - fprintf (stderr, "Usage: genmatch [--gimple] [--generic] " - "[--header=] [--include=] [-v[v]] input " - "[...]\n"); - fprintf (stderr, "\nWhen more then one outputfile is specified --header " - "is required.\n"); + const char *usage = "Usage:\n" + " %s [--gimple|--generic] [-v[v]] \n" + " %s [options] [--include=FILE] --header=FILE ...\n"; + fprintf (stderr, usage, progname, progname); } /* Write out the correct include to the match-head fle containing the helper @@ -5332,9 +5331,6 @@ main (int argc, char **argv) progname = "genmatch"; - if (argc < 2) - return 1; - bool gimple = true; char *s_header_file = NULL; char *s_include_file = NULL; @@ -5359,14 +5355,17 @@ main (int argc, char **argv) files.safe_push (argv[i]); else { - showUsage (); + usage (); return 1; } } /* Validate if the combinations are valid. */ if ((files.length () > 1 && !s_header_file) || files.is_empty ()) - showUsage (); + { + usage (); + return 1; + } if (!s_include_file) s_include_file = s_header_file;