From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2201) id 59101383EC59; Sat, 12 Nov 2022 14:12:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59101383EC59 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668262337; bh=FfFKSKrFZn30vlmGpRANaHxfALdBch+hV09/fA10SFM=; h=From:To:Subject:Date:From; b=Ic4zahGZ7YedEMOVMdY7/TnXmvyxkblbEaVsPzi+qvqEvOErOYP7RJxhwgnlEq0zA iLhkUPMGR6oxMoyoD7CBXJH/vE0Ea7afbjcTzcDfIFE9ivVu5i82XcLLEIhnBwn6QF uJbnKvBrjg+L31iHQMAW/WzWNd51MEpJBWFmnodY= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jon TURNEY To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] makedocbook: Use sys.exit() X-Act-Checkin: newlib-cygwin X-Git-Author: Jon Turney X-Git-Refname: refs/heads/master X-Git-Oldrev: 2432d77099345ee3a4649d002750622d5db79c1b X-Git-Newrev: 8b6c4249e2a592ab69d4fca299a3466815aed951 Message-Id: <20221112141217.59101383EC59@sourceware.org> Date: Sat, 12 Nov 2022 14:12:17 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D8b6c4249e2a= 592ab69d4fca299a3466815aed951 commit 8b6c4249e2a592ab69d4fca299a3466815aed951 Author: Jon Turney Date: Tue Nov 1 11:21:21 2022 +0000 makedocbook: Use sys.exit() =20 Use sys.exit() to write a message to stderr and terminate with a non-zero exit code. Diff: --- 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): =20 # FUNCTION implies starting a new refentry if refentry is not None: - print("multiple FUNCTIONs without NEWPAGE", file=3Dsys.stderr) - exit(1) + sys.exit("multiple FUNCTIONs without NEWPAGE") =20 # create the refentry refentry =3D lxml.etree.SubElement(rootelement, 'refentry') @@ -308,17 +307,15 @@ def synopsis(c, t): =20 # a prototype without a terminating ';' is an error if s.endswith(')'): - print("'%s' missing terminating semicolon" % l, file=3Dsys= .stderr) + sys.exit("'%s' missing terminating semicolon" % l) s =3D s + ';' - exit(1) =20 if ';' in s: synopsis_for_prototype(funcsynopsis, s) s =3D '' =20 if s.strip(): - print("surplus synopsis '%s'" % s, file=3Dsys.stderr) - exit(1) + sys.exit("surplus synopsis '%s'" % s) =20 def synopsis_for_prototype(funcsynopsis, s): s =3D s.strip() @@ -591,8 +588,7 @@ def t_eof(t): =20 # Error handling rule def t_error(t): - print("tokenization error, remaining text '%s'" % t.value, file=3Dsys.= stderr) - exit(1) + sys.exit("tokenization error, remaining text '%s'" % t.value) =20 lexer =3D lex.lex() =20 @@ -795,8 +791,8 @@ def p_multitable(p): parser_verbose(p) =20 def p_error(t): - print('parse error at line %d, token %s, next token %s' % (t.lineno, t= , parser.token()), file=3Dsys.stderr) - exit(1) + sys.exit('parse error at line %d, token %s, next token %s' % (t.lineno= , t, parser.token())) + =20 # protect creating the parser with a lockfile, so that when multiple proce= sses # are running this script simultaneously, we don't get one of them generat= ing a