summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-07-24 14:00:59 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-07-24 14:00:59 +0000
commit2f0e48a3b94c4ea5af2482492f89ecda94388aaf (patch)
tree73a2265aea4fdcb4b02b94c2ec7842a46fd3d901
parent81ee6448dee9591b4e0ee8879542ef378054c91b (diff)
downloadmandoc-2f0e48a3b94c4ea5af2482492f89ecda94388aaf.tar.gz
mandoc-2f0e48a3b94c4ea5af2482492f89ecda94388aaf.tar.zst
mandoc-2f0e48a3b94c4ea5af2482492f89ecda94388aaf.zip
Added -fign-errors for VERY fast checking of many manuals without stopping at errors.
-rw-r--r--main.c43
-rw-r--r--mandoc.114
2 files changed, 40 insertions, 17 deletions
diff --git a/main.c b/main.c
index 26988773..a7b5c4d4 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.38 2009/07/07 09:52:08 kristaps Exp $ */
+/* $Id: main.c,v 1.39 2009/07/24 14:00:59 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 fcf29386..c7235e2e 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.1,v 1.27 2009/07/21 15:52:41 kristaps Exp $
+.\" $Id: mandoc.1,v 1.28 2009/07/24 14:00:59 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: July 21 2009 $
+.Dd $Mdocdate: July 24 2009 $
.Dt MANDOC 1
.Os
.\" SECTION
@@ -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