diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-07-30 14:50:08 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-07-30 14:50:08 +0000 |
commit | 16567ee6b0b51e693f21d13f133f9fa14e59d992 (patch) | |
tree | 79ac8edf8630ed06810cbdb48ee6425abe52d828 /mdoc_validate.c | |
parent | 1825ddd5edbb59f71fa3505747e772b6e10bc773 (diff) | |
download | mandoc-16567ee6b0b51e693f21d13f133f9fa14e59d992.tar.gz |
Remove two useless FATAL errors.
When a file contains neither text nor macros, treat it as an empty document.
When the mdoc(7) document prologue is incomplete, use some default values.
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r-- | mdoc_validate.c | 22 |
1 files changed, 15 insertions, 7 deletions
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 |