-
-
-/* ARGSUSED */
-static int
-termp_xr_pre(DECL_ARGS)
-{
- const struct mdoc_node *n;
-
- if (NULL == (n = node->child))
- errx(1, "expected text line argument");
- if (MDOC_TEXT != n->type)
- errx(1, "expected text line argument");
-
- word(p, n->string);
-
- if (NULL == (n = n->next))
- return(0);
- if (MDOC_TEXT != n->type)
- errx(1, "expected text line argument");
-
- p->flags |= TERMP_NOSPACE;
- word(p, "(");
- p->flags |= TERMP_NOSPACE;
- word(p, n->string);
- p->flags |= TERMP_NOSPACE;
- word(p, ")");
-
- return(0);
-}
-
-
-/* ARGSUSED */
-static int
-termp_vt_pre(DECL_ARGS)
-{
-
- /* FIXME: this can be "type name". */
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_VAR_DECL]);
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_vt_post(DECL_ARGS)
-{
-
- if (node->sec == SEC_SYNOPSIS)
- vspace(p);
-}
-
-
-/* ARGSUSED */
-static int
-termp_fd_pre(DECL_ARGS)
-{
-
- /*
- * FIXME: this naming is bad. This value is used, in general,
- * for the #include header or other preprocessor statement.
- */
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_FUNC_DECL]);
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_fd_post(DECL_ARGS)
-{
-
- if (node->sec != SEC_SYNOPSIS)
- return;
- newln(p);
- if (node->next && MDOC_Fd != node->next->tok)
- vspace(p);
-}
-
-
-/* ARGSUSED */
-static int
-termp_sh_pre(DECL_ARGS)
-{
-
- switch (node->type) {
- case (MDOC_HEAD):
- vspace(p);
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_SECTION]);
- break;
- case (MDOC_BODY):
- p->offset = INDENT;
- break;
- default:
- break;
- }
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_sh_post(DECL_ARGS)
-{
-
- switch (node->type) {
- case (MDOC_HEAD):
- newln(p);
- break;
- case (MDOC_BODY):
- newln(p);
- p->offset = 0;
- break;
- default:
- break;
- }
-}
-
-
-/* ARGSUSED */
-static int
-termp_op_pre(DECL_ARGS)
-{
-
- switch (node->type) {
- case (MDOC_BODY):
- word(p, "\\(lB");
- p->flags |= TERMP_NOSPACE;
- break;
- default:
- break;
- }
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_bt_pre(DECL_ARGS)
-{
-
- word(p, "is currently in beta test.");
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_lb_pre(DECL_ARGS)
-{
- const char *lb;
-
- if (NULL == node->child)
- errx(1, "expected text line argument");
- if (MDOC_TEXT != node->child->type)
- errx(1, "expected text line argument");
-
- if ((lb = mdoc_a2lib(node->child->string))) {
- word(p, lb);
- return(0);
- }
-
- word(p, "library");
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_lb_post(DECL_ARGS)
-{
-
- newln(p);
-}
-
-
-/* ARGSUSED */
-static int
-termp_ud_pre(DECL_ARGS)
-{
-
- word(p, "currently under development.");
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_d1_pre(DECL_ARGS)
-{
-
- if (MDOC_BODY != node->type)
- return(1);
- newln(p);
- p->offset += (pair->offset = INDENT);
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_d1_post(DECL_ARGS)
-{
-
- if (MDOC_BODY != node->type)
- return;
- newln(p);
- p->offset -= pair->offset;
-}
-
-
-/* ARGSUSED */
-static int
-termp_aq_pre(DECL_ARGS)
-{
-
- if (MDOC_BODY != node->type)
- return(1);
- word(p, "\\(la");
- p->flags |= TERMP_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_aq_post(DECL_ARGS)
-{
-
- if (MDOC_BODY != node->type)
- return;
- p->flags |= TERMP_NOSPACE;
- word(p, "\\(ra");
-}
-
-
-/* ARGSUSED */
-static int
-termp_ft_pre(DECL_ARGS)
-{
-
- if (SEC_SYNOPSIS == node->sec)
- if (node->prev && MDOC_Fo == node->prev->tok)
- vspace(p);
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_FUNC_TYPE]);
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_ft_post(DECL_ARGS)
-{
-
- if (SEC_SYNOPSIS == node->sec)
- newln(p);
-}
-
-
-/* ARGSUSED */
-static int
-termp_fn_pre(DECL_ARGS)
-{
- const struct mdoc_node *n;
-
- if (NULL == node->child)
- errx(1, "expected text line arguments");
- if (MDOC_TEXT != node->child->type)
- errx(1, "expected text line arguments");
-
- /* FIXME: can be "type funcname" "type varname"... */
-
- p->flags |= ttypes[TTYPE_FUNC_NAME];
- word(p, node->child->string);
- p->flags &= ~ttypes[TTYPE_FUNC_NAME];
-
- word(p, "(");
-
- p->flags |= TERMP_NOSPACE;
- for (n = node->child->next; n; n = n->next) {
- if (MDOC_TEXT != n->type)
- errx(1, "expected text line arguments");
- p->flags |= ttypes[TTYPE_FUNC_ARG];
- word(p, n->string);
- p->flags &= ~ttypes[TTYPE_FUNC_ARG];
- if (n->next)
- word(p, ",");
- }
-
- word(p, ")");
-
- if (SEC_SYNOPSIS == node->sec)
- word(p, ";");
-
- return(0);
-}
-
-
-/* ARGSUSED */
-static void
-termp_fn_post(DECL_ARGS)
-{
-
- if (node->sec == SEC_SYNOPSIS && node->next)
- vspace(p);
-
-}
-
-
-/* ARGSUSED */
-static int
-termp_sx_pre(DECL_ARGS)
-{
-
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_LINK]);
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_fa_pre(DECL_ARGS)
-{
- struct mdoc_node *n;
-
- if (node->parent->tok != MDOC_Fo) {
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_FUNC_ARG]);
- return(1);
- }
-
- for (n = node->child; n; n = n->next) {
- if (MDOC_TEXT != n->type)
- errx(1, "expected text line arguments");
-
- p->flags |= ttypes[TTYPE_FUNC_ARG];
- word(p, n->string);
- p->flags &= ~ttypes[TTYPE_FUNC_ARG];
-
- if (n->next)
- word(p, ",");
- }
-
- if (node->next && node->next->tok == MDOC_Fa)
- word(p, ",");
-
- return(0);
-}
-
-
-/* ARGSUSED */
-static int
-termp_va_pre(DECL_ARGS)
-{
-
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_VAR_DECL]);
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_bd_pre(DECL_ARGS)
-{
- const struct mdoc_node *n;
- int i, type;
-
- if (MDOC_BLOCK == node->type) {
- if (node->prev)
- vspace(p);
- return(1);
- } else if (MDOC_BODY != node->type)
- return(1);
-
- if (NULL == node->parent->args)
- errx(1, "missing display type");
-
- pair->offset = p->offset;
-
- for (type = -1, i = 0;
- i < (int)node->parent->args->argc; i++) {
- switch (node->parent->args->argv[i].arg) {
- case (MDOC_Ragged):
- /* FALLTHROUGH */
- case (MDOC_Filled):
- /* FALLTHROUGH */
- case (MDOC_Unfilled):
- /* FALLTHROUGH */
- case (MDOC_Literal):
- type = node->parent->args->argv[i].arg;
- i = (int)node->parent->args->argc;
- break;
- default:
- break;
- }
- }
-
- if (NULL == node->parent->args)
- errx(1, "missing display type");
-
- i = arg_getattr(MDOC_Offset, node->parent);
- if (-1 != i) {
- if (1 != node->parent->args->argv[i].sz)
- errx(1, "expected single value");
- p->offset += arg_offset(&node->parent->args->argv[i]);
- }
-
- switch (type) {
- case (MDOC_Literal):
- /* FALLTHROUGH */
- case (MDOC_Unfilled):
- break;
- default:
- return(1);
- }
-
- p->flags |= TERMP_LITERAL;
-
- for (n = node->child; n; n = n->next) {
- if (MDOC_TEXT != n->type) {
- warnx("non-text children not yet allowed");
- continue;
- }
- word(p, n->string);
- flushln(p);
- }
-
- return(0);
-}
-
-
-/* ARGSUSED */
-static void
-termp_bd_post(DECL_ARGS)
-{
-
- if (MDOC_BODY != node->type)
- return;
-
- if ( ! (p->flags & TERMP_LITERAL))
- flushln(p);
-
- p->flags &= ~TERMP_LITERAL;
- p->offset = pair->offset;
-}
-
-
-/* ARGSUSED */
-static int
-termp_qq_pre(DECL_ARGS)
-{
-
- if (MDOC_BODY != node->type)
- return(1);
- word(p, "\"");
- p->flags |= TERMP_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_qq_post(DECL_ARGS)
-{
-
- if (MDOC_BODY != node->type)
- return;
- p->flags |= TERMP_NOSPACE;
- word(p, "\"");
-}
-
-
-/* ARGSUSED */
-static int
-termp_bsx_pre(DECL_ARGS)
-{
-
- word(p, "BSDI BSD/OS");
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_bx_post(DECL_ARGS)
-{
-
- if (node->child)
- p->flags |= TERMP_NOSPACE;
- word(p, "BSD");
-}
-
-
-/* ARGSUSED */
-static int
-termp_ox_pre(DECL_ARGS)
-{
-
- word(p, "OpenBSD");
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_ux_pre(DECL_ARGS)
-{
-
- word(p, "UNIX");
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_fx_pre(DECL_ARGS)
-{
-
- word(p, "FreeBSD");
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_nx_pre(DECL_ARGS)
-{
-
- word(p, "NetBSD");
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_sq_pre(DECL_ARGS)
-{
-
- if (MDOC_BODY != node->type)
- return(1);
- word(p, "`");
- p->flags |= TERMP_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_sq_post(DECL_ARGS)
-{
-
- if (MDOC_BODY != node->type)
- return;
- p->flags |= TERMP_NOSPACE;
- word(p, "\'");
-}
-
-
-/* ARGSUSED */
-static int
-termp_pf_pre(DECL_ARGS)
-{
-
- p->flags |= TERMP_IGNDELIM;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_pf_post(DECL_ARGS)
-{
-
- p->flags &= ~TERMP_IGNDELIM;
- p->flags |= TERMP_NOSPACE;
-}
-
-
-/* ARGSUSED */
-static int
-termp_ss_pre(DECL_ARGS)
-{
-
- switch (node->type) {
- case (MDOC_HEAD):
- vspace(p);
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_SSECTION]);
- p->offset = INDENT / 2;
- break;
- default:
- break;
- }
-
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_ss_post(DECL_ARGS)
-{
-
- switch (node->type) {
- case (MDOC_HEAD):
- newln(p);
- p->offset = INDENT;
- break;
- default:
- break;
- }
-}
-
-
-/* ARGSUSED */
-static int
-termp_pa_pre(DECL_ARGS)
-{
-
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_FILE]);
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_em_pre(DECL_ARGS)
-{
-
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_EMPH]);
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_cd_pre(DECL_ARGS)
-{
-
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_CONFIG]);
- newln(p);
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_cm_pre(DECL_ARGS)
-{
-
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_CMD_FLAG]);
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_ic_pre(DECL_ARGS)
-{
-
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_CMD]);
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_in_pre(DECL_ARGS)
-{
-
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_INCLUDE]);
- word(p, "#include");
- word(p, "<");
- p->flags |= TERMP_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_in_post(DECL_ARGS)
-{
-
- p->flags |= TERMP_NOSPACE;
- word(p, ">");
-
- newln(p);
- if (SEC_SYNOPSIS != node->sec)
- return;
- if (node->next && MDOC_In != node->next->tok)
- vspace(p);
-}
-
-
-/* ARGSUSED */
-static int
-termp_at_pre(DECL_ARGS)
-{
- const char *att;
-
- att = NULL;
-
- if (node->child) {
- if (MDOC_TEXT != node->child->type)
- errx(1, "expected text line argument");
- att = mdoc_a2att(node->child->string);
- }
-
- if (NULL == att)
- att = "AT&T UNIX";
-
- word(p, att);
- return(0);
-}
-
-
-/* ARGSUSED */
-static int
-termp_bq_pre(DECL_ARGS)
-{
-
- if (MDOC_BODY != node->type)
- return(1);
- word(p, "[");
- p->flags |= TERMP_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_bq_post(DECL_ARGS)
-{
-
- if (MDOC_BODY != node->type)
- return;
- word(p, "]");
-}
-
-
-/* ARGSUSED */
-static int
-termp_pq_pre(DECL_ARGS)
-{
-
- if (MDOC_BODY != node->type)
- return(1);
- word(p, "\\&(");
- p->flags |= TERMP_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_pq_post(DECL_ARGS)
-{
-
- if (MDOC_BODY != node->type)
- return;
- word(p, ")");
-}
-
-
-/* ARGSUSED */
-static int
-termp_fo_pre(DECL_ARGS)
-{
- const struct mdoc_node *n;
-
- if (MDOC_BODY == node->type) {
- word(p, "(");
- p->flags |= TERMP_NOSPACE;
- return(1);
- } else if (MDOC_HEAD != node->type)
- return(1);
-
- /* XXX - groff shows only first parameter */
-
- p->flags |= ttypes[TTYPE_FUNC_NAME];
- for (n = node->child; n; n = n->next) {
- if (MDOC_TEXT != n->type)
- errx(1, "expected text line argument");
- word(p, n->string);
- }
- p->flags &= ~ttypes[TTYPE_FUNC_NAME];
-
- return(0);
-}
-
-
-/* ARGSUSED */
-static void
-termp_fo_post(DECL_ARGS)
-{
-
- if (MDOC_BODY != node->type)
- return;
- word(p, ")");
- word(p, ";");
- newln(p);
-}
-
-
-/* ARGSUSED */
-static int
-termp_bf_pre(DECL_ARGS)
-{
- const struct mdoc_node *n;
-
- if (MDOC_HEAD == node->type) {
- return(0);
- } else if (MDOC_BLOCK != node->type)
- return(1);
-
- if (NULL == (n = node->head->child)) {
- if (arg_hasattr(MDOC_Emphasis, node))
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_EMPH]);
- else if (arg_hasattr(MDOC_Symbolic, node))
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_SYMB]);
-
- return(1);
- }
-
- if (MDOC_TEXT != n->type)
- errx(1, "expected text line arguments");
-
- if (0 == strcmp("Em", n->string))
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_EMPH]);
- else if (0 == strcmp("Sy", n->string))
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_EMPH]);
-
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_sy_pre(DECL_ARGS)
-{
-
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_SYMB]);
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp_ms_pre(DECL_ARGS)
-{
-
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_SYMBOL]);
- return(1);
-}
-
-
-
-/* ARGSUSED */
-static int
-termp_sm_pre(DECL_ARGS)
-{
-
-#if notyet
- assert(node->child);
- if (0 == strcmp("off", node->child->data.text.string)) {
- p->flags &= ~TERMP_NONOSPACE;
- p->flags &= ~TERMP_NOSPACE;
- } else {
- p->flags |= TERMP_NONOSPACE;
- p->flags |= TERMP_NOSPACE;
- }
-#endif
-
- return(0);
-}
-
-
-/* ARGSUSED */
-static int
-termp_ap_pre(DECL_ARGS)
-{
-
- p->flags |= TERMP_NOSPACE;
- word(p, "\\(aq");
- p->flags |= TERMP_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static int
-termp__t_pre(DECL_ARGS)
-{
-
- /* FIXME: titles are underlined. */
- word(p, "\"");
- p->flags |= TERMP_NOSPACE;
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp__t_post(DECL_ARGS)
-{
-
- p->flags |= TERMP_NOSPACE;
- /* FIXME: titles are underlined. */
- word(p, "\"");
- word(p, node->next ? "," : ".");
-}
-
-
-/* ARGSUSED */
-static void
-termp____post(DECL_ARGS)
-{
-
- p->flags |= TERMP_NOSPACE;
- word(p, node->next ? "," : ".");
-}
-
-
-/* ARGSUSED */
-static int
-termp_lk_pre(DECL_ARGS)
-{
- const struct mdoc_node *n;
-
- if (NULL == (n = node->child))
- errx(1, "expected text line argument");
- if (MDOC_TEXT != n->type)
- errx(1, "expected text line argument");
-
- p->flags |= ttypes[TTYPE_LINK_ANCHOR];
- word(p, n->string);
- p->flags &= ~ttypes[TTYPE_LINK_ANCHOR];
- p->flags |= TERMP_NOSPACE;
- word(p, ":");
-
- p->flags |= ttypes[TTYPE_LINK_TEXT];
- for ( ; n; n = n->next) {
- if (MDOC_TEXT != n->type)
- errx(1, "expected text line argument");
- word(p, n->string);
- }
- p->flags &= ~ttypes[TTYPE_LINK_TEXT];
-
- return(0);
-}
-
-
-/* ARGSUSED */
-static int
-termp_mt_pre(DECL_ARGS)
-{
-
- TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_LINK_ANCHOR]);
- return(1);
-}
-