=================================================================== RCS file: /cvs/mandoc/mdoc_man.c,v retrieving revision 1.113 retrieving revision 1.119 diff -u -p -r1.113 -r1.119 --- mandoc/mdoc_man.c 2017/05/05 15:17:32 1.113 +++ mandoc/mdoc_man.c 2017/06/08 12:54:58 1.119 @@ -1,4 +1,4 @@ -/* $Id: mdoc_man.c,v 1.113 2017/05/05 15:17:32 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.119 2017/06/08 12:54:58 schwarze Exp $ */ /* * Copyright (c) 2011-2017 Ingo Schwarze * @@ -101,10 +101,10 @@ static int pre_in(DECL_ARGS); static int pre_it(DECL_ARGS); static int pre_lk(DECL_ARGS); static int pre_li(DECL_ARGS); -static void pre_ll(DECL_ARGS); static int pre_nm(DECL_ARGS); static int pre_no(DECL_ARGS); static int pre_ns(DECL_ARGS); +static void pre_onearg(DECL_ARGS); static int pre_pp(DECL_ARGS); static int pre_rs(DECL_ARGS); static int pre_sm(DECL_ARGS); @@ -112,6 +112,7 @@ static void pre_sp(DECL_ARGS); static int pre_sect(DECL_ARGS); static int pre_sy(DECL_ARGS); static void pre_syn(const struct roff_node *); +static void pre_ta(DECL_ARGS); static int pre_vt(DECL_ARGS); static int pre_xr(DECL_ARGS); static void print_word(const char *); @@ -125,9 +126,13 @@ static void print_node(DECL_ARGS); static const void_fp roff_manacts[ROFF_MAX] = { pre_br, + pre_onearg, pre_ft, - pre_ll, + pre_onearg, + pre_onearg, pre_sp, + pre_ta, + pre_onearg, }; static const struct manact __manacts[MDOC_MAX - MDOC_Dd] = { @@ -443,7 +448,6 @@ static void print_line(const char *s, int newflags) { - outflags &= ~MMAN_br; outflags |= MMAN_nl; print_word(s); outflags |= newflags; @@ -472,6 +476,7 @@ print_offs(const char *v, int keywords) { char buf[24]; struct roffsu su; + const char *end; int sz; print_line(".RS", MMAN_Bk_susp); @@ -483,8 +488,11 @@ print_offs(const char *v, int keywords) sz = 6; else if (keywords && !strcmp(v, "indent-two")) sz = 12; - else if (a2roffsu(v, &su, SCALE_EN) > 1) { - if (SCALE_EN == su.unit) + else { + end = a2roffsu(v, &su, SCALE_EN); + if (end == NULL || *end != '\0') + sz = man_strlen(v); + else if (SCALE_EN == su.unit) sz = su.scale; else { /* @@ -498,8 +506,7 @@ print_offs(const char *v, int keywords) outflags |= MMAN_nl; return; } - } else - sz = man_strlen(v); + } /* * We are inside an enclosing list. @@ -521,6 +528,7 @@ print_width(const struct mdoc_bl *bl, const struct rof { char buf[24]; struct roffsu su; + const char *end; int numeric, remain, sz, chsz; numeric = 1; @@ -529,15 +537,17 @@ print_width(const struct mdoc_bl *bl, const struct rof /* Convert the width into a number (of characters). */ if (bl->width == NULL) sz = (bl->type == LIST_hang) ? 6 : 0; - else if (a2roffsu(bl->width, &su, SCALE_MAX) > 1) { - if (SCALE_EN == su.unit) + else { + end = a2roffsu(bl->width, &su, SCALE_MAX); + if (end == NULL || *end != '\0') + sz = man_strlen(bl->width); + else if (SCALE_EN == su.unit) sz = su.scale; else { sz = 0; numeric = 0; } - } else - sz = man_strlen(bl->width); + } /* XXX Rough estimation, might have multiple parts. */ if (bl->type == LIST_enum) @@ -1525,16 +1535,22 @@ post_lb(DECL_ARGS) static int pre_lk(DECL_ARGS) { - const struct roff_node *link, *descr; + const struct roff_node *link, *descr, *punct; int display; if ((link = n->child) == NULL) return 0; + /* Find beginning of trailing punctuation. */ + punct = n->last; + while (punct != link && punct->flags & NODE_DELIMC) + punct = punct->prev; + punct = punct->next; + /* Link text. */ - if ((descr = link->next) != NULL && !(descr->flags & NODE_DELIMC)) { + if ((descr = link->next) != NULL && descr != punct) { font_push('I'); - while (descr != NULL && !(descr->flags & NODE_DELIMC)) { + while (descr != punct) { print_word(descr->string); descr = descr->next; } @@ -1554,9 +1570,9 @@ pre_lk(DECL_ARGS) font_pop(); /* Trailing punctuation. */ - while (descr != NULL) { - print_word(descr->string); - descr = descr->next; + while (punct != NULL) { + print_word(punct->string); + punct = punct->next; } if (display) print_line(".RE", MMAN_nl); @@ -1564,12 +1580,18 @@ pre_lk(DECL_ARGS) } static void -pre_ll(DECL_ARGS) +pre_onearg(DECL_ARGS) { - print_line(".ll", 0); + outflags |= MMAN_nl; + print_word("."); + outflags &= ~MMAN_spc; + print_word(roff_name[n->tok]); if (n->child != NULL) print_word(n->child->string); outflags |= MMAN_nl; + if (n->tok == ROFF_ce) + for (n = n->child->next; n != NULL; n = n->next) + print_node(meta, n); } static int @@ -1713,6 +1735,15 @@ pre_sy(DECL_ARGS) font_push('B'); return 1; +} + +static void +pre_ta(DECL_ARGS) +{ + print_line(".ta", 0); + for (n = n->child; n != NULL; n = n->next) + print_word(n->string); + outflags |= MMAN_nl; } static int