summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mandoc.h2
-rw-r--r--mdoc_validate.c22
-rw-r--r--read.c38
3 files changed, 36 insertions, 26 deletions
diff --git a/mandoc.h b/mandoc.h
index 3cafca1b..b52f3054 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -160,14 +160,12 @@ enum mandocerr {
MANDOCERR_FATAL, /* ===== start of fatal errors ===== */
MANDOCERR_TOOLARGE, /* input too large */
- MANDOCERR_NOTMANUAL, /* not a manual */
MANDOCERR_COLUMNS, /* column syntax is inconsistent */
MANDOCERR_BADDISP, /* NOT IMPLEMENTED: .Bd -file */
MANDOCERR_SYNTCHILD, /* child violates parent syntax */
MANDOCERR_SYNTARGCOUNT, /* argument count wrong, violates syntax */
MANDOCERR_SO_PATH, /* NOT IMPLEMENTED: .so with absolute path or ".." */
MANDOCERR_SO_FAIL, /* .so request failed */
- MANDOCERR_NODOCPROLOG, /* no document prologue */
MANDOCERR_MEM, /* static buffer exhausted */
/* ===== system errors ===== */
diff --git a/mdoc_validate.c b/mdoc_validate.c
index e5d10bc0..d1e8df95 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1683,16 +1683,24 @@ ebool(struct mdoc *mdoc)
static int
post_root(POST_ARGS)
{
- int ret;
struct mdoc_node *n;
- ret = 1;
-
- /* Check that we have a finished prologue. */
+ /* Add missing prologue data. */
if ( ! (MDOC_PBODY & mdoc->flags)) {
- ret = 0;
- mdoc_nmsg(mdoc, mdoc->first, MANDOCERR_NODOCPROLOG);
+ mandoc_msg(MANDOCERR_PROLOG_BAD, mdoc->parse, 0, 0, "EOF");
+ if (mdoc->meta.date == NULL)
+ mdoc->meta.date = mdoc->quick ?
+ mandoc_strdup("") :
+ mandoc_normdate(mdoc->parse, NULL, 0, 0);
+ if (mdoc->meta.title == NULL)
+ mdoc->meta.title = mandoc_strdup("UNKNOWN");
+ if (mdoc->meta.vol == NULL)
+ mdoc->meta.vol = mandoc_strdup("LOCAL");
+ if (mdoc->meta.arch == NULL)
+ mdoc->meta.msec = mandoc_strdup("1");
+ if (mdoc->meta.os == NULL)
+ mdoc->meta.os = mandoc_strdup("UNKNOWN");
}
n = mdoc->first;
@@ -1707,7 +1715,7 @@ post_root(POST_ARGS)
n->child->line, n->child->pos,
mdoc_macronames[n->child->tok]);
- return(ret);
+ return(1);
}
static int
diff --git a/read.c b/read.c
index 1788c40f..c867af65 100644
--- a/read.c
+++ b/read.c
@@ -204,14 +204,12 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"generic fatal error",
"input too large",
- "not a manual",
"column syntax is inconsistent",
"NOT IMPLEMENTED: .Bd -file",
"child violates parent syntax",
"argument count wrong, violates syntax",
"NOT IMPLEMENTED: .so with absolute path or \"..\"",
".so request failed",
- "no document prologue",
"static buffer exhausted",
/* system errors */
@@ -264,18 +262,9 @@ pset(const char *buf, int pos, struct mparse *curp)
}
if (MPARSE_MDOC & curp->options) {
- if (NULL == curp->pmdoc)
- curp->pmdoc = mdoc_alloc(
- curp->roff, curp, curp->defos,
- MPARSE_QUICK & curp->options ? 1 : 0);
- assert(curp->pmdoc);
curp->mdoc = curp->pmdoc;
return;
} else if (MPARSE_MAN & curp->options) {
- if (NULL == curp->pman)
- curp->pman = man_alloc(curp->roff, curp,
- MPARSE_QUICK & curp->options ? 1 : 0);
- assert(curp->pman);
curp->man = curp->pman;
return;
}
@@ -683,6 +672,19 @@ mparse_end(struct mparse *curp)
if (MANDOCLEVEL_FATAL <= curp->file_status)
return;
+ if (curp->mdoc == NULL &&
+ curp->man == NULL &&
+ curp->sodest == NULL) {
+ if (curp->options & MPARSE_MDOC)
+ curp->mdoc = curp->pmdoc;
+ else {
+ if (curp->pman == NULL)
+ curp->pman = man_alloc(curp->roff, curp,
+ curp->options & MPARSE_QUICK ? 1 : 0);
+ curp->man = curp->pman;
+ }
+ }
+
if (curp->mdoc && ! mdoc_endparse(curp->mdoc)) {
assert(MANDOCLEVEL_FATAL <= curp->file_status);
return;
@@ -693,12 +695,6 @@ mparse_end(struct mparse *curp)
return;
}
- if ( ! (curp->mdoc || curp->man || curp->sodest)) {
- mandoc_msg(MANDOCERR_NOTMANUAL, curp, 0, 0, NULL);
- curp->file_status = MANDOCLEVEL_FATAL;
- return;
- }
-
roff_endparse(curp->roff);
}
@@ -796,6 +792,14 @@ mparse_alloc(int options, enum mandoclevel wlevel,
curp->defos = defos;
curp->roff = roff_alloc(curp, options);
+ if (curp->options & MPARSE_MDOC)
+ curp->pmdoc = mdoc_alloc(
+ curp->roff, curp, curp->defos,
+ curp->options & MPARSE_QUICK ? 1 : 0);
+ if (curp->options & MPARSE_MAN)
+ curp->pman = man_alloc(curp->roff, curp,
+ curp->options & MPARSE_QUICK ? 1 : 0);
+
return(curp);
}