=================================================================== RCS file: /cvs/mandoc/mdoc_man.c,v retrieving revision 1.119 retrieving revision 1.126 diff -u -p -r1.119 -r1.126 --- mandoc/mdoc_man.c 2017/06/08 12:54:58 1.119 +++ mandoc/mdoc_man.c 2018/04/11 17:11:13 1.126 @@ -1,6 +1,6 @@ -/* $Id: mdoc_man.c,v 1.119 2017/06/08 12:54:58 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.126 2018/04/11 17:11:13 schwarze Exp $ */ /* - * Copyright (c) 2011-2017 Ingo Schwarze + * Copyright (c) 2011-2018 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 @@ -125,14 +125,16 @@ static void print_count(int *); static void print_node(DECL_ARGS); static const void_fp roff_manacts[ROFF_MAX] = { - pre_br, - pre_onearg, - pre_ft, - pre_onearg, - pre_onearg, - pre_sp, - pre_ta, - pre_onearg, + pre_br, /* br */ + pre_onearg, /* ce */ + pre_ft, /* ft */ + pre_onearg, /* ll */ + pre_onearg, /* mc */ + pre_onearg, /* po */ + pre_onearg, /* rj */ + pre_sp, /* sp */ + pre_ta, /* ta */ + pre_onearg, /* ti */ }; static const struct manact __manacts[MDOC_MAX - MDOC_Dd] = { @@ -196,22 +198,22 @@ static const struct manact __manacts[MDOC_MAX - MDOC_D { NULL, pre_bf, post_bf, NULL, NULL }, /* Bf */ { cond_body, pre_enc, post_enc, "[", "]" }, /* Bo */ { cond_body, pre_enc, post_enc, "[", "]" }, /* Bq */ - { NULL, NULL, NULL, NULL, NULL }, /* Bsx */ - { NULL, NULL, NULL, NULL, NULL }, /* Bx */ + { NULL, pre_bk, post_bk, NULL, NULL }, /* Bsx */ + { NULL, pre_bk, post_bk, NULL, NULL }, /* Bx */ { NULL, pre_skip, NULL, NULL, NULL }, /* Db */ { NULL, NULL, NULL, NULL, NULL }, /* Dc */ - { cond_body, pre_enc, post_enc, "\\(Lq", "\\(Rq" }, /* Do */ - { cond_body, pre_enc, post_enc, "\\(Lq", "\\(Rq" }, /* Dq */ + { cond_body, pre_enc, post_enc, "\\(lq", "\\(rq" }, /* Do */ + { cond_body, pre_enc, post_enc, "\\(lq", "\\(rq" }, /* Dq */ { NULL, NULL, NULL, NULL, NULL }, /* Ec */ { NULL, NULL, NULL, NULL, NULL }, /* Ef */ { NULL, pre_em, post_font, NULL, NULL }, /* Em */ { cond_body, pre_eo, post_eo, NULL, NULL }, /* Eo */ - { NULL, NULL, NULL, NULL, NULL }, /* Fx */ + { NULL, pre_bk, post_bk, NULL, NULL }, /* Fx */ { NULL, pre_sy, post_font, NULL, NULL }, /* Ms */ { NULL, pre_no, NULL, NULL, NULL }, /* No */ { NULL, pre_ns, NULL, NULL, NULL }, /* Ns */ - { NULL, NULL, NULL, NULL, NULL }, /* Nx */ - { NULL, NULL, NULL, NULL, NULL }, /* Ox */ + { NULL, pre_bk, post_bk, NULL, NULL }, /* Nx */ + { NULL, pre_bk, post_bk, NULL, NULL }, /* Ox */ { NULL, NULL, NULL, NULL, NULL }, /* Pc */ { NULL, NULL, post_pf, NULL, NULL }, /* Pf */ { cond_body, pre_enc, post_enc, "(", ")" }, /* Po */ @@ -252,7 +254,7 @@ static const struct manact __manacts[MDOC_MAX - MDOC_D { NULL, NULL, post_percent, NULL, NULL }, /* %C */ { NULL, pre_skip, NULL, NULL, NULL }, /* Es */ { cond_body, pre_en, post_en, NULL, NULL }, /* En */ - { NULL, NULL, NULL, NULL, NULL }, /* Dx */ + { NULL, pre_bk, post_bk, NULL, NULL }, /* Dx */ { NULL, NULL, post_percent, NULL, NULL }, /* %Q */ { NULL, NULL, post_percent, NULL, NULL }, /* %U */ { NULL, NULL, NULL, NULL, NULL }, /* Ta */ @@ -608,6 +610,14 @@ man_mdoc(void *arg, const struct roff_man *mdoc) { struct roff_node *n; + printf(".\\\" Automatically generated from an mdoc input file." + " Do not edit.\n"); + for (n = mdoc->first->child; n != NULL; n = n->next) { + if (n->type != ROFFT_COMMENT) + break; + printf(".\\\"%s\n", n->string); + } + printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n", mdoc->meta.title, (mdoc->meta.msec == NULL ? "" : mdoc->meta.msec), @@ -622,7 +632,7 @@ man_mdoc(void *arg, const struct roff_man *mdoc) fontqueue.head = fontqueue.tail = mandoc_malloc(8); *fontqueue.tail = 'R'; } - for (n = mdoc->first->child; n != NULL; n = n->next) + for (; n != NULL; n = n->next) print_node(&mdoc->meta, n); putchar('\n'); } @@ -990,11 +1000,11 @@ post_bf(DECL_ARGS) static int pre_bk(DECL_ARGS) { - switch (n->type) { case ROFFT_BLOCK: return 1; case ROFFT_BODY: + case ROFFT_ELEM: outflags |= MMAN_Bk; return 1; default: @@ -1005,9 +1015,18 @@ pre_bk(DECL_ARGS) static void post_bk(DECL_ARGS) { - - if (n->type == ROFFT_BODY) + switch (n->type) { + case ROFFT_ELEM: + while ((n = n->parent) != NULL) + if (n->tok == MDOC_Bk) + return; + /* FALLTHROUGH */ + case ROFFT_BODY: outflags &= ~MMAN_Bk; + break; + default: + break; + } } static int @@ -1397,7 +1416,7 @@ pre_it(DECL_ARGS) if (bln->norm->Bl.type == LIST_diag) print_line(".B \"", 0); else - print_line(".R \"", 0); + print_line(".BR \\& \"", 0); outflags &= ~MMAN_spc; return 1; case LIST_bullet: @@ -1536,7 +1555,6 @@ static int pre_lk(DECL_ARGS) { const struct roff_node *link, *descr, *punct; - int display; if ((link = n->child) == NULL) return 0; @@ -1559,12 +1577,6 @@ pre_lk(DECL_ARGS) } /* Link target. */ - display = man_strlen(link->string) >= 26; - if (display) { - print_line(".RS", MMAN_Bk_susp); - print_word("6n"); - outflags |= MMAN_nl; - } font_push('B'); print_word(link->string); font_pop(); @@ -1574,8 +1586,6 @@ pre_lk(DECL_ARGS) print_word(punct->string); punct = punct->next; } - if (display) - print_line(".RE", MMAN_nl); return 0; }