[BACK]Return to mdoc_term.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Annotation of mandoc/mdoc_term.c, Revision 1.382

1.382   ! schwarze    1: /* $Id: mdoc_term.c,v 1.381 2022/08/16 17:45:55 schwarze Exp $ */
1.1       kristaps    2: /*
1.381     schwarze    3:  * Copyright (c) 2010, 2012-2020, 2022 Ingo Schwarze <schwarze@openbsd.org>
1.217     schwarze    4:  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
1.256     schwarze    5:  * Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
1.1       kristaps    6:  *
                      7:  * Permission to use, copy, modify, and distribute this software for any
1.6       kristaps    8:  * purpose with or without fee is hereby granted, provided that the above
                      9:  * copyright notice and this permission notice appear in all copies.
1.1       kristaps   10:  *
1.314     schwarze   11:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
1.6       kristaps   12:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1.314     schwarze   13:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
1.6       kristaps   14:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     15:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     16:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     17:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.379     schwarze   18:  *
                     19:  * Plain text formatter for mdoc(7), used by mandoc(1)
                     20:  * for ASCII, UTF-8, PostScript, and PDF output.
1.1       kristaps   21:  */
1.107     kristaps   22: #include "config.h"
                     23:
1.1       kristaps   24: #include <sys/types.h>
                     25:
                     26: #include <assert.h>
                     27: #include <ctype.h>
1.302     schwarze   28: #include <limits.h>
1.118     kristaps   29: #include <stdint.h>
1.1       kristaps   30: #include <stdio.h>
                     31: #include <stdlib.h>
                     32: #include <string.h>
                     33:
1.314     schwarze   34: #include "mandoc_aux.h"
                     35: #include "roff.h"
                     36: #include "mdoc.h"
1.92      kristaps   37: #include "out.h"
1.1       kristaps   38: #include "term.h"
1.379     schwarze   39: #include "term_tag.h"
1.89      kristaps   40: #include "main.h"
1.1       kristaps   41:
                     42: struct termpair {
                     43:        struct termpair  *ppair;
1.31      kristaps   44:        int               count;
1.1       kristaps   45: };
                     46:
1.31      kristaps   47: #define        DECL_ARGS struct termp *p, \
                     48:                  struct termpair *pair, \
1.316     schwarze   49:                  const struct roff_meta *meta, \
1.315     schwarze   50:                  struct roff_node *n
1.1       kristaps   51:
1.368     schwarze   52: struct mdoc_term_act {
1.1       kristaps   53:        int     (*pre)(DECL_ARGS);
                     54:        void    (*post)(DECL_ARGS);
                     55: };
                     56:
1.302     schwarze   57: static int       a2width(const struct termp *, const char *);
1.96      kristaps   58:
                     59: static void      print_bvspace(struct termp *,
1.377     schwarze   60:                        struct roff_node *, struct roff_node *);
1.264     schwarze   61: static void      print_mdoc_node(DECL_ARGS);
1.145     kristaps   62: static void      print_mdoc_nodelist(DECL_ARGS);
1.316     schwarze   63: static void      print_mdoc_head(struct termp *, const struct roff_meta *);
                     64: static void      print_mdoc_foot(struct termp *, const struct roff_meta *);
1.377     schwarze   65: static void      synopsis_pre(struct termp *, struct roff_node *);
1.96      kristaps   66:
1.31      kristaps   67: static void      termp____post(DECL_ARGS);
1.203     kristaps   68: static void      termp__t_post(DECL_ARGS);
1.31      kristaps   69: static void      termp_bd_post(DECL_ARGS);
1.159     schwarze   70: static void      termp_bk_post(DECL_ARGS);
1.31      kristaps   71: static void      termp_bl_post(DECL_ARGS);
1.306     schwarze   72: static void      termp_eo_post(DECL_ARGS);
1.241     schwarze   73: static void      termp_fd_post(DECL_ARGS);
1.31      kristaps   74: static void      termp_fo_post(DECL_ARGS);
                     75: static void      termp_in_post(DECL_ARGS);
                     76: static void      termp_it_post(DECL_ARGS);
                     77: static void      termp_lb_post(DECL_ARGS);
1.164     schwarze   78: static void      termp_nm_post(DECL_ARGS);
1.31      kristaps   79: static void      termp_pf_post(DECL_ARGS);
1.188     kristaps   80: static void      termp_quote_post(DECL_ARGS);
1.31      kristaps   81: static void      termp_sh_post(DECL_ARGS);
                     82: static void      termp_ss_post(DECL_ARGS);
1.339     schwarze   83: static void      termp_xx_post(DECL_ARGS);
1.31      kristaps   84:
1.184     kristaps   85: static int       termp__a_pre(DECL_ARGS);
1.203     kristaps   86: static int       termp__t_pre(DECL_ARGS);
1.369     schwarze   87: static int       termp_abort_pre(DECL_ARGS);
1.61      kristaps   88: static int       termp_an_pre(DECL_ARGS);
1.31      kristaps   89: static int       termp_ap_pre(DECL_ARGS);
                     90: static int       termp_bd_pre(DECL_ARGS);
                     91: static int       termp_bf_pre(DECL_ARGS);
1.159     schwarze   92: static int       termp_bk_pre(DECL_ARGS);
1.115     kristaps   93: static int       termp_bl_pre(DECL_ARGS);
1.69      kristaps   94: static int       termp_bold_pre(DECL_ARGS);
1.31      kristaps   95: static int       termp_d1_pre(DECL_ARGS);
1.306     schwarze   96: static int       termp_eo_pre(DECL_ARGS);
1.31      kristaps   97: static int       termp_ex_pre(DECL_ARGS);
                     98: static int       termp_fa_pre(DECL_ARGS);
1.188     kristaps   99: static int       termp_fd_pre(DECL_ARGS);
1.31      kristaps  100: static int       termp_fl_pre(DECL_ARGS);
                    101: static int       termp_fn_pre(DECL_ARGS);
                    102: static int       termp_fo_pre(DECL_ARGS);
                    103: static int       termp_ft_pre(DECL_ARGS);
                    104: static int       termp_in_pre(DECL_ARGS);
                    105: static int       termp_it_pre(DECL_ARGS);
1.102     kristaps  106: static int       termp_li_pre(DECL_ARGS);
1.31      kristaps  107: static int       termp_lk_pre(DECL_ARGS);
                    108: static int       termp_nd_pre(DECL_ARGS);
                    109: static int       termp_nm_pre(DECL_ARGS);
                    110: static int       termp_ns_pre(DECL_ARGS);
1.188     kristaps  111: static int       termp_quote_pre(DECL_ARGS);
1.31      kristaps  112: static int       termp_rs_pre(DECL_ARGS);
                    113: static int       termp_sh_pre(DECL_ARGS);
1.294     schwarze  114: static int       termp_skip_pre(DECL_ARGS);
1.31      kristaps  115: static int       termp_sm_pre(DECL_ARGS);
1.355     schwarze  116: static int       termp_pp_pre(DECL_ARGS);
1.31      kristaps  117: static int       termp_ss_pre(DECL_ARGS);
1.69      kristaps  118: static int       termp_under_pre(DECL_ARGS);
1.110     kristaps  119: static int       termp_vt_pre(DECL_ARGS);
1.31      kristaps  120: static int       termp_xr_pre(DECL_ARGS);
                    121: static int       termp_xx_pre(DECL_ARGS);
                    122:
1.368     schwarze  123: static const struct mdoc_term_act mdoc_term_acts[MDOC_MAX - MDOC_Dd] = {
1.1       kristaps  124:        { NULL, NULL }, /* Dd */
                    125:        { NULL, NULL }, /* Dt */
                    126:        { NULL, NULL }, /* Os */
                    127:        { termp_sh_pre, termp_sh_post }, /* Sh */
1.264     schwarze  128:        { termp_ss_pre, termp_ss_post }, /* Ss */
1.355     schwarze  129:        { termp_pp_pre, NULL }, /* Pp */
1.241     schwarze  130:        { termp_d1_pre, termp_bl_post }, /* D1 */
                    131:        { termp_d1_pre, termp_bl_post }, /* Dl */
1.1       kristaps  132:        { termp_bd_pre, termp_bd_post }, /* Bd */
                    133:        { NULL, NULL }, /* Ed */
1.115     kristaps  134:        { termp_bl_pre, termp_bl_post }, /* Bl */
1.1       kristaps  135:        { NULL, NULL }, /* El */
                    136:        { termp_it_pre, termp_it_post }, /* It */
1.264     schwarze  137:        { termp_under_pre, NULL }, /* Ad */
1.282     schwarze  138:        { termp_an_pre, NULL }, /* An */
1.350     schwarze  139:        { termp_ap_pre, NULL }, /* Ap */
1.69      kristaps  140:        { termp_under_pre, NULL }, /* Ar */
1.379     schwarze  141:        { termp_fd_pre, NULL }, /* Cd */
1.69      kristaps  142:        { termp_bold_pre, NULL }, /* Cm */
1.325     schwarze  143:        { termp_li_pre, NULL }, /* Dv */
1.379     schwarze  144:        { NULL, NULL }, /* Er */
                    145:        { NULL, NULL }, /* Ev */
1.1       kristaps  146:        { termp_ex_pre, NULL }, /* Ex */
1.264     schwarze  147:        { termp_fa_pre, NULL }, /* Fa */
                    148:        { termp_fd_pre, termp_fd_post }, /* Fd */
1.1       kristaps  149:        { termp_fl_pre, NULL }, /* Fl */
1.264     schwarze  150:        { termp_fn_pre, NULL }, /* Fn */
                    151:        { termp_ft_pre, NULL }, /* Ft */
                    152:        { termp_bold_pre, NULL }, /* Ic */
                    153:        { termp_in_pre, termp_in_post }, /* In */
1.102     kristaps  154:        { termp_li_pre, NULL }, /* Li */
1.264     schwarze  155:        { termp_nd_pre, NULL }, /* Nd */
                    156:        { termp_nm_pre, termp_nm_post }, /* Nm */
1.188     kristaps  157:        { termp_quote_pre, termp_quote_post }, /* Op */
1.369     schwarze  158:        { termp_abort_pre, NULL }, /* Ot */
1.69      kristaps  159:        { termp_under_pre, NULL }, /* Pa */
1.341     schwarze  160:        { termp_ex_pre, NULL }, /* Rv */
1.264     schwarze  161:        { NULL, NULL }, /* St */
1.69      kristaps  162:        { termp_under_pre, NULL }, /* Va */
1.143     kristaps  163:        { termp_vt_pre, NULL }, /* Vt */
1.1       kristaps  164:        { termp_xr_pre, NULL }, /* Xr */
1.184     kristaps  165:        { termp__a_pre, termp____post }, /* %A */
1.84      kristaps  166:        { termp_under_pre, termp____post }, /* %B */
1.1       kristaps  167:        { NULL, termp____post }, /* %D */
1.84      kristaps  168:        { termp_under_pre, termp____post }, /* %I */
1.69      kristaps  169:        { termp_under_pre, termp____post }, /* %J */
1.1       kristaps  170:        { NULL, termp____post }, /* %N */
                    171:        { NULL, termp____post }, /* %O */
                    172:        { NULL, termp____post }, /* %P */
                    173:        { NULL, termp____post }, /* %R */
1.203     kristaps  174:        { termp__t_pre, termp__t_post }, /* %T */
1.1       kristaps  175:        { NULL, termp____post }, /* %V */
                    176:        { NULL, NULL }, /* Ac */
1.188     kristaps  177:        { termp_quote_pre, termp_quote_post }, /* Ao */
                    178:        { termp_quote_pre, termp_quote_post }, /* Aq */
1.35      kristaps  179:        { NULL, NULL }, /* At */
1.1       kristaps  180:        { NULL, NULL }, /* Bc */
1.264     schwarze  181:        { termp_bf_pre, NULL }, /* Bf */
1.188     kristaps  182:        { termp_quote_pre, termp_quote_post }, /* Bo */
                    183:        { termp_quote_pre, termp_quote_post }, /* Bq */
1.339     schwarze  184:        { termp_xx_pre, termp_xx_post }, /* Bsx */
1.340     schwarze  185:        { NULL, NULL }, /* Bx */
1.294     schwarze  186:        { termp_skip_pre, NULL }, /* Db */
1.1       kristaps  187:        { NULL, NULL }, /* Dc */
1.188     kristaps  188:        { termp_quote_pre, termp_quote_post }, /* Do */
                    189:        { termp_quote_pre, termp_quote_post }, /* Dq */
1.112     kristaps  190:        { NULL, NULL }, /* Ec */ /* FIXME: no space */
1.1       kristaps  191:        { NULL, NULL }, /* Ef */
1.379     schwarze  192:        { termp_under_pre, NULL }, /* Em */
1.306     schwarze  193:        { termp_eo_pre, termp_eo_post }, /* Eo */
1.339     schwarze  194:        { termp_xx_pre, termp_xx_post }, /* Fx */
1.176     kristaps  195:        { termp_bold_pre, NULL }, /* Ms */
1.290     schwarze  196:        { termp_li_pre, NULL }, /* No */
1.1       kristaps  197:        { termp_ns_pre, NULL }, /* Ns */
1.339     schwarze  198:        { termp_xx_pre, termp_xx_post }, /* Nx */
                    199:        { termp_xx_pre, termp_xx_post }, /* Ox */
1.1       kristaps  200:        { NULL, NULL }, /* Pc */
1.254     schwarze  201:        { NULL, termp_pf_post }, /* Pf */
1.188     kristaps  202:        { termp_quote_pre, termp_quote_post }, /* Po */
                    203:        { termp_quote_pre, termp_quote_post }, /* Pq */
1.1       kristaps  204:        { NULL, NULL }, /* Qc */
1.188     kristaps  205:        { termp_quote_pre, termp_quote_post }, /* Ql */
                    206:        { termp_quote_pre, termp_quote_post }, /* Qo */
                    207:        { termp_quote_pre, termp_quote_post }, /* Qq */
1.1       kristaps  208:        { NULL, NULL }, /* Re */
                    209:        { termp_rs_pre, NULL }, /* Rs */
                    210:        { NULL, NULL }, /* Sc */
1.188     kristaps  211:        { termp_quote_pre, termp_quote_post }, /* So */
                    212:        { termp_quote_pre, termp_quote_post }, /* Sq */
1.1       kristaps  213:        { termp_sm_pre, NULL }, /* Sm */
1.69      kristaps  214:        { termp_under_pre, NULL }, /* Sx */
1.379     schwarze  215:        { termp_bold_pre, NULL }, /* Sy */
1.1       kristaps  216:        { NULL, NULL }, /* Tn */
1.339     schwarze  217:        { termp_xx_pre, termp_xx_post }, /* Ux */
1.1       kristaps  218:        { NULL, NULL }, /* Xc */
                    219:        { NULL, NULL }, /* Xo */
1.264     schwarze  220:        { termp_fo_pre, termp_fo_post }, /* Fo */
                    221:        { NULL, NULL }, /* Fc */
1.188     kristaps  222:        { termp_quote_pre, termp_quote_post }, /* Oo */
1.1       kristaps  223:        { NULL, NULL }, /* Oc */
1.159     schwarze  224:        { termp_bk_pre, termp_bk_post }, /* Bk */
1.1       kristaps  225:        { NULL, NULL }, /* Ek */
1.341     schwarze  226:        { NULL, NULL }, /* Bt */
1.1       kristaps  227:        { NULL, NULL }, /* Hf */
1.268     schwarze  228:        { termp_under_pre, NULL }, /* Fr */
1.341     schwarze  229:        { NULL, NULL }, /* Ud */
1.37      kristaps  230:        { NULL, termp_lb_post }, /* Lb */
1.369     schwarze  231:        { termp_abort_pre, NULL }, /* Lp */
1.264     schwarze  232:        { termp_lk_pre, NULL }, /* Lk */
                    233:        { termp_under_pre, NULL }, /* Mt */
                    234:        { termp_quote_pre, termp_quote_post }, /* Brq */
                    235:        { termp_quote_pre, termp_quote_post }, /* Bro */
                    236:        { NULL, NULL }, /* Brc */
                    237:        { NULL, termp____post }, /* %C */
1.294     schwarze  238:        { termp_skip_pre, NULL }, /* Es */
1.268     schwarze  239:        { termp_quote_pre, termp_quote_post }, /* En */
1.339     schwarze  240:        { termp_xx_pre, termp_xx_post }, /* Dx */
1.264     schwarze  241:        { NULL, termp____post }, /* %Q */
                    242:        { NULL, termp____post }, /* %U */
                    243:        { NULL, NULL }, /* Ta */
1.378     schwarze  244:        { termp_skip_pre, NULL }, /* Tg */
1.1       kristaps  245: };
                    246:
1.350     schwarze  247:
1.70      kristaps  248: void
1.371     schwarze  249: terminal_mdoc(void *arg, const struct roff_meta *mdoc)
1.1       kristaps  250: {
1.374     schwarze  251:        struct roff_node        *n, *nn;
1.89      kristaps  252:        struct termp            *p;
1.342     schwarze  253:        size_t                   save_defindent;
1.89      kristaps  254:
                    255:        p = (struct termp *)arg;
1.362     schwarze  256:        p->tcol->rmargin = p->maxrmargin = p->defrmargin;
1.356     schwarze  257:        term_tab_set(p, NULL);
                    258:        term_tab_set(p, "T");
                    259:        term_tab_set(p, ".5i");
1.70      kristaps  260:
1.319     schwarze  261:        n = mdoc->first->child;
1.281     schwarze  262:        if (p->synopsisonly) {
1.374     schwarze  263:                for (nn = NULL; n != NULL; n = n->next) {
                    264:                        if (n->tok != MDOC_Sh)
                    265:                                continue;
                    266:                        if (n->sec == SEC_SYNOPSIS)
1.281     schwarze  267:                                break;
1.374     schwarze  268:                        if (nn == NULL && n->sec == SEC_NAME)
                    269:                                nn = n;
1.281     schwarze  270:                }
1.374     schwarze  271:                if (n == NULL)
                    272:                        n = nn;
                    273:                p->flags |= TERMP_NOSPACE;
                    274:                if (n != NULL && (n = n->child->next->child) != NULL)
                    275:                        print_mdoc_nodelist(p, NULL, mdoc, n);
                    276:                term_newln(p);
1.281     schwarze  277:        } else {
1.342     schwarze  278:                save_defindent = p->defindent;
1.281     schwarze  279:                if (p->defindent == 0)
                    280:                        p->defindent = 5;
1.371     schwarze  281:                term_begin(p, print_mdoc_head, print_mdoc_foot, mdoc);
1.367     schwarze  282:                while (n != NULL &&
                    283:                    (n->type == ROFFT_COMMENT ||
                    284:                     n->flags & NODE_NOPRT))
1.337     schwarze  285:                        n = n->next;
1.281     schwarze  286:                if (n != NULL) {
                    287:                        if (n->tok != MDOC_Sh)
                    288:                                term_vspace(p);
1.371     schwarze  289:                        print_mdoc_nodelist(p, NULL, mdoc, n);
1.281     schwarze  290:                }
                    291:                term_end(p);
1.342     schwarze  292:                p->defindent = save_defindent;
1.271     schwarze  293:        }
1.1       kristaps  294: }
                    295:
1.3       kristaps  296: static void
1.102     kristaps  297: print_mdoc_nodelist(DECL_ARGS)
1.1       kristaps  298: {
1.304     schwarze  299:        while (n != NULL) {
                    300:                print_mdoc_node(p, pair, meta, n);
                    301:                n = n->next;
                    302:        }
1.1       kristaps  303: }
                    304:
1.3       kristaps  305: static void
1.102     kristaps  306: print_mdoc_node(DECL_ARGS)
1.1       kristaps  307: {
1.368     schwarze  308:        const struct mdoc_term_act *act;
1.1       kristaps  309:        struct termpair  npair;
1.30      kristaps  310:        size_t           offset, rmargin;
1.368     schwarze  311:        int              chld;
1.1       kristaps  312:
1.372     schwarze  313:        /*
                    314:         * In no-fill mode, break the output line at the beginning
                    315:         * of new input lines except after \c, and nowhere else.
                    316:         */
                    317:
                    318:        if (n->flags & NODE_NOFILL) {
                    319:                if (n->flags & NODE_LINE &&
                    320:                    (p->flags & TERMP_NONEWLINE) == 0)
                    321:                        term_newln(p);
                    322:                p->flags |= TERMP_BRNEVER;
1.381     schwarze  323:        } else {
                    324:                if (n->flags & NODE_LINE)
                    325:                        term_tab_ref(p);
1.372     schwarze  326:                p->flags &= ~TERMP_BRNEVER;
1.381     schwarze  327:        }
1.372     schwarze  328:
1.367     schwarze  329:        if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT)
1.337     schwarze  330:                return;
                    331:
1.70      kristaps  332:        chld = 1;
1.362     schwarze  333:        offset = p->tcol->offset;
                    334:        rmargin = p->tcol->rmargin;
1.338     schwarze  335:        n->flags &= ~NODE_ENDED;
1.305     schwarze  336:        n->prev_font = p->fonti;
1.29      kristaps  337:
1.97      kristaps  338:        memset(&npair, 0, sizeof(struct termpair));
1.1       kristaps  339:        npair.ppair = pair;
1.172     kristaps  340:
1.380     schwarze  341:        if (n->flags & NODE_ID && n->tok != MDOC_Pp &&
                    342:            (n->tok != MDOC_It || n->type != ROFFT_BLOCK))
1.379     schwarze  343:                term_tag_write(n, p->line);
1.378     schwarze  344:
1.172     kristaps  345:        /*
                    346:         * Keeps only work until the end of a line.  If a keep was
                    347:         * invoked in a prior line, revert it to PREKEEP.
                    348:         */
                    349:
1.338     schwarze  350:        if (p->flags & TERMP_KEEP && n->flags & NODE_LINE) {
1.307     schwarze  351:                p->flags &= ~TERMP_KEEP;
                    352:                p->flags |= TERMP_PREKEEP;
1.172     kristaps  353:        }
1.197     schwarze  354:
                    355:        /*
1.217     schwarze  356:         * After the keep flags have been set up, we may now
                    357:         * produce output.  Note that some pre-handlers do so.
                    358:         */
                    359:
1.373     schwarze  360:        act = NULL;
1.217     schwarze  361:        switch (n->type) {
1.314     schwarze  362:        case ROFFT_TEXT:
1.372     schwarze  363:                if (n->flags & NODE_LINE) {
                    364:                        switch (*n->string) {
                    365:                        case '\0':
                    366:                                if (p->flags & TERMP_NONEWLINE)
                    367:                                        term_newln(p);
                    368:                                else
                    369:                                        term_vspace(p);
                    370:                                return;
                    371:                        case ' ':
                    372:                                if ((p->flags & TERMP_NONEWLINE) == 0)
                    373:                                        term_newln(p);
                    374:                                break;
                    375:                        default:
                    376:                                break;
                    377:                        }
                    378:                }
1.338     schwarze  379:                if (NODE_DELIMC & n->flags)
1.222     kristaps  380:                        p->flags |= TERMP_NOSPACE;
1.217     schwarze  381:                term_word(p, n->string);
1.338     schwarze  382:                if (NODE_DELIMO & n->flags)
1.222     kristaps  383:                        p->flags |= TERMP_NOSPACE;
1.217     schwarze  384:                break;
1.314     schwarze  385:        case ROFFT_EQN:
1.338     schwarze  386:                if ( ! (n->flags & NODE_LINE))
1.284     schwarze  387:                        p->flags |= TERMP_NOSPACE;
1.233     kristaps  388:                term_eqn(p, n->eqn);
1.338     schwarze  389:                if (n->next != NULL && ! (n->next->flags & NODE_LINE))
1.285     schwarze  390:                        p->flags |= TERMP_NOSPACE;
1.217     schwarze  391:                break;
1.314     schwarze  392:        case ROFFT_TBL:
1.313     schwarze  393:                if (p->tbl.cols == NULL)
                    394:                        term_newln(p);
1.217     schwarze  395:                term_tbl(p, n->span);
                    396:                break;
                    397:        default:
1.351     schwarze  398:                if (n->tok < ROFF_MAX) {
1.352     schwarze  399:                        roff_term_pre(p, n);
1.354     schwarze  400:                        return;
1.351     schwarze  401:                }
                    402:                assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX);
1.368     schwarze  403:                act = mdoc_term_acts + (n->tok - MDOC_Dd);
                    404:                if (act->pre != NULL &&
1.331     schwarze  405:                    (n->end == ENDBODY_NOT || n->child != NULL))
1.368     schwarze  406:                        chld = (*act->pre)(p, &npair, meta, n);
1.217     schwarze  407:                break;
                    408:        }
                    409:
1.86      kristaps  410:        if (chld && n->child)
1.245     schwarze  411:                print_mdoc_nodelist(p, &npair, meta, n->child);
1.1       kristaps  412:
1.244     schwarze  413:        term_fontpopq(p,
1.310     schwarze  414:            (ENDBODY_NOT == n->end ? n : n->body)->prev_font);
1.46      kristaps  415:
1.206     kristaps  416:        switch (n->type) {
1.314     schwarze  417:        case ROFFT_TEXT:
1.206     kristaps  418:                break;
1.314     schwarze  419:        case ROFFT_TBL:
1.216     kristaps  420:                break;
1.314     schwarze  421:        case ROFFT_EQN:
1.206     kristaps  422:                break;
                    423:        default:
1.368     schwarze  424:                if (act->post == NULL || n->flags & NODE_ENDED)
1.206     kristaps  425:                        break;
1.368     schwarze  426:                (void)(*act->post)(p, &npair, meta, n);
1.162     schwarze  427:
                    428:                /*
                    429:                 * Explicit end tokens not only call the post
                    430:                 * handler, but also tell the respective block
                    431:                 * that it must not call the post handler again.
                    432:                 */
1.165     kristaps  433:                if (ENDBODY_NOT != n->end)
1.338     schwarze  434:                        n->body->flags |= NODE_ENDED;
1.206     kristaps  435:                break;
1.162     schwarze  436:        }
1.121     kristaps  437:
1.338     schwarze  438:        if (NODE_EOS & n->flags)
1.121     kristaps  439:                p->flags |= TERMP_SENTENCE;
1.29      kristaps  440:
1.359     schwarze  441:        if (n->type != ROFFT_TEXT)
1.362     schwarze  442:                p->tcol->offset = offset;
                    443:        p->tcol->rmargin = rmargin;
1.1       kristaps  444: }
                    445:
1.3       kristaps  446: static void
1.316     schwarze  447: print_mdoc_foot(struct termp *p, const struct roff_meta *meta)
1.1       kristaps  448: {
1.292     schwarze  449:        size_t sz;
1.144     kristaps  450:
1.102     kristaps  451:        term_fontrepl(p, TERMFONT_NONE);
1.101     kristaps  452:
1.264     schwarze  453:        /*
1.9       kristaps  454:         * Output the footer in new-groff style, that is, three columns
                    455:         * with the middle being the manual date and flanking columns
                    456:         * being the operating system:
                    457:         *
                    458:         * SYSTEM                  DATE                    SYSTEM
                    459:         */
                    460:
1.1       kristaps  461:        term_vspace(p);
                    462:
1.362     schwarze  463:        p->tcol->offset = 0;
1.292     schwarze  464:        sz = term_strlen(p, meta->date);
1.362     schwarze  465:        p->tcol->rmargin = p->maxrmargin > sz ?
1.292     schwarze  466:            (p->maxrmargin + term_len(p, 1) - sz) / 2 : 0;
1.250     schwarze  467:        p->trailspace = 1;
1.1       kristaps  468:        p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
                    469:
1.245     schwarze  470:        term_word(p, meta->os);
1.1       kristaps  471:        term_flushln(p);
                    472:
1.362     schwarze  473:        p->tcol->offset = p->tcol->rmargin;
1.292     schwarze  474:        sz = term_strlen(p, meta->os);
1.362     schwarze  475:        p->tcol->rmargin = p->maxrmargin > sz ? p->maxrmargin - sz : 0;
1.234     schwarze  476:        p->flags |= TERMP_NOSPACE;
1.9       kristaps  477:
1.245     schwarze  478:        term_word(p, meta->date);
1.9       kristaps  479:        term_flushln(p);
                    480:
1.362     schwarze  481:        p->tcol->offset = p->tcol->rmargin;
                    482:        p->tcol->rmargin = p->maxrmargin;
1.250     schwarze  483:        p->trailspace = 0;
1.1       kristaps  484:        p->flags &= ~TERMP_NOBREAK;
1.234     schwarze  485:        p->flags |= TERMP_NOSPACE;
1.1       kristaps  486:
1.245     schwarze  487:        term_word(p, meta->os);
1.1       kristaps  488:        term_flushln(p);
                    489:
1.362     schwarze  490:        p->tcol->offset = 0;
                    491:        p->tcol->rmargin = p->maxrmargin;
1.9       kristaps  492:        p->flags = 0;
1.1       kristaps  493: }
                    494:
1.3       kristaps  495: static void
1.316     schwarze  496: print_mdoc_head(struct termp *p, const struct roff_meta *meta)
1.1       kristaps  497: {
1.267     schwarze  498:        char                    *volume, *title;
                    499:        size_t                   vollen, titlen;
1.1       kristaps  500:
                    501:        /*
                    502:         * The header is strange.  It has three components, which are
                    503:         * really two with the first duplicated.  It goes like this:
                    504:         *
                    505:         * IDENTIFIER              TITLE                   IDENTIFIER
                    506:         *
                    507:         * The IDENTIFIER is NAME(SECTION), which is the command-name
                    508:         * (if given, or "unknown" if not) followed by the manual page
                    509:         * section.  These are given in `Dt'.  The TITLE is a free-form
                    510:         * string depending on the manual volume.  If not specified, it
                    511:         * switches on the manual section.
                    512:         */
1.235     schwarze  513:
1.245     schwarze  514:        assert(meta->vol);
1.267     schwarze  515:        if (NULL == meta->arch)
                    516:                volume = mandoc_strdup(meta->vol);
                    517:        else
                    518:                mandoc_asprintf(&volume, "%s (%s)",
                    519:                    meta->vol, meta->arch);
                    520:        vollen = term_strlen(p, volume);
1.1       kristaps  521:
1.275     schwarze  522:        if (NULL == meta->msec)
                    523:                title = mandoc_strdup(meta->title);
                    524:        else
                    525:                mandoc_asprintf(&title, "%s(%s)",
                    526:                    meta->title, meta->msec);
1.235     schwarze  527:        titlen = term_strlen(p, title);
1.1       kristaps  528:
1.235     schwarze  529:        p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;
1.250     schwarze  530:        p->trailspace = 1;
1.362     schwarze  531:        p->tcol->offset = 0;
                    532:        p->tcol->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ?
1.267     schwarze  533:            (p->maxrmargin - vollen + term_len(p, 1)) / 2 :
1.292     schwarze  534:            vollen < p->maxrmargin ?  p->maxrmargin - vollen : 0;
1.1       kristaps  535:
                    536:        term_word(p, title);
                    537:        term_flushln(p);
                    538:
1.235     schwarze  539:        p->flags |= TERMP_NOSPACE;
1.362     schwarze  540:        p->tcol->offset = p->tcol->rmargin;
                    541:        p->tcol->rmargin = p->tcol->offset + vollen + titlen <
                    542:            p->maxrmargin ? p->maxrmargin - titlen : p->maxrmargin;
1.1       kristaps  543:
1.267     schwarze  544:        term_word(p, volume);
1.1       kristaps  545:        term_flushln(p);
                    546:
                    547:        p->flags &= ~TERMP_NOBREAK;
1.250     schwarze  548:        p->trailspace = 0;
1.362     schwarze  549:        if (p->tcol->rmargin + titlen <= p->maxrmargin) {
1.235     schwarze  550:                p->flags |= TERMP_NOSPACE;
1.362     schwarze  551:                p->tcol->offset = p->tcol->rmargin;
                    552:                p->tcol->rmargin = p->maxrmargin;
1.235     schwarze  553:                term_word(p, title);
                    554:                term_flushln(p);
                    555:        }
1.1       kristaps  556:
1.235     schwarze  557:        p->flags &= ~TERMP_NOSPACE;
1.362     schwarze  558:        p->tcol->offset = 0;
                    559:        p->tcol->rmargin = p->maxrmargin;
1.266     schwarze  560:        free(title);
1.267     schwarze  561:        free(volume);
1.1       kristaps  562: }
                    563:
1.302     schwarze  564: static int
1.157     kristaps  565: a2width(const struct termp *p, const char *v)
1.91      kristaps  566: {
1.92      kristaps  567:        struct roffsu    su;
1.363     schwarze  568:        const char      *end;
1.1       kristaps  569:
1.363     schwarze  570:        end = a2roffsu(v, &su, SCALE_MAX);
                    571:        if (end == NULL || *end != '\0') {
1.382   ! schwarze  572:                su.unit = SCALE_EN;
        !           573:                su.scale = term_strlen(p, v) / term_strlen(p, "0");
1.302     schwarze  574:        }
1.364     schwarze  575:        return term_hen(p, &su);
1.1       kristaps  576: }
                    577:
1.108     kristaps  578: /*
                    579:  * Determine how much space to print out before block elements of `It'
                    580:  * (and thus `Bl') and `Bd'.  And then go ahead and print that space,
                    581:  * too.
                    582:  */
1.54      kristaps  583: static void
1.377     schwarze  584: print_bvspace(struct termp *p, struct roff_node *bl, struct roff_node *n)
1.1       kristaps  585: {
1.377     schwarze  586:        struct roff_node *nn;
1.1       kristaps  587:
                    588:        term_newln(p);
1.150     kristaps  589:
1.377     schwarze  590:        if ((bl->tok == MDOC_Bd && bl->norm->Bd.comp) ||
                    591:            (bl->tok == MDOC_Bl && bl->norm->Bl.comp))
1.54      kristaps  592:                return;
                    593:
1.85      kristaps  594:        /* Do not vspace directly after Ss/Sh. */
1.1       kristaps  595:
1.289     schwarze  596:        nn = n;
1.377     schwarze  597:        while (roff_node_prev(nn) == NULL) {
1.289     schwarze  598:                do {
                    599:                        nn = nn->parent;
1.314     schwarze  600:                        if (nn->type == ROFFT_ROOT)
1.289     schwarze  601:                                return;
1.314     schwarze  602:                } while (nn->type != ROFFT_BLOCK);
1.289     schwarze  603:                if (nn->tok == MDOC_Sh || nn->tok == MDOC_Ss)
1.54      kristaps  604:                        return;
1.289     schwarze  605:                if (nn->tok == MDOC_It &&
                    606:                    nn->parent->parent->norm->Bl.type != LIST_item)
                    607:                        break;
1.1       kristaps  608:        }
                    609:
1.377     schwarze  610:        /*
                    611:         * No vertical space after:
                    612:         * items in .Bl -column
                    613:         * items without a body in .Bl -diag
                    614:         */
1.54      kristaps  615:
1.377     schwarze  616:        if (bl->tok != MDOC_Bl ||
                    617:            n->prev == NULL || n->prev->tok != MDOC_It ||
                    618:            (bl->norm->Bl.type != LIST_column &&
                    619:             (bl->norm->Bl.type != LIST_diag ||
                    620:              n->prev->body->child != NULL)))
                    621:                term_vspace(p);
1.260     schwarze  622: }
                    623:
1.1       kristaps  624:
                    625: static int
                    626: termp_it_pre(DECL_ARGS)
                    627: {
1.345     schwarze  628:        struct roffsu           su;
1.302     schwarze  629:        char                    buf[24];
1.315     schwarze  630:        const struct roff_node *bl, *nn;
1.302     schwarze  631:        size_t                  ncols, dcol;
                    632:        int                     i, offset, width;
1.126     kristaps  633:        enum mdoc_list          type;
1.1       kristaps  634:
1.314     schwarze  635:        if (n->type == ROFFT_BLOCK) {
1.151     kristaps  636:                print_bvspace(p, n->parent->parent, n);
1.380     schwarze  637:                if (n->flags & NODE_ID)
                    638:                        term_tag_write(n, p->line);
1.328     schwarze  639:                return 1;
1.54      kristaps  640:        }
1.1       kristaps  641:
1.86      kristaps  642:        bl = n->parent->parent->parent;
1.202     kristaps  643:        type = bl->norm->Bl.type;
1.1       kristaps  644:
1.264     schwarze  645:        /*
1.302     schwarze  646:         * Defaults for specific list types.
                    647:         */
                    648:
                    649:        switch (type) {
                    650:        case LIST_bullet:
                    651:        case LIST_dash:
                    652:        case LIST_hyphen:
                    653:        case LIST_enum:
                    654:                width = term_len(p, 2);
                    655:                break;
                    656:        case LIST_hang:
1.332     schwarze  657:        case LIST_tag:
1.302     schwarze  658:                width = term_len(p, 8);
                    659:                break;
                    660:        case LIST_column:
                    661:                width = term_len(p, 10);
                    662:                break;
                    663:        default:
                    664:                width = 0;
                    665:                break;
                    666:        }
                    667:        offset = 0;
                    668:
                    669:        /*
1.108     kristaps  670:         * First calculate width and offset.  This is pretty easy unless
                    671:         * we're a -column list, in which case all prior columns must
                    672:         * be accounted for.
                    673:         */
                    674:
1.302     schwarze  675:        if (bl->norm->Bl.offs != NULL) {
1.288     schwarze  676:                offset = a2width(p, bl->norm->Bl.offs);
1.362     schwarze  677:                if (offset < 0 && (size_t)(-offset) > p->tcol->offset)
                    678:                        offset = -p->tcol->offset;
1.302     schwarze  679:                else if (offset > SHRT_MAX)
                    680:                        offset = 0;
                    681:        }
1.152     kristaps  682:
1.1       kristaps  683:        switch (type) {
1.264     schwarze  684:        case LIST_column:
1.314     schwarze  685:                if (n->type == ROFFT_HEAD)
1.1       kristaps  686:                        break;
1.155     kristaps  687:
1.105     kristaps  688:                /*
1.108     kristaps  689:                 * Imitate groff's column handling:
                    690:                 * - For each earlier column, add its width.
                    691:                 * - For less than 5 columns, add four more blanks per
                    692:                 *   column.
                    693:                 * - For exactly 5 columns, add three more blank per
                    694:                 *   column.
                    695:                 * - For more than 5 columns, add only one column.
1.105     kristaps  696:                 */
1.202     kristaps  697:                ncols = bl->norm->Bl.ncols;
1.264     schwarze  698:                dcol = ncols < 5 ? term_len(p, 4) :
                    699:                    ncols == 5 ? term_len(p, 3) : term_len(p, 1);
1.108     kristaps  700:
1.134     kristaps  701:                /*
1.314     schwarze  702:                 * Calculate the offset by applying all prior ROFFT_BODY,
                    703:                 * so we stop at the ROFFT_HEAD (nn->prev == NULL).
1.134     kristaps  704:                 */
                    705:
1.264     schwarze  706:                for (i = 0, nn = n->prev;
                    707:                    nn->prev && i < (int)ncols;
1.345     schwarze  708:                    nn = nn->prev, i++) {
1.382   ! schwarze  709:                        su.unit = SCALE_EN;
        !           710:                        su.scale = term_strlen(p, bl->norm->Bl.cols[i]) /
        !           711:                            term_strlen(p, "0");
1.364     schwarze  712:                        offset += term_hen(p, &su) + dcol;
1.345     schwarze  713:                }
1.105     kristaps  714:
                    715:                /*
1.108     kristaps  716:                 * When exceeding the declared number of columns, leave
                    717:                 * the remaining widths at 0.  This will later be
                    718:                 * adjusted to the default width of 10, or, for the last
                    719:                 * column, stretched to the right margin.
1.58      kristaps  720:                 */
1.108     kristaps  721:                if (i >= (int)ncols)
                    722:                        break;
1.58      kristaps  723:
1.105     kristaps  724:                /*
1.108     kristaps  725:                 * Use the declared column widths, extended as explained
                    726:                 * in the preceding paragraph.
1.105     kristaps  727:                 */
1.382   ! schwarze  728:                su.unit = SCALE_EN;
        !           729:                su.scale = term_strlen(p, bl->norm->Bl.cols[i]) /
        !           730:                    term_strlen(p, "0");
1.364     schwarze  731:                width = term_hen(p, &su) + dcol;
1.1       kristaps  732:                break;
                    733:        default:
1.202     kristaps  734:                if (NULL == bl->norm->Bl.width)
1.108     kristaps  735:                        break;
                    736:
1.264     schwarze  737:                /*
1.108     kristaps  738:                 * Note: buffer the width by 2, which is groff's magic
                    739:                 * number for buffering single arguments.  See the above
                    740:                 * handling for column for how this changes.
                    741:                 */
1.202     kristaps  742:                width = a2width(p, bl->norm->Bl.width) + term_len(p, 2);
1.362     schwarze  743:                if (width < 0 && (size_t)(-width) > p->tcol->offset)
                    744:                        width = -p->tcol->offset;
1.302     schwarze  745:                else if (width > SHRT_MAX)
                    746:                        width = 0;
1.1       kristaps  747:                break;
                    748:        }
                    749:
1.264     schwarze  750:        /*
1.17      kristaps  751:         * Whitespace control.  Inset bodies need an initial space,
                    752:         * while diagonal bodies need two.
1.1       kristaps  753:         */
                    754:
1.51      kristaps  755:        p->flags |= TERMP_NOSPACE;
                    756:
1.1       kristaps  757:        switch (type) {
1.264     schwarze  758:        case LIST_diag:
1.314     schwarze  759:                if (n->type == ROFFT_BODY)
1.62      kristaps  760:                        term_word(p, "\\ \\ ");
1.51      kristaps  761:                break;
1.264     schwarze  762:        case LIST_inset:
1.331     schwarze  763:                if (n->type == ROFFT_BODY && n->parent->head->child != NULL)
1.51      kristaps  764:                        term_word(p, "\\ ");
1.1       kristaps  765:                break;
                    766:        default:
                    767:                break;
                    768:        }
                    769:
1.51      kristaps  770:        p->flags |= TERMP_NOSPACE;
                    771:
1.1       kristaps  772:        switch (type) {
1.264     schwarze  773:        case LIST_diag:
1.314     schwarze  774:                if (n->type == ROFFT_HEAD)
1.102     kristaps  775:                        term_fontpush(p, TERMFONT_BOLD);
1.1       kristaps  776:                break;
                    777:        default:
                    778:                break;
                    779:        }
                    780:
                    781:        /*
1.109     kristaps  782:         * Pad and break control.  This is the tricky part.  These flags
                    783:         * are documented in term_flushln() in term.c.  Note that we're
                    784:         * going to unset all of these flags in termp_it_post() when we
                    785:         * exit.
1.1       kristaps  786:         */
                    787:
                    788:        switch (type) {
1.264     schwarze  789:        case LIST_enum:
1.329     schwarze  790:        case LIST_bullet:
                    791:        case LIST_dash:
                    792:        case LIST_hyphen:
1.360     schwarze  793:                if (n->type == ROFFT_HEAD) {
                    794:                        p->flags |= TERMP_NOBREAK | TERMP_HANG;
                    795:                        p->trailspace = 1;
                    796:                } else if (width <= (int)term_len(p, 2))
                    797:                        p->flags |= TERMP_NOPAD;
1.39      kristaps  798:                break;
1.264     schwarze  799:        case LIST_hang:
1.314     schwarze  800:                if (n->type != ROFFT_HEAD)
1.59      kristaps  801:                        break;
1.263     schwarze  802:                p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;
1.250     schwarze  803:                p->trailspace = 1;
1.39      kristaps  804:                break;
1.264     schwarze  805:        case LIST_tag:
1.314     schwarze  806:                if (n->type != ROFFT_HEAD)
1.39      kristaps  807:                        break;
1.250     schwarze  808:
1.326     schwarze  809:                p->flags |= TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND;
1.250     schwarze  810:                p->trailspace = 2;
                    811:
1.86      kristaps  812:                if (NULL == n->next || NULL == n->next->child)
1.360     schwarze  813:                        p->flags |= TERMP_HANG;
1.1       kristaps  814:                break;
1.264     schwarze  815:        case LIST_column:
1.314     schwarze  816:                if (n->type == ROFFT_HEAD)
1.134     kristaps  817:                        break;
                    818:
1.250     schwarze  819:                if (NULL == n->next) {
1.134     kristaps  820:                        p->flags &= ~TERMP_NOBREAK;
1.250     schwarze  821:                        p->trailspace = 0;
                    822:                } else {
1.134     kristaps  823:                        p->flags |= TERMP_NOBREAK;
1.250     schwarze  824:                        p->trailspace = 1;
                    825:                }
1.134     kristaps  826:
1.1       kristaps  827:                break;
1.264     schwarze  828:        case LIST_diag:
1.314     schwarze  829:                if (n->type != ROFFT_HEAD)
1.250     schwarze  830:                        break;
1.263     schwarze  831:                p->flags |= TERMP_NOBREAK | TERMP_BRIND;
1.250     schwarze  832:                p->trailspace = 1;
1.1       kristaps  833:                break;
                    834:        default:
                    835:                break;
                    836:        }
                    837:
1.264     schwarze  838:        /*
1.1       kristaps  839:         * Margin control.  Set-head-width lists have their right
                    840:         * margins shortened.  The body for these lists has the offset
                    841:         * necessarily lengthened.  Everybody gets the offset.
                    842:         */
                    843:
1.362     schwarze  844:        p->tcol->offset += offset;
1.1       kristaps  845:
                    846:        switch (type) {
1.264     schwarze  847:        case LIST_bullet:
                    848:        case LIST_dash:
                    849:        case LIST_enum:
                    850:        case LIST_hyphen:
1.360     schwarze  851:        case LIST_hang:
1.264     schwarze  852:        case LIST_tag:
1.314     schwarze  853:                if (n->type == ROFFT_HEAD)
1.362     schwarze  854:                        p->tcol->rmargin = p->tcol->offset + width;
1.292     schwarze  855:                else
1.362     schwarze  856:                        p->tcol->offset += width;
1.1       kristaps  857:                break;
1.264     schwarze  858:        case LIST_column:
1.49      kristaps  859:                assert(width);
1.362     schwarze  860:                p->tcol->rmargin = p->tcol->offset + width;
1.264     schwarze  861:                /*
1.50      kristaps  862:                 * XXX - this behaviour is not documented: the
                    863:                 * right-most column is filled to the right margin.
                    864:                 */
1.314     schwarze  865:                if (n->type == ROFFT_HEAD)
1.134     kristaps  866:                        break;
1.362     schwarze  867:                if (n->next == NULL && p->tcol->rmargin < p->maxrmargin)
                    868:                        p->tcol->rmargin = p->maxrmargin;
1.1       kristaps  869:                break;
                    870:        default:
                    871:                break;
                    872:        }
                    873:
1.264     schwarze  874:        /*
1.1       kristaps  875:         * The dash, hyphen, bullet and enum lists all have a special
1.264     schwarze  876:         * HEAD character (temporarily bold, in some cases).
1.1       kristaps  877:         */
                    878:
1.314     schwarze  879:        if (n->type == ROFFT_HEAD)
1.1       kristaps  880:                switch (type) {
1.264     schwarze  881:                case LIST_bullet:
1.102     kristaps  882:                        term_fontpush(p, TERMFONT_BOLD);
1.1       kristaps  883:                        term_word(p, "\\[bu]");
1.102     kristaps  884:                        term_fontpop(p);
1.1       kristaps  885:                        break;
1.264     schwarze  886:                case LIST_dash:
                    887:                case LIST_hyphen:
1.102     kristaps  888:                        term_fontpush(p, TERMFONT_BOLD);
1.330     schwarze  889:                        term_word(p, "-");
1.102     kristaps  890:                        term_fontpop(p);
1.1       kristaps  891:                        break;
1.264     schwarze  892:                case LIST_enum:
1.1       kristaps  893:                        (pair->ppair->ppair->count)++;
1.265     schwarze  894:                        (void)snprintf(buf, sizeof(buf), "%d.",
1.264     schwarze  895:                            pair->ppair->ppair->count);
1.1       kristaps  896:                        term_word(p, buf);
                    897:                        break;
                    898:                default:
                    899:                        break;
                    900:                }
                    901:
1.264     schwarze  902:        /*
1.1       kristaps  903:         * If we're not going to process our children, indicate so here.
                    904:         */
                    905:
                    906:        switch (type) {
1.264     schwarze  907:        case LIST_bullet:
                    908:        case LIST_item:
                    909:        case LIST_dash:
                    910:        case LIST_hyphen:
                    911:        case LIST_enum:
1.314     schwarze  912:                if (n->type == ROFFT_HEAD)
1.328     schwarze  913:                        return 0;
1.1       kristaps  914:                break;
1.264     schwarze  915:        case LIST_column:
1.314     schwarze  916:                if (n->type == ROFFT_HEAD)
1.328     schwarze  917:                        return 0;
1.360     schwarze  918:                p->minbl = 0;
1.1       kristaps  919:                break;
                    920:        default:
                    921:                break;
                    922:        }
                    923:
1.328     schwarze  924:        return 1;
1.1       kristaps  925: }
                    926:
                    927: static void
                    928: termp_it_post(DECL_ARGS)
                    929: {
1.126     kristaps  930:        enum mdoc_list     type;
1.1       kristaps  931:
1.314     schwarze  932:        if (n->type == ROFFT_BLOCK)
1.1       kristaps  933:                return;
                    934:
1.202     kristaps  935:        type = n->parent->parent->parent->norm->Bl.type;
1.1       kristaps  936:
                    937:        switch (type) {
1.264     schwarze  938:        case LIST_item:
                    939:        case LIST_diag:
                    940:        case LIST_inset:
1.314     schwarze  941:                if (n->type == ROFFT_BODY)
1.130     schwarze  942:                        term_newln(p);
1.1       kristaps  943:                break;
1.264     schwarze  944:        case LIST_column:
1.314     schwarze  945:                if (n->type == ROFFT_BODY)
1.1       kristaps  946:                        term_flushln(p);
                    947:                break;
                    948:        default:
1.130     schwarze  949:                term_newln(p);
1.1       kristaps  950:                break;
                    951:        }
                    952:
1.264     schwarze  953:        /*
1.109     kristaps  954:         * Now that our output is flushed, we can reset our tags.  Since
                    955:         * only `It' sets these flags, we're free to assume that nobody
                    956:         * has munged them in the meanwhile.
                    957:         */
                    958:
1.360     schwarze  959:        p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND | TERMP_HANG);
1.250     schwarze  960:        p->trailspace = 0;
1.1       kristaps  961: }
                    962:
                    963: static int
                    964: termp_nm_pre(DECL_ARGS)
                    965: {
1.296     schwarze  966:        const char      *cp;
1.1       kristaps  967:
1.314     schwarze  968:        if (n->type == ROFFT_BLOCK) {
1.253     schwarze  969:                p->flags |= TERMP_PREKEEP;
1.328     schwarze  970:                return 1;
1.253     schwarze  971:        }
1.164     schwarze  972:
1.314     schwarze  973:        if (n->type == ROFFT_BODY) {
1.362     schwarze  974:                if (n->child == NULL)
1.328     schwarze  975:                        return 0;
1.234     schwarze  976:                p->flags |= TERMP_NOSPACE;
1.296     schwarze  977:                cp = NULL;
                    978:                if (n->prev->child != NULL)
                    979:                    cp = n->prev->child->string;
                    980:                if (cp == NULL)
                    981:                        cp = meta->name;
                    982:                if (cp == NULL)
1.362     schwarze  983:                        p->tcol->offset += term_len(p, 6);
1.296     schwarze  984:                else
1.362     schwarze  985:                        p->tcol->offset += term_len(p, 1) +
                    986:                            term_strlen(p, cp);
1.328     schwarze  987:                return 1;
1.164     schwarze  988:        }
                    989:
1.343     schwarze  990:        if (n->child == NULL)
1.328     schwarze  991:                return 0;
1.125     kristaps  992:
1.314     schwarze  993:        if (n->type == ROFFT_HEAD)
1.177     schwarze  994:                synopsis_pre(p, n->parent);
1.102     kristaps  995:
1.314     schwarze  996:        if (n->type == ROFFT_HEAD &&
1.362     schwarze  997:            n->next != NULL && n->next->child != NULL) {
1.263     schwarze  998:                p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_BRIND;
1.250     schwarze  999:                p->trailspace = 1;
1.362     schwarze 1000:                p->tcol->rmargin = p->tcol->offset + term_len(p, 1);
                   1001:                if (n->child == NULL)
                   1002:                        p->tcol->rmargin += term_strlen(p, meta->name);
                   1003:                else if (n->child->type == ROFFT_TEXT) {
                   1004:                        p->tcol->rmargin += term_strlen(p, n->child->string);
                   1005:                        if (n->child->next != NULL)
1.185     schwarze 1006:                                p->flags |= TERMP_HANG;
                   1007:                } else {
1.362     schwarze 1008:                        p->tcol->rmargin += term_len(p, 5);
1.185     schwarze 1009:                        p->flags |= TERMP_HANG;
                   1010:                }
1.164     schwarze 1011:        }
1.379     schwarze 1012:        return termp_bold_pre(p, pair, meta, n);
1.1       kristaps 1013: }
                   1014:
1.164     schwarze 1015: static void
                   1016: termp_nm_post(DECL_ARGS)
                   1017: {
1.379     schwarze 1018:        switch (n->type) {
                   1019:        case ROFFT_BLOCK:
1.253     schwarze 1020:                p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
1.379     schwarze 1021:                break;
                   1022:        case ROFFT_HEAD:
                   1023:                if (n->next == NULL || n->next->child == NULL)
                   1024:                        break;
1.164     schwarze 1025:                term_flushln(p);
1.263     schwarze 1026:                p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG);
1.250     schwarze 1027:                p->trailspace = 0;
1.379     schwarze 1028:                break;
                   1029:        case ROFFT_BODY:
                   1030:                if (n->child != NULL)
                   1031:                        term_flushln(p);
                   1032:                break;
                   1033:        default:
                   1034:                break;
                   1035:        }
1.164     schwarze 1036: }
                   1037:
1.1       kristaps 1038: static int
                   1039: termp_fl_pre(DECL_ARGS)
                   1040: {
1.377     schwarze 1041:        struct roff_node *nn;
1.1       kristaps 1042:
1.102     kristaps 1043:        term_fontpush(p, TERMFONT_BOLD);
1.1       kristaps 1044:        term_word(p, "\\-");
1.103     kristaps 1045:
1.377     schwarze 1046:        if (n->child != NULL ||
                   1047:            ((nn = roff_node_next(n)) != NULL &&
                   1048:             nn->type != ROFFT_TEXT &&
                   1049:             (nn->flags & NODE_LINE) == 0))
1.103     kristaps 1050:                p->flags |= TERMP_NOSPACE;
                   1051:
1.328     schwarze 1052:        return 1;
1.1       kristaps 1053: }
                   1054:
                   1055: static int
1.184     kristaps 1056: termp__a_pre(DECL_ARGS)
                   1057: {
1.377     schwarze 1058:        struct roff_node *nn;
1.184     kristaps 1059:
1.377     schwarze 1060:        if ((nn = roff_node_prev(n)) != NULL && nn->tok == MDOC__A &&
                   1061:            ((nn = roff_node_next(n)) == NULL || nn->tok != MDOC__A))
                   1062:                term_word(p, "and");
1.184     kristaps 1063:
1.328     schwarze 1064:        return 1;
1.184     kristaps 1065: }
                   1066:
                   1067: static int
1.61      kristaps 1068: termp_an_pre(DECL_ARGS)
                   1069: {
                   1070:
1.282     schwarze 1071:        if (n->norm->An.auth == AUTH_split) {
                   1072:                p->flags &= ~TERMP_NOSPLIT;
                   1073:                p->flags |= TERMP_SPLIT;
1.328     schwarze 1074:                return 0;
1.282     schwarze 1075:        }
                   1076:        if (n->norm->An.auth == AUTH_nosplit) {
                   1077:                p->flags &= ~TERMP_SPLIT;
                   1078:                p->flags |= TERMP_NOSPLIT;
1.328     schwarze 1079:                return 0;
1.282     schwarze 1080:        }
1.264     schwarze 1081:
1.282     schwarze 1082:        if (p->flags & TERMP_SPLIT)
1.61      kristaps 1083:                term_newln(p);
                   1084:
1.282     schwarze 1085:        if (n->sec == SEC_AUTHORS && ! (p->flags & TERMP_NOSPLIT))
                   1086:                p->flags |= TERMP_SPLIT;
1.61      kristaps 1087:
1.328     schwarze 1088:        return 1;
1.61      kristaps 1089: }
                   1090:
                   1091: static int
1.1       kristaps 1092: termp_ns_pre(DECL_ARGS)
                   1093: {
                   1094:
1.338     schwarze 1095:        if ( ! (NODE_LINE & n->flags))
1.215     kristaps 1096:                p->flags |= TERMP_NOSPACE;
1.328     schwarze 1097:        return 1;
1.1       kristaps 1098: }
                   1099:
                   1100: static int
                   1101: termp_rs_pre(DECL_ARGS)
                   1102: {
1.86      kristaps 1103:        if (SEC_SEE_ALSO != n->sec)
1.328     schwarze 1104:                return 1;
1.377     schwarze 1105:        if (n->type == ROFFT_BLOCK && roff_node_prev(n) != NULL)
1.1       kristaps 1106:                term_vspace(p);
1.328     schwarze 1107:        return 1;
1.1       kristaps 1108: }
                   1109:
                   1110: static int
                   1111: termp_ex_pre(DECL_ARGS)
                   1112: {
1.224     kristaps 1113:        term_newln(p);
1.341     schwarze 1114:        return 1;
1.1       kristaps 1115: }
                   1116:
                   1117: static int
                   1118: termp_nd_pre(DECL_ARGS)
                   1119: {
1.314     schwarze 1120:        if (n->type == ROFFT_BODY)
1.297     schwarze 1121:                term_word(p, "\\(en");
1.328     schwarze 1122:        return 1;
1.115     kristaps 1123: }
                   1124:
                   1125: static int
                   1126: termp_bl_pre(DECL_ARGS)
                   1127: {
1.380     schwarze 1128:        switch (n->type) {
                   1129:        case ROFFT_BLOCK:
                   1130:                term_newln(p);
                   1131:                return 1;
                   1132:        case ROFFT_HEAD:
                   1133:                return 0;
                   1134:        default:
                   1135:                return 1;
                   1136:        }
1.1       kristaps 1137: }
                   1138:
                   1139: static void
                   1140: termp_bl_post(DECL_ARGS)
                   1141: {
1.356     schwarze 1142:        if (n->type != ROFFT_BLOCK)
                   1143:                return;
                   1144:        term_newln(p);
                   1145:        if (n->tok != MDOC_Bl || n->norm->Bl.type != LIST_column)
                   1146:                return;
                   1147:        term_tab_set(p, NULL);
                   1148:        term_tab_set(p, "T");
                   1149:        term_tab_set(p, ".5i");
1.1       kristaps 1150: }
                   1151:
                   1152: static int
                   1153: termp_xr_pre(DECL_ARGS)
                   1154: {
1.225     kristaps 1155:        if (NULL == (n = n->child))
1.328     schwarze 1156:                return 0;
1.113     kristaps 1157:
1.314     schwarze 1158:        assert(n->type == ROFFT_TEXT);
1.225     kristaps 1159:        term_word(p, n->string);
1.11      kristaps 1160:
1.264     schwarze 1161:        if (NULL == (n = n->next))
1.328     schwarze 1162:                return 0;
1.225     kristaps 1163:
1.1       kristaps 1164:        p->flags |= TERMP_NOSPACE;
                   1165:        term_word(p, "(");
1.222     kristaps 1166:        p->flags |= TERMP_NOSPACE;
1.225     kristaps 1167:
1.314     schwarze 1168:        assert(n->type == ROFFT_TEXT);
1.225     kristaps 1169:        term_word(p, n->string);
                   1170:
1.222     kristaps 1171:        p->flags |= TERMP_NOSPACE;
1.1       kristaps 1172:        term_word(p, ")");
1.86      kristaps 1173:
1.328     schwarze 1174:        return 0;
1.1       kristaps 1175: }
                   1176:
1.143     kristaps 1177: /*
                   1178:  * This decides how to assert whitespace before any of the SYNOPSIS set
                   1179:  * of macros (which, as in the case of Ft/Fo and Ft/Fn, may contain
                   1180:  * macro combos).
                   1181:  */
                   1182: static void
1.377     schwarze 1183: synopsis_pre(struct termp *p, struct roff_node *n)
1.143     kristaps 1184: {
1.377     schwarze 1185:        struct roff_node        *np;
                   1186:
                   1187:        if ((n->flags & NODE_SYNPRETTY) == 0 ||
                   1188:            (np = roff_node_prev(n)) == NULL)
1.143     kristaps 1189:                return;
                   1190:
                   1191:        /*
                   1192:         * If we're the second in a pair of like elements, emit our
                   1193:         * newline and return.  UNLESS we're `Fo', `Fn', `Fn', in which
                   1194:         * case we soldier on.
                   1195:         */
1.377     schwarze 1196:        if (np->tok == n->tok &&
1.264     schwarze 1197:            MDOC_Ft != n->tok &&
                   1198:            MDOC_Fo != n->tok &&
                   1199:            MDOC_Fn != n->tok) {
1.143     kristaps 1200:                term_newln(p);
                   1201:                return;
                   1202:        }
                   1203:
                   1204:        /*
                   1205:         * If we're one of the SYNOPSIS set and non-like pair-wise after
                   1206:         * another (or Fn/Fo, which we've let slip through) then assert
                   1207:         * vertical space, else only newline and move on.
                   1208:         */
1.377     schwarze 1209:        switch (np->tok) {
1.264     schwarze 1210:        case MDOC_Fd:
                   1211:        case MDOC_Fn:
                   1212:        case MDOC_Fo:
                   1213:        case MDOC_In:
                   1214:        case MDOC_Vt:
1.143     kristaps 1215:                term_vspace(p);
                   1216:                break;
1.264     schwarze 1217:        case MDOC_Ft:
1.377     schwarze 1218:                if (n->tok != MDOC_Fn && n->tok != MDOC_Fo) {
1.143     kristaps 1219:                        term_vspace(p);
                   1220:                        break;
                   1221:                }
                   1222:                /* FALLTHROUGH */
                   1223:        default:
                   1224:                term_newln(p);
                   1225:                break;
                   1226:        }
                   1227: }
                   1228:
1.110     kristaps 1229: static int
                   1230: termp_vt_pre(DECL_ARGS)
                   1231: {
1.379     schwarze 1232:        switch (n->type) {
                   1233:        case ROFFT_ELEM:
                   1234:                return termp_ft_pre(p, pair, meta, n);
                   1235:        case ROFFT_BLOCK:
1.143     kristaps 1236:                synopsis_pre(p, n);
1.328     schwarze 1237:                return 1;
1.379     schwarze 1238:        case ROFFT_HEAD:
1.328     schwarze 1239:                return 0;
1.379     schwarze 1240:        default:
                   1241:                return termp_under_pre(p, pair, meta, n);
                   1242:        }
1.110     kristaps 1243: }
                   1244:
1.1       kristaps 1245: static int
1.69      kristaps 1246: termp_bold_pre(DECL_ARGS)
1.1       kristaps 1247: {
1.102     kristaps 1248:        term_fontpush(p, TERMFONT_BOLD);
1.328     schwarze 1249:        return 1;
1.1       kristaps 1250: }
                   1251:
1.143     kristaps 1252: static int
                   1253: termp_fd_pre(DECL_ARGS)
1.1       kristaps 1254: {
1.143     kristaps 1255:        synopsis_pre(p, n);
1.328     schwarze 1256:        return termp_bold_pre(p, pair, meta, n);
1.1       kristaps 1257: }
                   1258:
1.241     schwarze 1259: static void
                   1260: termp_fd_post(DECL_ARGS)
                   1261: {
                   1262:        term_newln(p);
                   1263: }
                   1264:
1.1       kristaps 1265: static int
                   1266: termp_sh_pre(DECL_ARGS)
                   1267: {
1.377     schwarze 1268:        struct roff_node        *np;
1.85      kristaps 1269:
1.86      kristaps 1270:        switch (n->type) {
1.314     schwarze 1271:        case ROFFT_BLOCK:
1.293     schwarze 1272:                /*
                   1273:                 * Vertical space before sections, except
                   1274:                 * when the previous section was empty.
                   1275:                 */
1.377     schwarze 1276:                if ((np = roff_node_prev(n)) == NULL ||
                   1277:                    np->tok != MDOC_Sh ||
                   1278:                    (np->body != NULL && np->body->child != NULL))
1.293     schwarze 1279:                        term_vspace(p);
1.65      kristaps 1280:                break;
1.314     schwarze 1281:        case ROFFT_HEAD:
1.379     schwarze 1282:                return termp_bold_pre(p, pair, meta, n);
1.314     schwarze 1283:        case ROFFT_BODY:
1.362     schwarze 1284:                p->tcol->offset = term_len(p, p->defindent);
1.356     schwarze 1285:                term_tab_set(p, NULL);
                   1286:                term_tab_set(p, "T");
                   1287:                term_tab_set(p, ".5i");
1.379     schwarze 1288:                if (n->sec == SEC_AUTHORS)
1.239     schwarze 1289:                        p->flags &= ~(TERMP_SPLIT|TERMP_NOSPLIT);
1.1       kristaps 1290:                break;
                   1291:        default:
                   1292:                break;
                   1293:        }
1.328     schwarze 1294:        return 1;
1.1       kristaps 1295: }
                   1296:
                   1297: static void
                   1298: termp_sh_post(DECL_ARGS)
                   1299: {
1.86      kristaps 1300:        switch (n->type) {
1.314     schwarze 1301:        case ROFFT_HEAD:
1.1       kristaps 1302:                term_newln(p);
                   1303:                break;
1.314     schwarze 1304:        case ROFFT_BODY:
1.1       kristaps 1305:                term_newln(p);
1.362     schwarze 1306:                p->tcol->offset = 0;
1.1       kristaps 1307:                break;
                   1308:        default:
                   1309:                break;
                   1310:        }
                   1311: }
                   1312:
                   1313: static void
                   1314: termp_lb_post(DECL_ARGS)
                   1315: {
1.379     schwarze 1316:        if (n->sec == SEC_LIBRARY && n->flags & NODE_LINE)
1.81      kristaps 1317:                term_newln(p);
1.1       kristaps 1318: }
                   1319:
                   1320: static int
                   1321: termp_d1_pre(DECL_ARGS)
                   1322: {
1.314     schwarze 1323:        if (n->type != ROFFT_BLOCK)
1.328     schwarze 1324:                return 1;
1.1       kristaps 1325:        term_newln(p);
1.362     schwarze 1326:        p->tcol->offset += term_len(p, p->defindent + 1);
1.356     schwarze 1327:        term_tab_set(p, NULL);
                   1328:        term_tab_set(p, "T");
                   1329:        term_tab_set(p, ".5i");
1.328     schwarze 1330:        return 1;
1.1       kristaps 1331: }
                   1332:
                   1333: static int
                   1334: termp_ft_pre(DECL_ARGS)
                   1335: {
1.143     kristaps 1336:        synopsis_pre(p, n);
1.379     schwarze 1337:        return termp_under_pre(p, pair, meta, n);
1.1       kristaps 1338: }
                   1339:
                   1340: static int
                   1341: termp_fn_pre(DECL_ARGS)
                   1342: {
1.257     schwarze 1343:        size_t           rmargin = 0;
1.226     kristaps 1344:        int              pretty;
                   1345:
1.143     kristaps 1346:        synopsis_pre(p, n);
1.379     schwarze 1347:        pretty = n->flags & NODE_SYNPRETTY;
                   1348:        if ((n = n->child) == NULL)
1.328     schwarze 1349:                return 0;
1.226     kristaps 1350:
1.251     schwarze 1351:        if (pretty) {
1.362     schwarze 1352:                rmargin = p->tcol->rmargin;
                   1353:                p->tcol->rmargin = p->tcol->offset + term_len(p, 4);
1.263     schwarze 1354:                p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;
1.251     schwarze 1355:        }
                   1356:
1.314     schwarze 1357:        assert(n->type == ROFFT_TEXT);
1.102     kristaps 1358:        term_fontpush(p, TERMFONT_BOLD);
1.226     kristaps 1359:        term_word(p, n->string);
1.102     kristaps 1360:        term_fontpop(p);
1.1       kristaps 1361:
1.251     schwarze 1362:        if (pretty) {
                   1363:                term_flushln(p);
1.263     schwarze 1364:                p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG);
1.360     schwarze 1365:                p->flags |= TERMP_NOPAD;
1.362     schwarze 1366:                p->tcol->offset = p->tcol->rmargin;
                   1367:                p->tcol->rmargin = rmargin;
1.251     schwarze 1368:        }
                   1369:
1.1       kristaps 1370:        p->flags |= TERMP_NOSPACE;
                   1371:        term_word(p, "(");
1.222     kristaps 1372:        p->flags |= TERMP_NOSPACE;
1.1       kristaps 1373:
1.226     kristaps 1374:        for (n = n->next; n; n = n->next) {
1.314     schwarze 1375:                assert(n->type == ROFFT_TEXT);
1.102     kristaps 1376:                term_fontpush(p, TERMFONT_UNDER);
1.255     schwarze 1377:                if (pretty)
                   1378:                        p->flags |= TERMP_NBRWORD;
1.226     kristaps 1379:                term_word(p, n->string);
1.102     kristaps 1380:                term_fontpop(p);
                   1381:
1.226     kristaps 1382:                if (n->next) {
1.222     kristaps 1383:                        p->flags |= TERMP_NOSPACE;
1.1       kristaps 1384:                        term_word(p, ",");
1.222     kristaps 1385:                }
1.1       kristaps 1386:        }
                   1387:
1.222     kristaps 1388:        p->flags |= TERMP_NOSPACE;
1.1       kristaps 1389:        term_word(p, ")");
                   1390:
1.226     kristaps 1391:        if (pretty) {
1.222     kristaps 1392:                p->flags |= TERMP_NOSPACE;
1.1       kristaps 1393:                term_word(p, ";");
1.251     schwarze 1394:                term_flushln(p);
1.222     kristaps 1395:        }
1.328     schwarze 1396:        return 0;
1.1       kristaps 1397: }
                   1398:
                   1399: static int
                   1400: termp_fa_pre(DECL_ARGS)
                   1401: {
1.315     schwarze 1402:        const struct roff_node  *nn;
1.1       kristaps 1403:
1.379     schwarze 1404:        if (n->parent->tok != MDOC_Fo)
                   1405:                return termp_under_pre(p, pair, meta, n);
                   1406:
1.377     schwarze 1407:        for (nn = n->child; nn != NULL; nn = nn->next) {
1.102     kristaps 1408:                term_fontpush(p, TERMFONT_UNDER);
1.258     schwarze 1409:                p->flags |= TERMP_NBRWORD;
1.86      kristaps 1410:                term_word(p, nn->string);
1.102     kristaps 1411:                term_fontpop(p);
1.377     schwarze 1412:                if (nn->next != NULL) {
1.222     kristaps 1413:                        p->flags |= TERMP_NOSPACE;
1.1       kristaps 1414:                        term_word(p, ",");
1.222     kristaps 1415:                }
1.1       kristaps 1416:        }
1.377     schwarze 1417:        if (n->child != NULL &&
                   1418:            (nn = roff_node_next(n)) != NULL &&
                   1419:            nn->tok == MDOC_Fa) {
                   1420:                p->flags |= TERMP_NOSPACE;
                   1421:                term_word(p, ",");
                   1422:        }
1.328     schwarze 1423:        return 0;
1.1       kristaps 1424: }
                   1425:
                   1426: static int
                   1427: termp_bd_pre(DECL_ARGS)
                   1428: {
1.302     schwarze 1429:        int                      offset;
1.1       kristaps 1430:
1.314     schwarze 1431:        if (n->type == ROFFT_BLOCK) {
1.151     kristaps 1432:                print_bvspace(p, n, n);
1.328     schwarze 1433:                return 1;
1.314     schwarze 1434:        } else if (n->type == ROFFT_HEAD)
1.328     schwarze 1435:                return 0;
1.1       kristaps 1436:
1.288     schwarze 1437:        /* Handle the -offset argument. */
                   1438:
                   1439:        if (n->norm->Bd.offs == NULL ||
                   1440:            ! strcmp(n->norm->Bd.offs, "left"))
                   1441:                /* nothing */;
                   1442:        else if ( ! strcmp(n->norm->Bd.offs, "indent"))
1.362     schwarze 1443:                p->tcol->offset += term_len(p, p->defindent + 1);
1.288     schwarze 1444:        else if ( ! strcmp(n->norm->Bd.offs, "indent-two"))
1.362     schwarze 1445:                p->tcol->offset += term_len(p, (p->defindent + 1) * 2);
1.302     schwarze 1446:        else {
                   1447:                offset = a2width(p, n->norm->Bd.offs);
1.362     schwarze 1448:                if (offset < 0 && (size_t)(-offset) > p->tcol->offset)
                   1449:                        p->tcol->offset = 0;
1.302     schwarze 1450:                else if (offset < SHRT_MAX)
1.362     schwarze 1451:                        p->tcol->offset += offset;
1.302     schwarze 1452:        }
1.85      kristaps 1453:
1.372     schwarze 1454:        switch (n->norm->Bd.type) {
                   1455:        case DISP_literal:
1.356     schwarze 1456:                term_tab_set(p, NULL);
                   1457:                term_tab_set(p, "T");
                   1458:                term_tab_set(p, "8n");
1.372     schwarze 1459:                break;
                   1460:        case DISP_centered:
                   1461:                p->flags |= TERMP_CENTER;
                   1462:                break;
                   1463:        default:
                   1464:                break;
1.356     schwarze 1465:        }
1.372     schwarze 1466:        return 1;
1.1       kristaps 1467: }
                   1468:
                   1469: static void
                   1470: termp_bd_post(DECL_ARGS)
                   1471: {
1.314     schwarze 1472:        if (n->type != ROFFT_BODY)
1.1       kristaps 1473:                return;
1.372     schwarze 1474:        if (n->norm->Bd.type == DISP_unfilled ||
                   1475:            n->norm->Bd.type == DISP_literal)
1.361     schwarze 1476:                p->flags |= TERMP_BRNEVER;
1.60      kristaps 1477:        p->flags |= TERMP_NOSPACE;
1.130     schwarze 1478:        term_newln(p);
1.361     schwarze 1479:        p->flags &= ~TERMP_BRNEVER;
1.372     schwarze 1480:        if (n->norm->Bd.type == DISP_centered)
                   1481:                p->flags &= ~TERMP_CENTER;
1.1       kristaps 1482: }
                   1483:
                   1484: static int
1.26      kristaps 1485: termp_xx_pre(DECL_ARGS)
1.1       kristaps 1486: {
1.339     schwarze 1487:        if ((n->aux = p->flags & TERMP_PREKEEP) == 0)
                   1488:                p->flags |= TERMP_PREKEEP;
                   1489:        return 1;
                   1490: }
1.1       kristaps 1491:
1.339     schwarze 1492: static void
                   1493: termp_xx_post(DECL_ARGS)
                   1494: {
                   1495:        if (n->aux == 0)
                   1496:                p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
1.1       kristaps 1497: }
                   1498:
                   1499: static void
                   1500: termp_pf_post(DECL_ARGS)
                   1501: {
1.377     schwarze 1502:        if (n->next != NULL && (n->next->flags & NODE_LINE) == 0)
1.298     schwarze 1503:                p->flags |= TERMP_NOSPACE;
1.1       kristaps 1504: }
                   1505:
                   1506: static int
                   1507: termp_ss_pre(DECL_ARGS)
                   1508: {
1.86      kristaps 1509:        switch (n->type) {
1.314     schwarze 1510:        case ROFFT_BLOCK:
1.377     schwarze 1511:                if (roff_node_prev(n) == NULL)
                   1512:                        term_newln(p);
                   1513:                else
1.1       kristaps 1514:                        term_vspace(p);
                   1515:                break;
1.314     schwarze 1516:        case ROFFT_HEAD:
1.362     schwarze 1517:                p->tcol->offset = term_len(p, (p->defindent+1)/2);
1.379     schwarze 1518:                return termp_bold_pre(p, pair, meta, n);
1.314     schwarze 1519:        case ROFFT_BODY:
1.362     schwarze 1520:                p->tcol->offset = term_len(p, p->defindent);
1.356     schwarze 1521:                term_tab_set(p, NULL);
                   1522:                term_tab_set(p, "T");
                   1523:                term_tab_set(p, ".5i");
1.274     schwarze 1524:                break;
1.1       kristaps 1525:        default:
                   1526:                break;
                   1527:        }
1.328     schwarze 1528:        return 1;
1.1       kristaps 1529: }
                   1530:
                   1531: static void
                   1532: termp_ss_post(DECL_ARGS)
                   1533: {
1.314     schwarze 1534:        if (n->type == ROFFT_HEAD || n->type == ROFFT_BODY)
1.1       kristaps 1535:                term_newln(p);
                   1536: }
                   1537:
                   1538: static int
                   1539: termp_in_pre(DECL_ARGS)
                   1540: {
1.143     kristaps 1541:        synopsis_pre(p, n);
1.379     schwarze 1542:        if (n->flags & NODE_SYNPRETTY && n->flags & NODE_LINE) {
1.138     kristaps 1543:                term_fontpush(p, TERMFONT_BOLD);
1.22      kristaps 1544:                term_word(p, "#include");
1.138     kristaps 1545:                term_word(p, "<");
                   1546:        } else {
                   1547:                term_word(p, "<");
                   1548:                term_fontpush(p, TERMFONT_UNDER);
                   1549:        }
1.1       kristaps 1550:        p->flags |= TERMP_NOSPACE;
1.328     schwarze 1551:        return 1;
1.1       kristaps 1552: }
                   1553:
                   1554: static void
                   1555: termp_in_post(DECL_ARGS)
                   1556: {
1.379     schwarze 1557:        if (n->flags & NODE_SYNPRETTY)
1.138     kristaps 1558:                term_fontpush(p, TERMFONT_BOLD);
1.79      kristaps 1559:        p->flags |= TERMP_NOSPACE;
1.1       kristaps 1560:        term_word(p, ">");
1.379     schwarze 1561:        if (n->flags & NODE_SYNPRETTY)
1.138     kristaps 1562:                term_fontpop(p);
1.1       kristaps 1563: }
                   1564:
                   1565: static int
1.355     schwarze 1566: termp_pp_pre(DECL_ARGS)
1.45      kristaps 1567: {
1.355     schwarze 1568:        term_vspace(p);
1.380     schwarze 1569:        if (n->flags & NODE_ID)
                   1570:                term_tag_write(n, p->line);
1.328     schwarze 1571:        return 0;
1.45      kristaps 1572: }
                   1573:
                   1574: static int
1.294     schwarze 1575: termp_skip_pre(DECL_ARGS)
1.268     schwarze 1576: {
1.328     schwarze 1577:        return 0;
1.268     schwarze 1578: }
                   1579:
                   1580: static int
1.188     kristaps 1581: termp_quote_pre(DECL_ARGS)
1.1       kristaps 1582: {
1.314     schwarze 1583:        if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM)
1.328     schwarze 1584:                return 1;
1.1       kristaps 1585:
1.188     kristaps 1586:        switch (n->tok) {
1.264     schwarze 1587:        case MDOC_Ao:
                   1588:        case MDOC_Aq:
1.331     schwarze 1589:                term_word(p, n->child != NULL && n->child->next == NULL &&
1.303     schwarze 1590:                    n->child->tok == MDOC_Mt ? "<" : "\\(la");
1.188     kristaps 1591:                break;
1.264     schwarze 1592:        case MDOC_Bro:
                   1593:        case MDOC_Brq:
1.188     kristaps 1594:                term_word(p, "{");
                   1595:                break;
1.264     schwarze 1596:        case MDOC_Oo:
                   1597:        case MDOC_Op:
                   1598:        case MDOC_Bo:
                   1599:        case MDOC_Bq:
1.188     kristaps 1600:                term_word(p, "[");
                   1601:                break;
1.346     schwarze 1602:        case MDOC__T:
                   1603:                /* FALLTHROUGH */
1.264     schwarze 1604:        case MDOC_Do:
                   1605:        case MDOC_Dq:
1.366     schwarze 1606:                term_word(p, "\\(lq");
1.188     kristaps 1607:                break;
1.268     schwarze 1608:        case MDOC_En:
                   1609:                if (NULL == n->norm->Es ||
                   1610:                    NULL == n->norm->Es->child)
1.328     schwarze 1611:                        return 1;
1.268     schwarze 1612:                term_word(p, n->norm->Es->child->string);
                   1613:                break;
1.264     schwarze 1614:        case MDOC_Po:
                   1615:        case MDOC_Pq:
1.188     kristaps 1616:                term_word(p, "(");
                   1617:                break;
1.264     schwarze 1618:        case MDOC_Qo:
                   1619:        case MDOC_Qq:
1.188     kristaps 1620:                term_word(p, "\"");
                   1621:                break;
1.264     schwarze 1622:        case MDOC_Ql:
                   1623:        case MDOC_So:
                   1624:        case MDOC_Sq:
1.249     schwarze 1625:                term_word(p, "\\(oq");
1.188     kristaps 1626:                break;
                   1627:        default:
                   1628:                abort();
                   1629:        }
1.1       kristaps 1630:
                   1631:        p->flags |= TERMP_NOSPACE;
1.328     schwarze 1632:        return 1;
1.1       kristaps 1633: }
                   1634:
                   1635: static void
1.188     kristaps 1636: termp_quote_post(DECL_ARGS)
1.1       kristaps 1637: {
                   1638:
1.314     schwarze 1639:        if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM)
1.1       kristaps 1640:                return;
                   1641:
1.306     schwarze 1642:        p->flags |= TERMP_NOSPACE;
1.1       kristaps 1643:
1.188     kristaps 1644:        switch (n->tok) {
1.264     schwarze 1645:        case MDOC_Ao:
                   1646:        case MDOC_Aq:
1.331     schwarze 1647:                term_word(p, n->child != NULL && n->child->next == NULL &&
1.303     schwarze 1648:                    n->child->tok == MDOC_Mt ? ">" : "\\(ra");
1.188     kristaps 1649:                break;
1.264     schwarze 1650:        case MDOC_Bro:
                   1651:        case MDOC_Brq:
1.188     kristaps 1652:                term_word(p, "}");
                   1653:                break;
1.264     schwarze 1654:        case MDOC_Oo:
                   1655:        case MDOC_Op:
                   1656:        case MDOC_Bo:
                   1657:        case MDOC_Bq:
1.188     kristaps 1658:                term_word(p, "]");
                   1659:                break;
1.346     schwarze 1660:        case MDOC__T:
                   1661:                /* FALLTHROUGH */
1.264     schwarze 1662:        case MDOC_Do:
                   1663:        case MDOC_Dq:
1.366     schwarze 1664:                term_word(p, "\\(rq");
1.268     schwarze 1665:                break;
                   1666:        case MDOC_En:
1.306     schwarze 1667:                if (n->norm->Es == NULL ||
                   1668:                    n->norm->Es->child == NULL ||
                   1669:                    n->norm->Es->child->next == NULL)
                   1670:                        p->flags &= ~TERMP_NOSPACE;
                   1671:                else
1.268     schwarze 1672:                        term_word(p, n->norm->Es->child->next->string);
1.188     kristaps 1673:                break;
1.264     schwarze 1674:        case MDOC_Po:
                   1675:        case MDOC_Pq:
1.188     kristaps 1676:                term_word(p, ")");
                   1677:                break;
1.264     schwarze 1678:        case MDOC_Qo:
                   1679:        case MDOC_Qq:
1.188     kristaps 1680:                term_word(p, "\"");
                   1681:                break;
1.264     schwarze 1682:        case MDOC_Ql:
                   1683:        case MDOC_So:
                   1684:        case MDOC_Sq:
1.249     schwarze 1685:                term_word(p, "\\(cq");
1.188     kristaps 1686:                break;
                   1687:        default:
                   1688:                abort();
                   1689:        }
1.306     schwarze 1690: }
                   1691:
                   1692: static int
                   1693: termp_eo_pre(DECL_ARGS)
                   1694: {
                   1695:
1.314     schwarze 1696:        if (n->type != ROFFT_BODY)
1.328     schwarze 1697:                return 1;
1.306     schwarze 1698:
                   1699:        if (n->end == ENDBODY_NOT &&
                   1700:            n->parent->head->child == NULL &&
                   1701:            n->child != NULL &&
                   1702:            n->child->end != ENDBODY_NOT)
                   1703:                term_word(p, "\\&");
                   1704:        else if (n->end != ENDBODY_NOT ? n->child != NULL :
1.309     schwarze 1705:             n->parent->head->child != NULL && (n->child != NULL ||
                   1706:             (n->parent->tail != NULL && n->parent->tail->child != NULL)))
1.306     schwarze 1707:                p->flags |= TERMP_NOSPACE;
                   1708:
1.328     schwarze 1709:        return 1;
1.306     schwarze 1710: }
                   1711:
                   1712: static void
                   1713: termp_eo_post(DECL_ARGS)
                   1714: {
                   1715:        int      body, tail;
                   1716:
1.314     schwarze 1717:        if (n->type != ROFFT_BODY)
1.306     schwarze 1718:                return;
                   1719:
                   1720:        if (n->end != ENDBODY_NOT) {
                   1721:                p->flags &= ~TERMP_NOSPACE;
                   1722:                return;
                   1723:        }
                   1724:
                   1725:        body = n->child != NULL || n->parent->head->child != NULL;
                   1726:        tail = n->parent->tail != NULL && n->parent->tail->child != NULL;
                   1727:
                   1728:        if (body && tail)
                   1729:                p->flags |= TERMP_NOSPACE;
                   1730:        else if ( ! (body || tail))
                   1731:                term_word(p, "\\&");
                   1732:        else if ( ! tail)
                   1733:                p->flags &= ~TERMP_NOSPACE;
1.1       kristaps 1734: }
                   1735:
                   1736: static int
                   1737: termp_fo_pre(DECL_ARGS)
                   1738: {
1.379     schwarze 1739:        size_t rmargin;
1.256     schwarze 1740:
1.379     schwarze 1741:        switch (n->type) {
                   1742:        case ROFFT_BLOCK:
1.143     kristaps 1743:                synopsis_pre(p, n);
1.328     schwarze 1744:                return 1;
1.379     schwarze 1745:        case ROFFT_BODY:
                   1746:                rmargin = p->tcol->rmargin;
                   1747:                if (n->flags & NODE_SYNPRETTY) {
1.362     schwarze 1748:                        p->tcol->rmargin = p->tcol->offset + term_len(p, 4);
1.263     schwarze 1749:                        p->flags |= TERMP_NOBREAK | TERMP_BRIND |
                   1750:                                        TERMP_HANG;
1.256     schwarze 1751:                }
1.33      kristaps 1752:                p->flags |= TERMP_NOSPACE;
1.1       kristaps 1753:                term_word(p, "(");
1.222     kristaps 1754:                p->flags |= TERMP_NOSPACE;
1.379     schwarze 1755:                if (n->flags & NODE_SYNPRETTY) {
1.256     schwarze 1756:                        term_flushln(p);
1.263     schwarze 1757:                        p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND |
                   1758:                                        TERMP_HANG);
1.360     schwarze 1759:                        p->flags |= TERMP_NOPAD;
1.362     schwarze 1760:                        p->tcol->offset = p->tcol->rmargin;
                   1761:                        p->tcol->rmargin = rmargin;
1.256     schwarze 1762:                }
1.328     schwarze 1763:                return 1;
1.379     schwarze 1764:        default:
                   1765:                return termp_bold_pre(p, pair, meta, n);
1.256     schwarze 1766:        }
1.1       kristaps 1767: }
                   1768:
                   1769: static void
                   1770: termp_fo_post(DECL_ARGS)
                   1771: {
1.314     schwarze 1772:        if (n->type != ROFFT_BODY)
1.143     kristaps 1773:                return;
                   1774:
1.222     kristaps 1775:        p->flags |= TERMP_NOSPACE;
1.143     kristaps 1776:        term_word(p, ")");
                   1777:
1.379     schwarze 1778:        if (n->flags & NODE_SYNPRETTY) {
1.222     kristaps 1779:                p->flags |= TERMP_NOSPACE;
1.143     kristaps 1780:                term_word(p, ";");
1.256     schwarze 1781:                term_flushln(p);
1.222     kristaps 1782:        }
1.1       kristaps 1783: }
                   1784:
                   1785: static int
                   1786: termp_bf_pre(DECL_ARGS)
                   1787: {
1.379     schwarze 1788:        switch (n->type) {
                   1789:        case ROFFT_HEAD:
1.328     schwarze 1790:                return 0;
1.379     schwarze 1791:        case ROFFT_BODY:
                   1792:                break;
                   1793:        default:
1.328     schwarze 1794:                return 1;
1.379     schwarze 1795:        }
                   1796:        switch (n->norm->Bf.font) {
                   1797:        case FONT_Em:
                   1798:                return termp_under_pre(p, pair, meta, n);
                   1799:        case FONT_Sy:
                   1800:                return termp_bold_pre(p, pair, meta, n);
                   1801:        default:
                   1802:                return termp_li_pre(p, pair, meta, n);
                   1803:        }
1.1       kristaps 1804: }
                   1805:
                   1806: static int
                   1807: termp_sm_pre(DECL_ARGS)
                   1808: {
1.379     schwarze 1809:        if (n->child == NULL)
1.269     schwarze 1810:                p->flags ^= TERMP_NONOSPACE;
1.379     schwarze 1811:        else if (strcmp(n->child->string, "on") == 0)
1.1       kristaps 1812:                p->flags &= ~TERMP_NONOSPACE;
1.269     schwarze 1813:        else
1.1       kristaps 1814:                p->flags |= TERMP_NONOSPACE;
1.269     schwarze 1815:
                   1816:        if (p->col && ! (TERMP_NONOSPACE & p->flags))
                   1817:                p->flags &= ~TERMP_NOSPACE;
1.1       kristaps 1818:
1.328     schwarze 1819:        return 0;
1.1       kristaps 1820: }
                   1821:
                   1822: static int
                   1823: termp_ap_pre(DECL_ARGS)
                   1824: {
                   1825:        p->flags |= TERMP_NOSPACE;
1.188     kristaps 1826:        term_word(p, "'");
1.1       kristaps 1827:        p->flags |= TERMP_NOSPACE;
1.328     schwarze 1828:        return 1;
1.1       kristaps 1829: }
                   1830:
                   1831: static void
                   1832: termp____post(DECL_ARGS)
                   1833: {
1.377     schwarze 1834:        struct roff_node *nn;
1.184     kristaps 1835:
                   1836:        /*
                   1837:         * Handle lists of authors.  In general, print each followed by
                   1838:         * a comma.  Don't print the comma if there are only two
                   1839:         * authors.
                   1840:         */
1.377     schwarze 1841:        if (n->tok == MDOC__A &&
                   1842:            (nn = roff_node_next(n)) != NULL && nn->tok == MDOC__A &&
                   1843:            ((nn = roff_node_next(nn)) == NULL || nn->tok != MDOC__A) &&
                   1844:            ((nn = roff_node_prev(n)) == NULL || nn->tok != MDOC__A))
                   1845:                return;
1.1       kristaps 1846:
1.95      kristaps 1847:        /* TODO: %U. */
                   1848:
1.377     schwarze 1849:        if (n->parent == NULL || n->parent->tok != MDOC_Rs)
1.187     kristaps 1850:                return;
                   1851:
1.222     kristaps 1852:        p->flags |= TERMP_NOSPACE;
1.377     schwarze 1853:        if (roff_node_next(n) == NULL) {
1.186     kristaps 1854:                term_word(p, ".");
                   1855:                p->flags |= TERMP_SENTENCE;
                   1856:        } else
                   1857:                term_word(p, ",");
1.1       kristaps 1858: }
                   1859:
                   1860: static int
1.102     kristaps 1861: termp_li_pre(DECL_ARGS)
                   1862: {
                   1863:        term_fontpush(p, TERMFONT_NONE);
1.328     schwarze 1864:        return 1;
1.102     kristaps 1865: }
                   1866:
                   1867: static int
1.1       kristaps 1868: termp_lk_pre(DECL_ARGS)
                   1869: {
1.358     schwarze 1870:        const struct roff_node *link, *descr, *punct;
1.1       kristaps 1871:
1.349     schwarze 1872:        if ((link = n->child) == NULL)
1.328     schwarze 1873:                return 0;
1.181     kristaps 1874:
1.358     schwarze 1875:        /* Find beginning of trailing punctuation. */
                   1876:        punct = n->last;
                   1877:        while (punct != link && punct->flags & NODE_DELIMC)
                   1878:                punct = punct->prev;
                   1879:        punct = punct->next;
                   1880:
1.349     schwarze 1881:        /* Link text. */
1.358     schwarze 1882:        if ((descr = link->next) != NULL && descr != punct) {
1.240     schwarze 1883:                term_fontpush(p, TERMFONT_UNDER);
1.358     schwarze 1884:                while (descr != punct) {
                   1885:                        if (descr->flags & (NODE_DELIMC | NODE_DELIMO))
                   1886:                                p->flags |= TERMP_NOSPACE;
1.240     schwarze 1887:                        term_word(p, descr->string);
                   1888:                        descr = descr->next;
                   1889:                }
1.347     schwarze 1890:                term_fontpop(p);
1.240     schwarze 1891:                p->flags |= TERMP_NOSPACE;
                   1892:                term_word(p, ":");
                   1893:        }
1.1       kristaps 1894:
1.349     schwarze 1895:        /* Link target. */
1.102     kristaps 1896:        term_fontpush(p, TERMFONT_BOLD);
1.240     schwarze 1897:        term_word(p, link->string);
1.102     kristaps 1898:        term_fontpop(p);
1.348     schwarze 1899:
1.349     schwarze 1900:        /* Trailing punctuation. */
1.358     schwarze 1901:        while (punct != NULL) {
1.349     schwarze 1902:                p->flags |= TERMP_NOSPACE;
1.358     schwarze 1903:                term_word(p, punct->string);
                   1904:                punct = punct->next;
1.349     schwarze 1905:        }
1.328     schwarze 1906:        return 0;
1.1       kristaps 1907: }
                   1908:
1.159     schwarze 1909: static int
                   1910: termp_bk_pre(DECL_ARGS)
                   1911: {
1.161     schwarze 1912:        switch (n->type) {
1.314     schwarze 1913:        case ROFFT_BLOCK:
1.166     kristaps 1914:                break;
1.314     schwarze 1915:        case ROFFT_HEAD:
1.328     schwarze 1916:                return 0;
1.314     schwarze 1917:        case ROFFT_BODY:
1.331     schwarze 1918:                if (n->parent->args != NULL || n->prev->child == NULL)
1.200     schwarze 1919:                        p->flags |= TERMP_PREKEEP;
1.166     kristaps 1920:                break;
1.161     schwarze 1921:        default:
                   1922:                abort();
                   1923:        }
1.328     schwarze 1924:        return 1;
1.159     schwarze 1925: }
                   1926:
                   1927: static void
                   1928: termp_bk_post(DECL_ARGS)
                   1929: {
1.314     schwarze 1930:        if (n->type == ROFFT_BODY)
1.161     schwarze 1931:                p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
1.203     kristaps 1932: }
                   1933:
1.379     schwarze 1934: /*
                   1935:  * If we are in an `Rs' and there is a journal present,
                   1936:  * then quote us instead of underlining us (for disambiguation).
                   1937:  */
1.203     kristaps 1938: static void
                   1939: termp__t_post(DECL_ARGS)
                   1940: {
1.379     schwarze 1941:        if (n->parent != NULL && n->parent->tok == MDOC_Rs &&
1.264     schwarze 1942:            n->parent->norm->Rs.quote_T)
1.245     schwarze 1943:                termp_quote_post(p, pair, meta, n);
                   1944:        termp____post(p, pair, meta, n);
1.203     kristaps 1945: }
                   1946:
                   1947: static int
                   1948: termp__t_pre(DECL_ARGS)
                   1949: {
1.379     schwarze 1950:        if (n->parent != NULL && n->parent->tok == MDOC_Rs &&
1.264     schwarze 1951:            n->parent->norm->Rs.quote_T)
1.328     schwarze 1952:                return termp_quote_pre(p, pair, meta, n);
1.379     schwarze 1953:        else
                   1954:                return termp_under_pre(p, pair, meta, n);
1.159     schwarze 1955: }
1.1       kristaps 1956:
                   1957: static int
1.69      kristaps 1958: termp_under_pre(DECL_ARGS)
1.1       kristaps 1959: {
1.334     schwarze 1960:        term_fontpush(p, TERMFONT_UNDER);
1.328     schwarze 1961:        return 1;
1.369     schwarze 1962: }
                   1963:
                   1964: static int
                   1965: termp_abort_pre(DECL_ARGS)
                   1966: {
                   1967:        abort();
1.84      kristaps 1968: }

CVSweb