- assert(tok < MDOC_MAX);
-
- if (mdoc->flags & MDOC_PBODY) {
- if (tok == MDOC_Dt) {
- mandoc_vmsg(MANDOCERR_DT_LATE,
- mdoc->parse, line, ppos,
- "Dt %s", buf + *pos);
- return;
- }
- } else if ( ! (mdoc_macros[tok].flags & MDOC_PROLOGUE)) {
- if (mdoc->meta.title == NULL) {
- mandoc_vmsg(MANDOCERR_DT_NOTITLE,
- mdoc->parse, line, ppos, "%s %s",
- mdoc_macronames[tok], buf + *pos);
- mdoc->meta.title = mandoc_strdup("UNTITLED");
- }
- if (NULL == mdoc->meta.vol)
- mdoc->meta.vol = mandoc_strdup("LOCAL");
- mdoc->flags |= MDOC_PBODY;
- }
- (*mdoc_macros[tok].fp)(mdoc, tok, line, ppos, pos, buf);
-}
-
-
-static void
-node_append(struct roff_man *mdoc, struct roff_node *p)
-{
-
- assert(mdoc->last);
- assert(mdoc->first);
- assert(p->type != ROFFT_ROOT);
-
- switch (mdoc->next) {
- case ROFF_NEXT_SIBLING:
- mdoc->last->next = p;
- p->prev = mdoc->last;
- p->parent = mdoc->last->parent;
- break;
- case ROFF_NEXT_CHILD:
- mdoc->last->child = p;
- p->parent = mdoc->last;
- break;
- default:
- abort();
- /* NOTREACHED */
- }
-
- p->parent->nchild++;
-
- /*
- * Copy over the normalised-data pointer of our parent. Not
- * everybody has one, but copying a null pointer is fine.
- */
-
- switch (p->type) {
- case ROFFT_BODY:
- if (ENDBODY_NOT != p->end)
- break;
- /* FALLTHROUGH */
- case ROFFT_TAIL:
- /* FALLTHROUGH */
- case ROFFT_HEAD:
- p->norm = p->parent->norm;
- break;
- default:
- break;
- }
-
- mdoc_valid_pre(mdoc, p);
-
- switch (p->type) {
- case ROFFT_HEAD:
- assert(p->parent->type == ROFFT_BLOCK);
- p->parent->head = p;
- break;
- case ROFFT_TAIL:
- assert(p->parent->type == ROFFT_BLOCK);
- p->parent->tail = p;
- break;
- case ROFFT_BODY:
- if (p->end)
- break;
- assert(p->parent->type == ROFFT_BLOCK);
- p->parent->body = p;
- break;
- default:
- break;
- }
-
- mdoc->last = p;
-
- switch (p->type) {
- case ROFFT_TBL:
- /* FALLTHROUGH */
- case ROFFT_TEXT:
- mdoc_valid_post(mdoc);
- break;
- default:
- break;
- }
-}
-
-static struct roff_node *
-node_alloc(struct roff_man *mdoc, int line, int pos,
- int tok, enum roff_type type)
-{
- struct roff_node *p;
-
- p = mandoc_calloc(1, sizeof(*p));
- p->sec = mdoc->lastsec;
- p->line = line;
- p->pos = pos;
- p->tok = tok;
- p->type = type;
-
- /* Flag analysis. */