summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.c41
-rw-r--r--mandoc.110
2 files changed, 37 insertions, 14 deletions
diff --git a/main.c b/main.c
index 6a7a38d4..84bccdf5 100644
--- a/main.c
+++ b/main.c
@@ -72,6 +72,7 @@ struct curparse {
#define NO_IGN_ESCAPE (1 << 1) /* Don't ignore bad escapes. */
#define NO_IGN_MACRO (1 << 2) /* Don't ignore bad macros. */
#define NO_IGN_CHARS (1 << 3) /* Don't ignore bad chars. */
+#define IGN_ERRORS (1 << 4) /* Ignore failed parse. */
enum intt inttype; /* Input parsers... */
struct man *man;
struct man *lastman;
@@ -161,13 +162,21 @@ main(int argc, char *argv[])
if (NULL == *argv) {
curp.file = "<stdin>";
curp.fd = STDIN_FILENO;
- if ( ! fdesc(&blk, &ln, &curp))
- rc = 0;
+
+ c = fdesc(&blk, &ln, &curp);
+ if ( ! (IGN_ERRORS & curp.fflags))
+ rc = 1 == c ? 1 : 0;
+ else
+ rc = -1 == c ? 0 : 1;
}
while (rc && *argv) {
- if ( ! ffile(&blk, &ln, *argv, &curp))
- rc = 0;
+ c = ffile(&blk, &ln, *argv, &curp);
+ if ( ! (IGN_ERRORS & curp.fflags))
+ rc = 1 == c ? 1 : 0;
+ else
+ rc = -1 == c ? 0 : 1;
+
argv++;
if (*argv && rc) {
if (curp.lastman)
@@ -283,7 +292,7 @@ ffile(struct buf *blk, struct buf *ln,
curp->file = file;
if (-1 == (curp->fd = open(curp->file, O_RDONLY, 0))) {
warn("%s", curp->file);
- return(0);
+ return(-1);
}
c = fdesc(blk, ln, curp);
@@ -324,7 +333,7 @@ fdesc(struct buf *blk, struct buf *ln, struct curparse *curp)
blk->buf = realloc(blk->buf, sz);
if (NULL == blk->buf) {
warn("realloc");
- return(0);
+ return(-1);
}
blk->sz = sz;
}
@@ -334,7 +343,7 @@ fdesc(struct buf *blk, struct buf *ln, struct curparse *curp)
for (lnn = pos = comment = 0; ; ) {
if (-1 == (ssz = read(curp->fd, blk->buf, sz))) {
warn("%s", curp->file);
- return(0);
+ return(-1);
} else if (0 == ssz)
break;
@@ -346,7 +355,7 @@ fdesc(struct buf *blk, struct buf *ln, struct curparse *curp)
ln->buf = realloc(ln->buf, ln->sz);
if (NULL == ln->buf) {
warn("realloc");
- return(0);
+ return(-1);
}
}
@@ -393,7 +402,7 @@ fdesc(struct buf *blk, struct buf *ln, struct curparse *curp)
if ( ! (man || mdoc) && ! pset(ln->buf,
pos, curp, &man, &mdoc))
- return(0);
+ return(-1);
pos = comment = 0;
@@ -441,10 +450,10 @@ fdesc(struct buf *blk, struct buf *ln, struct curparse *curp)
if (man && curp->outman)
if ( ! (*curp->outman)(curp->outdata, man))
- return(0);
+ return(-1);
if (mdoc && curp->outmdoc)
if ( ! (*curp->outmdoc)(curp->outdata, mdoc))
- return(0);
+ return(-1);
return(1);
}
@@ -551,14 +560,15 @@ static int
foptions(int *fflags, char *arg)
{
char *v, *o;
- char *toks[6];
+ char *toks[7];
toks[0] = "ign-scope";
toks[1] = "no-ign-escape";
toks[2] = "no-ign-macro";
toks[3] = "no-ign-chars";
- toks[4] = "strict";
- toks[5] = NULL;
+ toks[4] = "ign-errors";
+ toks[5] = "strict";
+ toks[6] = NULL;
while (*arg) {
o = arg;
@@ -576,6 +586,9 @@ foptions(int *fflags, char *arg)
*fflags |= NO_IGN_CHARS;
break;
case (4):
+ *fflags |= IGN_ERRORS;
+ break;
+ case (5):
*fflags |= NO_IGN_ESCAPE |
NO_IGN_MACRO | NO_IGN_CHARS;
break;
diff --git a/mandoc.1 b/mandoc.1
index b1c17481..85ee8177 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -227,6 +227,10 @@ Implies
.Fl f Ns Ar no-ign-macro
and
.Fl f Ns Ar no-ign-chars .
+.It Fl f Ns Ar ign-errors
+Don't halt when encountering parse errors. Useful with
+.Fl T Ns Ar lint
+over a large set of manuals passed on the command line.
.El
.\" PARAGRAPH
.Pp
@@ -245,6 +249,12 @@ To page manuals to the terminal:
.Pp
.D1 % mandoc \-Wall,error \-fstrict mandoc.1 2>&1 | less
.D1 % mandoc mandoc.1 mdoc.3 mdoc.7 | less
+.\" PARAGRAPH
+.Pp
+To check over a large set of manuals:
+.\" PARAGRAPH
+.Pp
+.Dl % mandoc \-Tlint \-fign-errors `find /usr/src -name \e*\e.[1-9]`
.\" SECTION
.Sh COMPATIBILITY
This section summarises