public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] makedocbook: Use sys.exit()
@ 2022-11-12 14:12 Jon TURNEY
  0 siblings, 0 replies; only message in thread
From: Jon TURNEY @ 2022-11-12 14:12 UTC (permalink / raw)
  To: newlib-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8b6c4249e2a592ab69d4fca299a3466815aed951

commit 8b6c4249e2a592ab69d4fca299a3466815aed951
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Tue Nov 1 11:21:21 2022 +0000

    makedocbook: Use sys.exit()
    
    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):
 
     # 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-12 14:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-12 14:12 [newlib-cygwin] makedocbook: Use sys.exit() Jon TURNEY

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).