From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from re-prd-fep-049.btinternet.com (mailomta18-re.btinternet.com [213.120.69.111]) by sourceware.org (Postfix) with ESMTPS id BAEC23858425 for ; Fri, 4 Nov 2022 13:50:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BAEC23858425 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dronecode.org.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=dronecode.org.uk Received: from re-prd-rgout-001.btmx-prd.synchronoss.net ([10.2.54.4]) by re-prd-fep-049.btinternet.com with ESMTP id <20221104135009.CTKS3069.re-prd-fep-049.btinternet.com@re-prd-rgout-001.btmx-prd.synchronoss.net>; Fri, 4 Nov 2022 13:50:09 +0000 Authentication-Results: btinternet.com; none X-SNCR-Rigid: 613A8CC3410427A2 X-Originating-IP: [81.153.98.206] X-OWM-Source-IP: 81.153.98.206 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-VadeSecure-score: verdict=clean score=0/300, class=clean X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvgedrvddugdehgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemuceutffkvffkuffjvffgnffgvefqofdpqfgfvfenuceurghilhhouhhtmecufedtudenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeflohhnucfvuhhrnhgvhicuoehjohhnrdhtuhhrnhgvhiesughrohhnvggtohguvgdrohhrghdruhhkqeenucggtffrrghtthgvrhhnpeeliedtjefhtdevkeehueegffegveeftdejjeevfefhiefffeektddvteehheeijeenucfkphepkedurdduheefrdelkedrvddtieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhephhgvlhhopehlohgtrghlhhhoshhtrdhlohgtrghlughomhgrihhnpdhinhgvthepkedurdduheefrdelkedrvddtiedpmhgrihhlfhhrohhmpehjohhnrdhtuhhrnhgvhiesughrohhnvggtohguvgdrohhrghdruhhkpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepjhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukhdprhgtphhtthhopehnvgiflhhisgesshhouhhrtggvfigrrhgvrdhorhhg X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from localhost.localdomain (81.153.98.206) by re-prd-rgout-001.btmx-prd.synchronoss.net (5.8.716.04) (authenticated as jonturney@btinternet.com) id 613A8CC3410427A2; Fri, 4 Nov 2022 13:50:09 +0000 From: Jon Turney To: newlib@sourceware.org Cc: Jon Turney Subject: [PATCH 2/5] makedocbook: Use sys.exit() Date: Fri, 4 Nov 2022 13:49:43 +0000 Message-Id: <20221104134946.13443-3-jon.turney@dronecode.org.uk> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221104134946.13443-1-jon.turney@dronecode.org.uk> References: <20221104134946.13443-1-jon.turney@dronecode.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1196.8 required=5.0 tests=BAYES_00,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_NONE,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: Use sys.exit() to write a message to stderr and terminate with a non-zero exit code. --- newlib/doc/makedocbook.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/newlib/doc/makedocbook.py b/newlib/doc/makedocbook.py index 5e46082df..57cd23bfd 100755 --- a/newlib/doc/makedocbook.py +++ b/newlib/doc/makedocbook.py @@ -214,8 +214,7 @@ def function(c, l): # FUNCTION implies starting a new refentry if refentry is not None: - print("multiple FUNCTIONs without NEWPAGE", file=sys.stderr) - exit(1) + sys.exit("multiple FUNCTIONs without NEWPAGE") # create the refentry refentry = lxml.etree.SubElement(rootelement, 'refentry') @@ -308,17 +307,15 @@ def synopsis(c, t): # a prototype without a terminating ';' is an error if s.endswith(')'): - print("'%s' missing terminating semicolon" % l, file=sys.stderr) + sys.exit("'%s' missing terminating semicolon" % l) s = s + ';' - exit(1) if ';' in s: synopsis_for_prototype(funcsynopsis, s) s = '' if s.strip(): - print("surplus synopsis '%s'" % s, file=sys.stderr) - exit(1) + sys.exit("surplus synopsis '%s'" % s) def synopsis_for_prototype(funcsynopsis, s): s = s.strip() @@ -591,8 +588,7 @@ def t_eof(t): # Error handling rule def t_error(t): - print("tokenization error, remaining text '%s'" % t.value, file=sys.stderr) - exit(1) + sys.exit("tokenization error, remaining text '%s'" % t.value) lexer = lex.lex() @@ -795,8 +791,8 @@ def p_multitable(p): parser_verbose(p) def p_error(t): - print('parse error at line %d, token %s, next token %s' % (t.lineno, t, parser.token()), file=sys.stderr) - exit(1) + sys.exit('parse error at line %d, token %s, next token %s' % (t.lineno, t, parser.token())) + # protect creating the parser with a lockfile, so that when multiple processes # are running this script simultaneously, we don't get one of them generating a -- 2.38.1