summaryrefslogtreecommitdiffstats
path: root/main.c
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
commit01f69fb32c4ca7b2a3feed66a73e89239f256947 (patch)
treefd42c9ecc0a8edda639dec1d2a51b954f46915aa /main.c
parentfdf3d4ea21fc756ec3a0b1f10ab6b1ea3ba6d00e (diff)
downloadmandoc-01f69fb32c4ca7b2a3feed66a73e89239f256947.tar.gz
Added -fign-errors for VERY fast checking of many manuals without stopping at errors.
Diffstat (limited to 'main.c')
-rw-r--r--main.c41
1 files changed, 27 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;