+pre_en(DECL_ARGS)
+{
+
+ if (NULL == n->norm->Es ||
+ NULL == n->norm->Es->child)
+ return(1);
+
+ print_word(n->norm->Es->child->string);
+ outflags &= ~MMAN_spc;
+ return(1);
+}
+
+static void
+post_en(DECL_ARGS)
+{
+
+ if (NULL == n->norm->Es ||
+ NULL == n->norm->Es->child ||
+ NULL == n->norm->Es->child->next)
+ return;
+
+ outflags &= ~MMAN_spc;
+ print_word(n->norm->Es->child->next->string);
+ return;
+}
+
+static int
+pre_eo(DECL_ARGS)
+{
+
+ if (n->end == ENDBODY_NOT &&
+ n->parent->head->child == NULL &&
+ n->child != NULL &&
+ n->child->end != ENDBODY_NOT)
+ print_word("\\&");
+ else if (n->end != ENDBODY_NOT ? n->child != NULL :
+ n->parent->head->child != NULL && (n->child != NULL ||
+ (n->parent->tail != NULL && n->parent->tail->child != NULL)))
+ outflags &= ~(MMAN_spc | MMAN_nl);
+ return(1);
+}
+
+static void
+post_eo(DECL_ARGS)
+{
+ int body, tail;
+
+ if (n->end != ENDBODY_NOT) {
+ outflags |= MMAN_spc;
+ return;
+ }
+
+ body = n->child != NULL || n->parent->head->child != NULL;
+ tail = n->parent->tail != NULL && n->parent->tail->child != NULL;
+
+ if (body && tail)
+ outflags &= ~MMAN_spc;
+ else if ( ! (body || tail))
+ print_word("\\&");
+ else if ( ! tail)
+ outflags |= MMAN_spc;
+}
+
+static int
+pre_fa(DECL_ARGS)
+{
+ int am_Fa;
+
+ am_Fa = MDOC_Fa == n->tok;
+
+ if (am_Fa)
+ n = n->child;
+
+ while (NULL != n) {
+ font_push('I');
+ if (am_Fa || MDOC_SYNPRETTY & n->flags)
+ outflags |= MMAN_nbrword;
+ print_node(meta, n);
+ font_pop();
+ if (NULL != (n = n->next))
+ print_word(",");
+ }
+ return(0);
+}
+
+static void
+post_fa(DECL_ARGS)
+{
+
+ if (NULL != n->next && MDOC_Fa == n->next->tok)
+ print_word(",");
+}
+
+static int
+pre_fd(DECL_ARGS)
+{
+
+ pre_syn(n);
+ font_push('B');
+ return(1);
+}
+
+static void
+post_fd(DECL_ARGS)
+{
+
+ font_pop();
+ outflags |= MMAN_br;
+}
+
+static int
+pre_fl(DECL_ARGS)
+{
+
+ font_push('B');
+ print_word("\\-");
+ if (n->nchild)
+ outflags &= ~MMAN_spc;
+ return(1);
+}
+
+static void
+post_fl(DECL_ARGS)
+{
+
+ font_pop();
+ if ( ! (n->nchild ||
+ n->next == NULL ||
+ n->next->type == MDOC_TEXT ||
+ n->next->flags & MDOC_LINE))
+ outflags &= ~MMAN_spc;
+}
+
+static int
+pre_fn(DECL_ARGS)
+{
+
+ pre_syn(n);
+
+ n = n->child;
+ if (NULL == n)
+ return(0);
+
+ if (MDOC_SYNPRETTY & n->flags)
+ print_block(".HP 4n", MMAN_nl);
+
+ font_push('B');
+ print_node(meta, n);
+ font_pop();
+ outflags &= ~MMAN_spc;
+ print_word("(");
+ outflags &= ~MMAN_spc;
+
+ n = n->next;
+ if (NULL != n)
+ pre_fa(meta, n);
+ return(0);
+}
+
+static void
+post_fn(DECL_ARGS)
+{
+
+ print_word(")");
+ if (MDOC_SYNPRETTY & n->flags) {
+ print_word(";");
+ outflags |= MMAN_PP;
+ }
+}
+
+static int
+pre_fo(DECL_ARGS)
+{
+
+ switch (n->type) {
+ case MDOC_BLOCK:
+ pre_syn(n);
+ break;
+ case MDOC_HEAD:
+ if (n->child == NULL)
+ return(0);
+ if (MDOC_SYNPRETTY & n->flags)
+ print_block(".HP 4n", MMAN_nl);
+ font_push('B');
+ break;
+ case MDOC_BODY:
+ outflags &= ~(MMAN_spc | MMAN_nl);
+ print_word("(");
+ outflags &= ~MMAN_spc;
+ break;
+ default:
+ break;
+ }
+ return(1);
+}
+
+static void
+post_fo(DECL_ARGS)
+{
+
+ switch (n->type) {
+ case MDOC_HEAD:
+ if (n->child != NULL)
+ font_pop();
+ break;
+ case MDOC_BODY:
+ post_fn(meta, n);
+ break;
+ default:
+ break;
+ }
+}
+
+static int
+pre_ft(DECL_ARGS)
+{
+
+ pre_syn(n);
+ font_push('I');
+ return(1);
+}
+
+static int
+pre_in(DECL_ARGS)
+{
+
+ if (MDOC_SYNPRETTY & n->flags) {
+ pre_syn(n);
+ font_push('B');
+ print_word("#include <");
+ outflags &= ~MMAN_spc;
+ } else {
+ print_word("<");
+ outflags &= ~MMAN_spc;
+ font_push('I');
+ }
+ return(1);
+}
+
+static void
+post_in(DECL_ARGS)
+{
+
+ if (MDOC_SYNPRETTY & n->flags) {
+ outflags &= ~MMAN_spc;
+ print_word(">");
+ font_pop();
+ outflags |= MMAN_br;
+ } else {
+ font_pop();
+ outflags &= ~MMAN_spc;
+ print_word(">");
+ }
+}
+
+static int
+pre_it(DECL_ARGS)
+{
+ const struct mdoc_node *bln;
+
+ switch (n->type) {
+ case MDOC_HEAD:
+ outflags |= MMAN_PP | MMAN_nl;
+ bln = n->parent->parent;
+ if (0 == bln->norm->Bl.comp ||
+ (NULL == n->parent->prev &&
+ NULL == bln->parent->prev))
+ outflags |= MMAN_sp;
+ outflags &= ~MMAN_br;
+ switch (bln->norm->Bl.type) {
+ case LIST_item:
+ return(0);
+ case LIST_inset:
+ /* FALLTHROUGH */
+ case LIST_diag:
+ /* FALLTHROUGH */
+ case LIST_ohang:
+ if (bln->norm->Bl.type == LIST_diag)
+ print_line(".B \"", 0);
+ else
+ print_line(".R \"", 0);
+ outflags &= ~MMAN_spc;
+ return(1);
+ case LIST_bullet:
+ /* FALLTHROUGH */
+ case LIST_dash:
+ /* FALLTHROUGH */
+ case LIST_hyphen:
+ print_width(&bln->norm->Bl, NULL);
+ TPremain = 0;
+ outflags |= MMAN_nl;
+ font_push('B');
+ if (LIST_bullet == bln->norm->Bl.type)
+ print_word("\\(bu");
+ else
+ print_word("-");
+ font_pop();
+ outflags |= MMAN_nl;
+ return(0);
+ case LIST_enum:
+ print_width(&bln->norm->Bl, NULL);
+ TPremain = 0;
+ outflags |= MMAN_nl;
+ print_count(&bln->norm->Bl.count);
+ outflags |= MMAN_nl;
+ return(0);
+ case LIST_hang:
+ print_width(&bln->norm->Bl, n->child);
+ TPremain = 0;
+ outflags |= MMAN_nl;
+ return(1);
+ case LIST_tag:
+ print_width(&bln->norm->Bl, n->child);
+ putchar('\n');
+ outflags &= ~MMAN_spc;
+ return(1);
+ default:
+ return(1);
+ }
+ default:
+ break;
+ }
+ return(1);
+}
+
+/*
+ * This function is called after closing out an indented block.
+ * If we are inside an enclosing list, restore its indentation.
+ */
+static void
+mid_it(void)
+{
+ char buf[24];
+
+ /* Nothing to do outside a list. */
+ if (0 == Bl_stack_len || 0 == Bl_stack[Bl_stack_len - 1])
+ return;
+
+ /* The indentation has already been set up. */
+ if (Bl_stack_post[Bl_stack_len - 1])
+ return;
+
+ /* Restore the indentation of the enclosing list. */
+ print_line(".RS", MMAN_Bk_susp);
+ (void)snprintf(buf, sizeof(buf), "%dn",
+ Bl_stack[Bl_stack_len - 1]);
+ print_word(buf);
+
+ /* Remeber to close out this .RS block later. */
+ Bl_stack_post[Bl_stack_len - 1] = 1;
+}
+
+static void
+post_it(DECL_ARGS)
+{
+ const struct mdoc_node *bln;
+
+ bln = n->parent->parent;
+
+ switch (n->type) {
+ case MDOC_HEAD:
+ switch (bln->norm->Bl.type) {
+ case LIST_diag:
+ outflags &= ~MMAN_spc;
+ print_word("\\ ");
+ break;
+ case LIST_ohang:
+ outflags |= MMAN_br;
+ break;
+ default:
+ break;
+ }
+ break;
+ case MDOC_BODY:
+ switch (bln->norm->Bl.type) {
+ case LIST_bullet:
+ /* FALLTHROUGH */
+ case LIST_dash:
+ /* FALLTHROUGH */
+ case LIST_hyphen:
+ /* FALLTHROUGH */
+ case LIST_enum:
+ /* FALLTHROUGH */
+ case LIST_hang:
+ /* FALLTHROUGH */
+ case LIST_tag:
+ assert(Bl_stack_len);
+ Bl_stack[--Bl_stack_len] = 0;
+
+ /*
+ * Our indentation had to be restored
+ * after a child display or child list.
+ * Close out that indentation block now.
+ */
+ if (Bl_stack_post[Bl_stack_len]) {
+ print_line(".RE", MMAN_nl);
+ Bl_stack_post[Bl_stack_len] = 0;
+ }
+ break;
+ case LIST_column:
+ if (NULL != n->next) {
+ putchar('\t');
+ outflags &= ~MMAN_spc;
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+post_lb(DECL_ARGS)
+{
+
+ if (SEC_LIBRARY == n->sec)
+ outflags |= MMAN_br;
+}
+
+static int
+pre_lk(DECL_ARGS)
+{
+ const struct mdoc_node *link, *descr;
+
+ if (NULL == (link = n->child))
+ return(0);
+
+ if (NULL != (descr = link->next)) {
+ font_push('I');
+ while (NULL != descr) {
+ print_word(descr->string);
+ descr = descr->next;
+ }
+ print_word(":");
+ font_pop();
+ }
+
+ font_push('B');
+ print_word(link->string);
+ font_pop();
+ return(0);
+}
+
+static int
+pre_ll(DECL_ARGS)
+{
+
+ print_line(".ll", 0);
+ return(1);
+}
+
+static int
+pre_li(DECL_ARGS)
+{
+
+ font_push('R');
+ return(1);
+}
+
+static int
+pre_nm(DECL_ARGS)
+{
+ char *name;
+
+ if (MDOC_BLOCK == n->type) {
+ outflags |= MMAN_Bk;
+ pre_syn(n);
+ }
+ if (MDOC_ELEM != n->type && MDOC_HEAD != n->type)
+ return(1);
+ name = n->child ? n->child->string : meta->name;
+ if (NULL == name)
+ return(0);
+ if (MDOC_HEAD == n->type) {
+ if (NULL == n->parent->prev)
+ outflags |= MMAN_sp;
+ print_block(".HP", 0);
+ printf(" %zun", strlen(name) + 1);
+ outflags |= MMAN_nl;
+ }
+ font_push('B');
+ if (NULL == n->child)
+ print_word(meta->name);
+ return(1);
+}
+
+static void
+post_nm(DECL_ARGS)
+{
+
+ switch (n->type) {
+ case MDOC_BLOCK:
+ outflags &= ~MMAN_Bk;
+ break;
+ case MDOC_HEAD:
+ /* FALLTHROUGH */
+ case MDOC_ELEM:
+ if (n->child != NULL || meta->name != NULL)
+ font_pop();
+ break;
+ default:
+ break;
+ }
+}
+
+static int
+pre_no(DECL_ARGS)
+{
+
+ outflags |= MMAN_spc_force;
+ return(1);
+}
+
+static int
+pre_ns(DECL_ARGS)
+{
+
+ outflags &= ~MMAN_spc;
+ return(0);
+}
+
+static void
+post_pf(DECL_ARGS)
+{
+
+ if ( ! (n->next == NULL || n->next->flags & MDOC_LINE))
+ outflags &= ~MMAN_spc;
+}
+
+static int
+pre_pp(DECL_ARGS)
+{
+
+ if (MDOC_It != n->parent->tok)
+ outflags |= MMAN_PP;
+ outflags |= MMAN_sp | MMAN_nl;
+ outflags &= ~MMAN_br;
+ return(0);
+}
+
+static int
+pre_rs(DECL_ARGS)
+{
+
+ if (SEC_SEE_ALSO == n->sec) {
+ outflags |= MMAN_PP | MMAN_sp | MMAN_nl;
+ outflags &= ~MMAN_br;
+ }
+ return(1);
+}
+
+static int
+pre_rv(DECL_ARGS)
+{
+ int nchild;
+
+ outflags |= MMAN_br | MMAN_nl;
+
+ nchild = n->nchild;
+ if (nchild > 0) {
+ print_word("The");
+
+ for (n = n->child; n; n = n->next) {
+ font_push('B');
+ print_word(n->string);
+ font_pop();
+
+ outflags &= ~MMAN_spc;
+ print_word("()");
+
+ if (n->next == NULL)
+ continue;
+
+ if (nchild > 2) {
+ outflags &= ~MMAN_spc;
+ print_word(",");
+ }
+ if (n->next->next == NULL)
+ print_word("and");
+ }
+
+ if (nchild > 1)
+ print_word("functions return");
+ else
+ print_word("function returns");
+
+ print_word("the value\\~0 if successful;");
+ } else
+ print_word("Upon successful completion, "
+ "the value\\~0 is returned;");
+
+ print_word("otherwise the value\\~\\-1 is returned"
+ " and the global variable");
+
+ font_push('I');
+ print_word("errno");
+ font_pop();
+
+ print_word("is set to indicate the error.");
+ outflags |= MMAN_nl;
+ return(0);
+}
+
+static int
+pre_skip(DECL_ARGS)
+{
+
+ return(0);
+}
+
+static int
+pre_sm(DECL_ARGS)
+{
+
+ if (NULL == n->child)
+ outflags ^= MMAN_Sm;
+ else if (0 == strcmp("on", n->child->string))
+ outflags |= MMAN_Sm;
+ else
+ outflags &= ~MMAN_Sm;
+
+ if (MMAN_Sm & outflags)
+ outflags |= MMAN_spc;
+
+ return(0);
+}
+
+static int
+pre_sp(DECL_ARGS)
+{
+
+ if (MMAN_PP & outflags) {
+ outflags &= ~MMAN_PP;
+ print_line(".PP", 0);
+ } else
+ print_line(".sp", 0);
+ return(1);
+}
+
+static void
+post_sp(DECL_ARGS)
+{
+
+ outflags |= MMAN_nl;
+}
+
+static int
+pre_sy(DECL_ARGS)
+{
+
+ font_push('B');
+ return(1);
+}
+
+static int
+pre_vt(DECL_ARGS)
+{
+
+ if (MDOC_SYNPRETTY & n->flags) {
+ switch (n->type) {
+ case MDOC_BLOCK:
+ pre_syn(n);
+ return(1);
+ case MDOC_BODY:
+ break;
+ default:
+ return(0);
+ }
+ }
+ font_push('I');
+ return(1);
+}
+
+static void
+post_vt(DECL_ARGS)
+{
+
+ if (MDOC_SYNPRETTY & n->flags && MDOC_BODY != n->type)
+ return;
+ font_pop();
+}
+
+static int
+pre_xr(DECL_ARGS)