source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: docbook2mdoc: Parsing errors are too easy to miss because they typically
Date: Tue, 26 Mar 2019 15:06:47 -0500 (EST)	[thread overview]
Message-ID: <e3fcc12cbf0ef556@fantadrom.bsd.lv> (raw)

Log Message:
-----------
Parsing errors are too easy to miss because they typically emit a
one-line error message followed by lengthy formatted output
of what was parsed before the error occurred.

Make parsing errors more conspicious by taking two steps:

1. If there was a parsing error, print a blank line to standard output
before starting formatted output, for better separation.

2. After the formatted output, if there was a parsing error, print
the following to standard error: a blank line, a message that output
is incomplete, and another blank line.

Modified Files:
--------------
    docbook2mdoc:
        main.c

Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/main.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lmain.c -Lmain.c -u -p -r1.1 -r1.2
--- main.c
+++ main.c
@@ -80,9 +80,15 @@ main(int argc, char *argv[])
 	rc = 1;
 	if ((parser = parse_alloc(warn)) != NULL) {
 		if ((tree = parse_file(parser, fd, fname)) != NULL) {
-			if ((tree->flags & TREE_FAIL) == 0)
+			if (tree->flags & TREE_FAIL)
+				fputc('\n', stderr);
+			else
 				rc = 0;
 			ptree_print(tree);
+			if (tree->flags & TREE_FAIL)
+				fputs("\nThe output is incomplete, see "
+				    "the parse error reported above.\n\n",
+				    stderr);
 			pnode_unlink(tree->root);
 			tree->root = NULL;
 		}
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

                 reply	other threads:[~2019-03-26 20:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e3fcc12cbf0ef556@fantadrom.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).