/* ARGSUSED */ static int termp_fn_pre(DECL_ARGS) { const struct mdoc_node *nn; synopsis_pre(p, n); term_fontpush(p, TERMFONT_BOLD); term_word(p, n->child->string); term_fontpop(p); p->flags |= TERMP_NOSPACE; term_word(p, "("); for (nn = n->child->next; nn; nn = nn->next) { term_fontpush(p, TERMFONT_UNDER); term_word(p, nn->string); term_fontpop(p); if (nn->next) term_word(p, ","); } term_word(p, ")"); if (MDOC_SYNPRETTY & n->flags) term_word(p, ";"); return(0); }
/* ARGSUSED */ static int termp_lk_pre(DECL_ARGS) { const struct mdoc_node *nn, *sv; term_fontpush(p, TERMFONT_UNDER); nn = sv = n->child; if (NULL == nn || NULL == nn->next) return(1); for (nn = nn->next; nn; nn = nn->next) term_word(p, nn->string); term_fontpop(p); p->flags |= TERMP_NOSPACE; term_word(p, ":"); term_fontpush(p, TERMFONT_BOLD); term_word(p, sv->string); term_fontpop(p); return(0); }
/* ARGSUSED */ static int termp_fa_pre(DECL_ARGS) { const struct mdoc_node *nn; if (n->parent->tok != MDOC_Fo) { term_fontpush(p, TERMFONT_UNDER); return(1); } for (nn = n->child; nn; nn = nn->next) { term_fontpush(p, TERMFONT_UNDER); term_word(p, nn->string); term_fontpop(p); if (nn->next) { p->flags |= TERMP_NOSPACE; term_word(p, ","); } } if (n->child && n->next && n->next->tok == MDOC_Fa) { p->flags |= TERMP_NOSPACE; term_word(p, ","); } return(0); }
static int termp_lk_pre(DECL_ARGS) { const struct roff_node *link, *descr; if (NULL == (link = n->child)) return 0; if (NULL != (descr = link->next)) { term_fontpush(p, TERMFONT_UNDER); while (NULL != descr) { term_word(p, descr->string); descr = descr->next; } p->flags |= TERMP_NOSPACE; term_word(p, ":"); term_fontpop(p); } term_fontpush(p, TERMFONT_BOLD); term_word(p, link->string); term_fontpop(p); return 0; }
/* ARGSUSED */ static int termp_fn_pre(DECL_ARGS) { size_t rmargin = 0; int pretty; pretty = MDOC_SYNPRETTY & n->flags; synopsis_pre(p, n); if (NULL == (n = n->child)) return(0); if (pretty) { rmargin = p->rmargin; p->rmargin = p->offset + term_len(p, 4); p->flags |= TERMP_NOBREAK | TERMP_HANG; } assert(MDOC_TEXT == n->type); term_fontpush(p, TERMFONT_BOLD); term_word(p, n->string); term_fontpop(p); if (pretty) { term_flushln(p); p->flags &= ~(TERMP_NOBREAK | TERMP_HANG); p->offset = p->rmargin; p->rmargin = rmargin; } p->flags |= TERMP_NOSPACE; term_word(p, "("); p->flags |= TERMP_NOSPACE; for (n = n->next; n; n = n->next) { assert(MDOC_TEXT == n->type); term_fontpush(p, TERMFONT_UNDER); if (pretty) p->flags |= TERMP_NBRWORD; term_word(p, n->string); term_fontpop(p); if (n->next) { p->flags |= TERMP_NOSPACE; term_word(p, ","); } } p->flags |= TERMP_NOSPACE; term_word(p, ")"); if (pretty) { p->flags |= TERMP_NOSPACE; term_word(p, ";"); term_flushln(p); } return(0); }
static int termp_rv_pre(DECL_ARGS) { int nchild; term_newln(p); nchild = n->nchild; if (nchild > 0) { term_word(p, "The"); for (n = n->child; n; n = n->next) { term_fontpush(p, TERMFONT_BOLD); term_word(p, n->string); term_fontpop(p); p->flags |= TERMP_NOSPACE; term_word(p, "()"); if (n->next == NULL) continue; if (nchild > 2) { p->flags |= TERMP_NOSPACE; term_word(p, ","); } if (n->next->next == NULL) term_word(p, "and"); } if (nchild > 1) term_word(p, "functions return"); else term_word(p, "function returns"); term_word(p, "the value\\~0 if successful;"); } else term_word(p, "Upon successful completion," " the value\\~0 is returned;"); term_word(p, "otherwise the value\\~\\-1 is returned" " and the global variable"); term_fontpush(p, TERMFONT_UNDER); term_word(p, "errno"); term_fontpop(p); term_word(p, "is set to indicate the error."); p->flags |= TERMP_SENTENCE; return 0; }
static void tbl_word(struct termp *tp, const struct tbl_dat *dp) { const void *prev_font; prev_font = term_fontq(tp); if (dp->layout->flags & TBL_CELL_BOLD) term_fontpush(tp, TERMFONT_BOLD); else if (dp->layout->flags & TBL_CELL_ITALIC) term_fontpush(tp, TERMFONT_UNDER); term_word(tp, dp->string); term_fontpopq(tp, prev_font); }
static int termp_sh_pre(DECL_ARGS) { switch (n->type) { case MDOC_BLOCK: /* * Vertical space before sections, except * when the previous section was empty. */ if (n->prev == NULL || MDOC_Sh != n->prev->tok || (n->prev->body != NULL && n->prev->body->child != NULL)) term_vspace(p); break; case MDOC_HEAD: term_fontpush(p, TERMFONT_BOLD); break; case MDOC_BODY: p->offset = term_len(p, p->defindent); if (SEC_AUTHORS == n->sec) p->flags &= ~(TERMP_SPLIT|TERMP_NOSPLIT); break; default: break; } return(1); }
static void eqn_box(struct termp *p, const struct eqn_box *bp) { if (EQNFONT_NONE != bp->font) term_fontpush(p, fontmap[(int)bp->font]); if (bp->left) term_word(p, bp->left); if (EQN_SUBEXPR == bp->type) term_word(p, "("); if (bp->text) term_word(p, bp->text); if (bp->first) eqn_box(p, bp->first); if (EQN_SUBEXPR == bp->type) term_word(p, ")"); if (bp->right) term_word(p, bp->right); if (EQNFONT_NONE != bp->font) term_fontpop(p); if (bp->next) eqn_box(p, bp->next); }
static int termp_ex_pre(DECL_ARGS) { int nchild; term_newln(p); term_word(p, "The"); nchild = n->nchild; for (n = n->child; n; n = n->next) { term_fontpush(p, TERMFONT_BOLD); term_word(p, n->string); term_fontpop(p); if (nchild > 2 && n->next) { p->flags |= TERMP_NOSPACE; term_word(p, ","); } if (n->next && NULL == n->next->next) term_word(p, "and"); } if (nchild > 1) term_word(p, "utilities exit\\~0"); else term_word(p, "utility exits\\~0"); term_word(p, "on success, and\\~>0 if an error occurs."); p->flags |= TERMP_SENTENCE; return 0; }
static int termp_ex_pre(DECL_ARGS) { struct roff_node *nch; term_newln(p); term_word(p, "The"); for (nch = n->child; nch != NULL; nch = nch->next) { term_fontpush(p, TERMFONT_BOLD); term_word(p, nch->string); term_fontpop(p); if (nch->next == NULL) continue; if (nch->prev != NULL || nch->next->next != NULL) { p->flags |= TERMP_NOSPACE; term_word(p, ","); } if (nch->next->next == NULL) term_word(p, "and"); } if (n->child != NULL && n->child->next != NULL) term_word(p, "utilities exit\\~0"); else term_word(p, "utility exits\\~0"); term_word(p, "on success, and\\~>0 if an error occurs."); p->flags |= TERMP_SENTENCE; return 0; }
static int termp_li_pre(DECL_ARGS) { term_fontpush(p, TERMFONT_NONE); return 1; }
static int termp_under_pre(DECL_ARGS) { term_fontpush(p, TERMFONT_UNDER); return 1; }
/* ARGSUSED */ static int termp_sh_pre(DECL_ARGS) { /* No vspace between consecutive `Sh' calls. */ switch (n->type) { case (MDOC_BLOCK): if (n->prev && MDOC_Sh == n->prev->tok) if (NULL == n->prev->body->child) break; term_vspace(p); break; case (MDOC_HEAD): term_fontpush(p, TERMFONT_BOLD); break; case (MDOC_BODY): p->offset = term_len(p, p->defindent); if (SEC_AUTHORS == n->sec) p->flags &= ~(TERMP_SPLIT|TERMP_NOSPLIT); break; default: break; } return(1); }
/* ARGSUSED */ static int termp_bold_pre(DECL_ARGS) { term_fontpush(p, TERMFONT_BOLD); return(1); }
/* ARGSUSED */ static int termp_ex_pre(DECL_ARGS) { const struct mdoc_node *nn; term_word(p, "The"); for (nn = n->child; nn; nn = nn->next) { term_fontpush(p, TERMFONT_BOLD); term_word(p, nn->string); term_fontpop(p); p->flags |= TERMP_NOSPACE; if (nn->next && NULL == nn->next->next) term_word(p, ", and"); else if (nn->next) term_word(p, ","); else p->flags &= ~TERMP_NOSPACE; } if (n->child && n->child->next) term_word(p, "utilities exit"); else term_word(p, "utility exits"); term_word(p, "0 on success, and >0 if an error occurs."); p->flags |= TERMP_SENTENCE; return(0); }
static int termp_bold_pre(DECL_ARGS) { termp_tag_pre(p, pair, meta, n); term_fontpush(p, TERMFONT_BOLD); return 1; }
static int termp_cd_pre(DECL_ARGS) { synopsis_pre(p, n); term_fontpush(p, TERMFONT_BOLD); return 1; }
/* ARGSUSED */ static int termp_bf_pre(DECL_ARGS) { if (MDOC_HEAD == n->type) return(0); else if (MDOC_BODY != n->type) return(1); if (FONT_Em == n->norm->Bf.font) term_fontpush(p, TERMFONT_UNDER); else if (FONT_Sy == n->norm->Bf.font) term_fontpush(p, TERMFONT_BOLD); else term_fontpush(p, TERMFONT_NONE); return(1); }
static int termp_ft_pre(DECL_ARGS) { /* NB: MDOC_LINE does not effect this! */ synopsis_pre(p, n); term_fontpush(p, TERMFONT_UNDER); return 1; }
static int termp_bf_pre(DECL_ARGS) { if (n->type == ROFFT_HEAD) return 0; else if (n->type != ROFFT_BODY) return 1; if (FONT_Em == n->norm->Bf.font) term_fontpush(p, TERMFONT_UNDER); else if (FONT_Sy == n->norm->Bf.font) term_fontpush(p, TERMFONT_BOLD); else term_fontpush(p, TERMFONT_NONE); return 1; }
static int termp_in_pre(DECL_ARGS) { synopsis_pre(p, n); if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags) { term_fontpush(p, TERMFONT_BOLD); term_word(p, "#include"); term_word(p, "<"); } else { term_word(p, "<"); term_fontpush(p, TERMFONT_UNDER); } p->flags |= TERMP_NOSPACE; return 1; }
/* ARGSUSED */ static int termp_rv_pre(DECL_ARGS) { int nchild; term_newln(p); term_word(p, "The"); nchild = n->nchild; for (n = n->child; n; n = n->next) { term_fontpush(p, TERMFONT_BOLD); term_word(p, n->string); term_fontpop(p); p->flags |= TERMP_NOSPACE; term_word(p, "()"); if (nchild > 2 && n->next) { p->flags |= TERMP_NOSPACE; term_word(p, ","); } if (n->next && NULL == n->next->next) term_word(p, "and"); } if (nchild > 1) term_word(p, "functions return"); else term_word(p, "function returns"); term_word(p, "the value 0 if successful; otherwise the value " "-1 is returned and the global variable"); term_fontpush(p, TERMFONT_UNDER); term_word(p, "errno"); term_fontpop(p); term_word(p, "is set to indicate the error."); p->flags |= TERMP_SENTENCE; return(0); }
/* ARGSUSED */ static int termp_fn_pre(DECL_ARGS) { int pretty; pretty = MDOC_SYNPRETTY & n->flags; synopsis_pre(p, n); if (NULL == (n = n->child)) return(0); assert(MDOC_TEXT == n->type); term_fontpush(p, TERMFONT_BOLD); term_word(p, n->string); term_fontpop(p); p->flags |= TERMP_NOSPACE; term_word(p, "("); p->flags |= TERMP_NOSPACE; for (n = n->next; n; n = n->next) { assert(MDOC_TEXT == n->type); term_fontpush(p, TERMFONT_UNDER); term_word(p, n->string); term_fontpop(p); if (n->next) { p->flags |= TERMP_NOSPACE; term_word(p, ","); } } p->flags |= TERMP_NOSPACE; term_word(p, ")"); if (pretty) { p->flags |= TERMP_NOSPACE; term_word(p, ";"); } return(0); }
static int termp_nm_pre(DECL_ARGS) { const char *cp; if (n->type == ROFFT_BLOCK) { p->flags |= TERMP_PREKEEP; return 1; } if (n->type == ROFFT_BODY) { if (NULL == n->child) return 0; p->flags |= TERMP_NOSPACE; cp = NULL; if (n->prev->child != NULL) cp = n->prev->child->string; if (cp == NULL) cp = meta->name; if (cp == NULL) p->offset += term_len(p, 6); else p->offset += term_len(p, 1) + term_strlen(p, cp); return 1; } if (NULL == n->child && NULL == meta->name) return 0; if (n->type == ROFFT_HEAD) synopsis_pre(p, n->parent); if (n->type == ROFFT_HEAD && NULL != n->next && NULL != n->next->child) { p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_BRIND; p->trailspace = 1; p->rmargin = p->offset + term_len(p, 1); if (NULL == n->child) { p->rmargin += term_strlen(p, meta->name); } else if (n->child->type == ROFFT_TEXT) { p->rmargin += term_strlen(p, n->child->string); if (n->child->next) p->flags |= TERMP_HANG; } else { p->rmargin += term_len(p, 5); p->flags |= TERMP_HANG; } } term_fontpush(p, TERMFONT_BOLD); if (NULL == n->child) term_word(p, meta->name); return 1; }
static void termp_in_post(DECL_ARGS) { if (MDOC_SYNPRETTY & n->flags) term_fontpush(p, TERMFONT_BOLD); p->flags |= TERMP_NOSPACE; term_word(p, ">"); if (MDOC_SYNPRETTY & n->flags) term_fontpop(p); }
/* ARGSUSED */ static int termp_fl_pre(DECL_ARGS) { term_fontpush(p, TERMFONT_BOLD); term_word(p, "\\-"); if (n->child) p->flags |= TERMP_NOSPACE; else if (n->next && n->next->line == n->line) p->flags |= TERMP_NOSPACE; return(1); }
/* ARGSUSED */ static int termp_nm_pre(DECL_ARGS) { if (MDOC_BLOCK == n->type) { p->flags |= TERMP_PREKEEP; return(1); } if (MDOC_BODY == n->type) { if (NULL == n->child) return(0); p->flags |= TERMP_NOSPACE; p->offset += term_len(p, 1) + (NULL == n->prev->child ? term_strlen(p, meta->name) : MDOC_TEXT == n->prev->child->type ? term_strlen(p, n->prev->child->string) : term_len(p, 5)); return(1); } if (NULL == n->child && NULL == meta->name) return(0); if (MDOC_HEAD == n->type) synopsis_pre(p, n->parent); if (MDOC_HEAD == n->type && n->next->child) { p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; p->trailspace = 1; p->rmargin = p->offset + term_len(p, 1); if (NULL == n->child) { p->rmargin += term_strlen(p, meta->name); } else if (MDOC_TEXT == n->child->type) { p->rmargin += term_strlen(p, n->child->string); if (n->child->next) p->flags |= TERMP_HANG; } else { p->rmargin += term_len(p, 5); p->flags |= TERMP_HANG; } } term_fontpush(p, TERMFONT_BOLD); if (NULL == n->child) term_word(p, meta->name); return(1); }
static int termp__t_pre(DECL_ARGS) { /* * If we're in an `Rs' and there's a journal present, then quote * us instead of underlining us (for disambiguation). */ if (n->parent && MDOC_Rs == n->parent->tok && n->parent->norm->Rs.quote_T) return termp_quote_pre(p, pair, meta, n); term_fontpush(p, TERMFONT_UNDER); return 1; }
static int termp_fl_pre(DECL_ARGS) { term_fontpush(p, TERMFONT_BOLD); term_word(p, "\\-"); if ( ! (n->nchild == 0 && (n->next == NULL || n->next->type == MDOC_TEXT || n->next->flags & MDOC_LINE))) p->flags |= TERMP_NOSPACE; return(1); }