- man_ptext(man, ln, buf, offs));
-}
-
-static void
-man_node_append(struct roff_man *man, struct roff_node *p)
-{
-
- assert(man->last);
- assert(man->first);
- assert(p->type != ROFFT_ROOT);
-
- switch (man->next) {
- case ROFF_NEXT_SIBLING:
- man->last->next = p;
- p->prev = man->last;
- p->parent = man->last->parent;
- break;
- case ROFF_NEXT_CHILD:
- man->last->child = p;
- p->parent = man->last;
- break;
- default:
- abort();
- /* NOTREACHED */
- }
-
- assert(p->parent);
- p->parent->nchild++;
-
- switch (p->type) {
- case ROFFT_BLOCK:
- if (p->tok == MAN_SH || p->tok == MAN_SS)
- man->flags &= ~MAN_LITERAL;
- break;
- case ROFFT_HEAD:
- assert(p->parent->type == ROFFT_BLOCK);
- p->parent->head = p;
- break;
- case ROFFT_BODY:
- assert(p->parent->type == ROFFT_BLOCK);
- p->parent->body = p;
- break;
- default:
- break;
- }
-
- man->last = p;
-
- switch (p->type) {
- case ROFFT_TBL:
- /* FALLTHROUGH */
- case ROFFT_TEXT:
- man_valid_post(man);
- break;
- default:
- break;
- }
-}
-
-static struct roff_node *
-man_node_alloc(struct roff_man *man, int line, int pos,
- enum roff_type type, int tok)
-{
- struct roff_node *p;
-
- p = mandoc_calloc(1, sizeof(*p));
- p->line = line;
- p->pos = pos;
- p->type = type;
- p->tok = tok;
-
- if (man->flags & MAN_NEWLINE)
- p->flags |= MAN_LINE;
- man->flags &= ~MAN_NEWLINE;
- return(p);
-}
-
-void
-man_elem_alloc(struct roff_man *man, int line, int pos, int tok)
-{
- struct roff_node *p;
-
- p = man_node_alloc(man, line, pos, ROFFT_ELEM, tok);
- man_node_append(man, p);
- man->next = ROFF_NEXT_CHILD;
-}
-
-void
-man_head_alloc(struct roff_man *man, int line, int pos, int tok)
-{
- struct roff_node *p;
-
- p = man_node_alloc(man, line, pos, ROFFT_HEAD, tok);
- man_node_append(man, p);
- man->next = ROFF_NEXT_CHILD;
-}
-
-void
-man_body_alloc(struct roff_man *man, int line, int pos, int tok)
-{
- struct roff_node *p;
-
- p = man_node_alloc(man, line, pos, ROFFT_BODY, tok);
- man_node_append(man, p);
- man->next = ROFF_NEXT_CHILD;
-}
-
-void
-man_block_alloc(struct roff_man *man, int line, int pos, int tok)
-{
- struct roff_node *p;
-
- p = man_node_alloc(man, line, pos, ROFFT_BLOCK, tok);
- man_node_append(man, p);
- man->next = ROFF_NEXT_CHILD;
-}
-
-void
-man_word_alloc(struct roff_man *man, int line, int pos, const char *word)
-{
- struct roff_node *n;
-
- n = man_node_alloc(man, line, pos, ROFFT_TEXT, MAN_MAX);
- n->string = roff_strdup(man->roff, word);
- man_node_append(man, n);
- man->next = ROFF_NEXT_SIBLING;
-}
-
-void
-man_word_append(struct roff_man *man, const char *word)
-{
- struct roff_node *n;
- char *addstr, *newstr;
-
- n = man->last;
- addstr = roff_strdup(man->roff, word);
- mandoc_asprintf(&newstr, "%s %s", n->string, addstr);
- free(addstr);
- free(n->string);
- n->string = newstr;
- man->next = ROFF_NEXT_SIBLING;