-static void
-mdoc_node_free(struct mdoc_node *p)
-{
-
- if (MDOC_BLOCK == p->type || MDOC_ELEM == p->type)
- free(p->norm);
- if (p->string)
- free(p->string);
- if (p->args)
- mdoc_argv_free(p->args);
- free(p);
-}
-
-static void
-mdoc_node_unlink(struct mdoc *mdoc, struct mdoc_node *n)
-{
-
- /* Adjust siblings. */
-
- if (n->prev)
- n->prev->next = n->next;
- if (n->next)
- n->next->prev = n->prev;
-
- /* Adjust parent. */
-
- if (n->parent) {
- n->parent->nchild--;
- if (n->parent->child == n)
- n->parent->child = n->prev ? n->prev : n->next;
- if (n->parent->last == n)
- n->parent->last = n->prev ? n->prev : NULL;
- }
-
- /* Adjust parse point, if applicable. */
-
- if (mdoc && mdoc->last == n) {
- if (n->prev) {
- mdoc->last = n->prev;
- mdoc->next = MDOC_NEXT_SIBLING;
- } else {
- mdoc->last = n->parent;
- mdoc->next = MDOC_NEXT_CHILD;
- }
- }
-
- if (mdoc && mdoc->first == n)
- mdoc->first = NULL;
-}
-
-void
-mdoc_node_delete(struct mdoc *mdoc, struct mdoc_node *p)
-{
-
- while (p->child) {
- assert(p->nchild);
- mdoc_node_delete(mdoc, p->child);
- }
- assert(0 == p->nchild);
-
- mdoc_node_unlink(mdoc, p);
- mdoc_node_free(p);
-}
-
-int
-mdoc_node_relink(struct mdoc *mdoc, struct mdoc_node *p)
-{
-
- mdoc_node_unlink(mdoc, p);
- return(node_append(mdoc, p));
-}
-
-#if 0
-/*
- * Pre-treat a text line.
- * Text lines can consist of equations, which must be handled apart from
- * the regular text.
- * Thus, use this function to step through a line checking if it has any
- * equations embedded in it.
- * This must handle multiple equations AND equations that do not end at
- * the end-of-line, i.e., will re-enter in the next roff parse.
- */
-static int
-mdoc_preptext(struct mdoc *mdoc, int line, char *buf, int offs)
-{
- char *start, *end;
- char delim;
-
- while ('\0' != buf[offs]) {
- /* Mark starting position if eqn is set. */
- start = NULL;
- if ('\0' != (delim = roff_eqndelim(mdoc->roff)))
- if (NULL != (start = strchr(buf + offs, delim)))
- *start++ = '\0';
-
- /* Parse text as normal. */
- if ( ! mdoc_ptext(mdoc, line, buf, offs))
- return(0);
-
- /* Continue only if an equation exists. */
- if (NULL == start)
- break;
-
- /* Read past the end of the equation. */
- offs += start - (buf + offs);
- assert(start == &buf[offs]);
- if (NULL != (end = strchr(buf + offs, delim))) {
- *end++ = '\0';
- while (' ' == *end)
- end++;
- }
-
- /* Parse the equation itself. */
- roff_openeqn(mdoc->roff, NULL, line, offs, buf);
-
- /* Process a finished equation? */
- if (roff_closeeqn(mdoc->roff))
- if ( ! mdoc_addeqn(mdoc, roff_eqn(mdoc->roff)))
- return(0);
- offs += (end - (buf + offs));
- }
-
- return(1);
-}
-#endif
-