=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mdoc_man.c,v retrieving revision 1.28 retrieving revision 1.29 diff -c -r1.28 -r1.29 *** src/usr.bin/mandoc/mdoc_man.c 2012/07/10 14:35:57 1.28 --- src/usr.bin/mandoc/mdoc_man.c 2012/07/10 19:53:11 1.29 *************** *** 1,4 **** ! /* $Id: mdoc_man.c,v 1.28 2012/07/10 14:35:57 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Ingo Schwarze * --- 1,4 ---- ! /* $Id: mdoc_man.c,v 1.29 2012/07/10 19:53:11 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Ingo Schwarze * *************** *** 96,102 **** static int pre_xr(DECL_ARGS); static void print_word(const char *); static void print_offs(const char *); ! static void print_width(const char *); static void print_count(int *); static void print_node(DECL_ARGS); --- 96,102 ---- static int pre_xr(DECL_ARGS); static void print_word(const char *); static void print_offs(const char *); ! static void print_width(const char *, const struct mdoc_node *); static void print_count(int *); static void print_node(DECL_ARGS); *************** *** 356,377 **** } void ! print_width(const char *v) { char buf[24]; struct roffsu su; ! size_t sz; if (a2roffsu(v, &su, SCALE_MAX)) { if (SCALE_EN == su.unit) sz = su.scale; else { print_word(v); return; } } else sz = strlen(v); snprintf(buf, sizeof(buf), "%ldn", sz + 2); print_word(buf); } --- 356,389 ---- } void ! print_width(const char *v, const struct mdoc_node *child) { char buf[24]; struct roffsu su; ! size_t sz, chsz; + /* XXX Rough estimation, might have multiple parts. */ + chsz = (NULL != child && MDOC_TEXT == child->type) ? + strlen(child->string) : 0; + if (a2roffsu(v, &su, SCALE_MAX)) { if (SCALE_EN == su.unit) sz = su.scale; else { + if (chsz) + print_word(".HP"); + else + print_word(".TP"); print_word(v); return; } } else sz = strlen(v); + if (chsz > sz) + print_word(".HP"); + else + print_word(".TP"); snprintf(buf, sizeof(buf), "%ldn", sz + 2); print_word(buf); } *************** *** 1023,1030 **** case (LIST_dash): /* FALLTHROUGH */ case (LIST_hyphen): ! print_word(".TP"); ! print_width(bln->norm->Bl.width); outflags |= MMAN_nl; font_push('B'); if (LIST_bullet == bln->norm->Bl.type) --- 1035,1041 ---- case (LIST_dash): /* FALLTHROUGH */ case (LIST_hyphen): ! print_width(bln->norm->Bl.width, NULL); outflags |= MMAN_nl; font_push('B'); if (LIST_bullet == bln->norm->Bl.type) *************** *** 1034,1048 **** font_pop(); break; case (LIST_enum): ! print_word(".TP"); ! print_width(bln->norm->Bl.width); outflags |= MMAN_nl; print_count(&bln->norm->Bl.count); outflags |= MMAN_nl; break; default: if (bln->norm->Bl.width) ! print_width(bln->norm->Bl.width); break; } outflags |= MMAN_nl; --- 1045,1062 ---- font_pop(); break; case (LIST_enum): ! print_width(bln->norm->Bl.width, NULL); outflags |= MMAN_nl; print_count(&bln->norm->Bl.count); outflags |= MMAN_nl; break; + case (LIST_hang): + print_width(bln->norm->Bl.width, n->child); + outflags |= MMAN_nl; + break; default: if (bln->norm->Bl.width) ! print_width(bln->norm->Bl.width, n->child); break; } outflags |= MMAN_nl;