aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/demandoc.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-01-15 04:26:39 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-01-15 04:26:39 +0000
commit6b618405d781b6a4a5425bf52419f31f0362fcf1 (patch)
treed28f1821e50247b93cfa8e53a1db6db3e51a969b /demandoc.c
parent8b5853de9633ceece63738b2ccd5bdba06098315 (diff)
downloadmandoc-6b618405d781b6a4a5425bf52419f31f0362fcf1.tar.gz
mandoc-6b618405d781b6a4a5425bf52419f31f0362fcf1.tar.zst
mandoc-6b618405d781b6a4a5425bf52419f31f0362fcf1.zip
Fatal errors no longer exist.
If a file can be opened, mandoc will produce some output; at worst, the output may be almost empty. Simplifies error handling and frees a message type for future use.
Diffstat (limited to 'demandoc.c')
-rw-r--r--demandoc.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/demandoc.c b/demandoc.c
index e9aa62af..37043e30 100644
--- a/demandoc.c
+++ b/demandoc.c
@@ -1,4 +1,4 @@
-/* $Id: demandoc.c,v 1.12 2014/10/28 17:36:19 schwarze Exp $ */
+/* $Id: demandoc.c,v 1.13 2015/01/15 04:26:39 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -44,7 +44,7 @@ main(int argc, char *argv[])
{
struct mparse *mp;
struct mchars *mchars;
- int ch, i, list;
+ int ch, fd, i, list;
extern int optind;
progname = strrchr(argv[0], '/');
@@ -78,7 +78,7 @@ main(int argc, char *argv[])
argv += optind;
mchars = mchars_alloc();
- mp = mparse_alloc(MPARSE_SO, MANDOCLEVEL_FATAL, NULL, mchars, NULL);
+ mp = mparse_alloc(MPARSE_SO, MANDOCLEVEL_BADARG, NULL, mchars, NULL);
assert(mp);
if (0 == argc)
@@ -86,7 +86,11 @@ main(int argc, char *argv[])
for (i = 0; i < argc; i++) {
mparse_reset(mp);
- pmandoc(mp, -1, argv[i], list);
+ if (mparse_open(mp, &fd, argv[i]) != MANDOCLEVEL_OK) {
+ perror(argv[i]);
+ continue;
+ }
+ pmandoc(mp, fd, argv[i], list);
}
mparse_free(mp);
@@ -108,11 +112,7 @@ pmandoc(struct mparse *mp, int fd, const char *fn, int list)
struct man *man;
int line, col;
- if (mparse_readfd(mp, fd, fn) >= MANDOCLEVEL_FATAL) {
- fprintf(stderr, "%s: Parse failure\n", fn);
- return;
- }
-
+ mparse_readfd(mp, fd, fn);
mparse_result(mp, &mdoc, &man, NULL);
line = 1;
col = 0;