=================================================================== RCS file: /cvs/mandoc/mdoc_man.c,v retrieving revision 1.131 retrieving revision 1.135 diff -u -p -r1.131 -r1.135 --- mandoc/mdoc_man.c 2018/12/30 00:49:55 1.131 +++ mandoc/mdoc_man.c 2020/02/20 22:55:42 1.135 @@ -1,6 +1,6 @@ -/* $Id: mdoc_man.c,v 1.131 2018/12/30 00:49:55 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.135 2020/02/20 22:55:42 schwarze Exp $ */ /* - * Copyright (c) 2011-2018 Ingo Schwarze + * Copyright (c) 2011-2020 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -104,6 +104,7 @@ static int pre_lk(DECL_ARGS); static int pre_li(DECL_ARGS); static int pre_nm(DECL_ARGS); static int pre_no(DECL_ARGS); +static void pre_noarg(DECL_ARGS); static int pre_ns(DECL_ARGS); static void pre_onearg(DECL_ARGS); static int pre_pp(DECL_ARGS); @@ -128,9 +129,11 @@ static void print_node(DECL_ARGS); static const void_fp roff_man_acts[ROFF_MAX] = { pre_br, /* br */ pre_onearg, /* ce */ + pre_noarg, /* fi */ pre_ft, /* ft */ pre_onearg, /* ll */ pre_onearg, /* mc */ + pre_noarg, /* nf */ pre_onearg, /* po */ pre_onearg, /* rj */ pre_sp, /* sp */ @@ -259,6 +262,7 @@ static const struct mdoc_man_act mdoc_man_acts[MDOC_MA { NULL, NULL, post_percent, NULL, NULL }, /* %Q */ { NULL, NULL, post_percent, NULL, NULL }, /* %U */ { NULL, NULL, NULL, NULL, NULL }, /* Ta */ + { NULL, pre_skip, NULL, NULL, NULL }, /* Tg */ }; static const struct mdoc_man_act *mdoc_man_act(enum roff_tok); @@ -579,9 +583,9 @@ print_width(const struct mdoc_bl *bl, const struct rof /* Set up the current list. */ if (chsz > sz && bl->type != LIST_tag) - print_block(".HP", 0); + print_block(".HP", MMAN_spc); else { - print_block(".TP", 0); + print_block(".TP", MMAN_spc); remain = sz + 2; } if (numeric) { @@ -936,7 +940,6 @@ post_aq(DECL_ARGS) static int pre_bd(DECL_ARGS) { - outflags &= ~(MMAN_PP | MMAN_sp | MMAN_br); if (DISP_unfilled == n->norm->Bd.type || @@ -951,12 +954,27 @@ pre_bd(DECL_ARGS) static void post_bd(DECL_ARGS) { + enum roff_tok bef, now; /* Close out this display. */ print_line(".RE", MMAN_nl); - if (DISP_unfilled == n->norm->Bd.type || - DISP_literal == n->norm->Bd.type) - print_line(".fi", MMAN_nl); + bef = n->flags & NODE_NOFILL ? ROFF_nf : ROFF_fi; + if (n->last == NULL) + now = n->norm->Bd.type == DISP_unfilled || + n->norm->Bd.type == DISP_literal ? ROFF_nf : ROFF_fi; + else if (n->last->tok == ROFF_nf) + now = ROFF_nf; + else if (n->last->tok == ROFF_fi) + now = ROFF_fi; + else + now = n->last->flags & NODE_NOFILL ? ROFF_nf : ROFF_fi; + if (bef != now) { + outflags |= MMAN_nl; + print_word("."); + outflags &= ~MMAN_spc; + print_word(roff_name[bef]); + outflags |= MMAN_nl; + } /* Maybe we are inside an enclosing list? */ if (NULL != n->parent->next) @@ -1607,7 +1625,6 @@ pre_onearg(DECL_ARGS) static int pre_li(DECL_ARGS) { - font_push('R'); return 1; } @@ -1640,7 +1657,6 @@ pre_nm(DECL_ARGS) static void post_nm(DECL_ARGS) { - switch (n->type) { case ROFFT_BLOCK: outflags &= ~MMAN_Bk; @@ -1658,15 +1674,23 @@ post_nm(DECL_ARGS) static int pre_no(DECL_ARGS) { - outflags |= MMAN_spc_force; return 1; } +static void +pre_noarg(DECL_ARGS) +{ + outflags |= MMAN_nl; + print_word("."); + outflags &= ~MMAN_spc; + print_word(roff_name[n->tok]); + outflags |= MMAN_nl; +} + static int pre_ns(DECL_ARGS) { - outflags &= ~MMAN_spc; return 0; }