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

Annotation of mandoc/mdoc_term.c, Revision 1.379

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

CVSweb