-/* $Id: mandoc.h,v 1.88 2014/08/08 15:15:27 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.89 2014/08/08 15:21:17 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
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 ===== */
-/* $Id: mdoc_validate.c,v 1.151 2014/08/08 15:15:27 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.152 2014/08/08 15:21:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
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;
n->child->line, n->child->pos,
mdoc_macronames[n->child->tok]);
- return(ret);
+ return(1);
}
static int
-/* $Id: read.c,v 1.49 2014/08/08 15:15:27 schwarze Exp $ */
+/* $Id: read.c,v 1.50 2014/08/08 15:21:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
"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 */
}
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;
}
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;
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);
}
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);
}